Revision: 7202
Author: [email protected]
Date: Mon Nov 30 11:56:48 2009
Log: Preload InternalCompilerException.

Prevents getting NoClassDefFoundError trying to load it under out of memory  
and other strange. conditions

Review by: spoon (desk)
http://code.google.com/p/google-web-toolkit/source/detail?r=7202

Modified:
  /trunk/dev/core/src/com/google/gwt/dev/jjs/InternalCompilerException.java
  /trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
  /trunk/dev/core/src/com/google/gwt/dev/js/ast/JsVisitor.java

=======================================
---  
/trunk/dev/core/src/com/google/gwt/dev/jjs/InternalCompilerException.java       
 
Wed Oct 24 23:02:55 2007
+++  
/trunk/dev/core/src/com/google/gwt/dev/jjs/InternalCompilerException.java       
 
Mon Nov 30 11:56:48 2009
@@ -66,6 +66,15 @@
     * Tracks if there's a pending addNode() to avoid recursion sickness.
     */
    private static final ThreadLocal<InternalCompilerException> pendingICE =  
new ThreadLocal<InternalCompilerException>();
+
+  /**
+   * Force this class to be preloaded. If we don't preload this class, we  
can
+   * get into bad behavior if we later try to load this class under out of
+   * memory or out of stack conditions.
+   */
+  public static void preload() {
+    // Nothing to do, JVM will initialize this class on static invocation.
+  }

    private final List<NodeInfo> nodeTrace = new ArrayList<NodeInfo>();

=======================================
---  
/trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java        
 
Mon Nov 23 09:14:03 2009
+++  
/trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java        
 
Mon Nov 30 11:56:48 2009
@@ -395,6 +395,8 @@
        String[] additionalRootTypes, JJSOptions options,
        boolean singlePermutation) throws UnableToCompleteException {

+    InternalCompilerException.preload();
+
      if (additionalRootTypes == null) {
        additionalRootTypes = Empty.STRINGS;
      }
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/js/ast/JsVisitor.java        Mon Oct 
26  
14:02:26 2009
+++ /trunk/dev/core/src/com/google/gwt/dev/js/ast/JsVisitor.java        Mon Nov 
30  
11:56:48 2009
@@ -458,9 +458,6 @@
      InternalCompilerException ice;
      if (e instanceof InternalCompilerException) {
        ice = (InternalCompilerException) e;
-    } else if (e instanceof OutOfMemoryError) {
-      // Just rethrow, it's not our problem.
-      throw (OutOfMemoryError) e;
      } else {
        ice = new InternalCompilerException("Unexpected error during  
visit.", e);
      }

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to