]> source.dussan.org Git - aspectj.git/commitdiff
175814: fixes: chaining preclinits if they are too large (too many tjpsps) and on...
authoraclement <aclement>
Tue, 10 Aug 2010 16:03:11 +0000 (16:03 +0000)
committeraclement <aclement>
Tue, 10 Aug 2010 16:03:11 +0000 (16:03 +0000)
loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java

index eab084fb65ed4d396c66e0ff995fdb33c88b73e7..94ca39af1b194812fec96e33862a0118a100ab07 100644 (file)
@@ -9,6 +9,8 @@
  * Contributors: 
  *     Matthew Webster, Adrian Colyer, 
  *     Martin Lippert     initial implementation 
+ *     Andy Clement
+ *     Abraham Nevado
  * ******************************************************************/
 
 package org.aspectj.weaver.loadtime;
@@ -121,7 +123,7 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
                if (trace.isTraceEnabled())
                        trace.enter("defineClass", this, new Object[] { name, b, cs });
                // System.err.println("? WeavingURLClassLoader.defineClass(" + name + ", [" + b.length + "])");
-
+               byte orig[] = b;
                /* Avoid recursion during adaptor initialization */
                if (!initializingAdaptor) {
 
@@ -139,7 +141,15 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
                                trace.error("defineClass", th);
                        }
                }
-               Class clazz = super.defineClass(name, b, cs);
+               Class clazz;
+               
+               // On error, define the original form of the class and log the issue
+               try { 
+                       clazz= super.defineClass(name, b, cs);
+               } catch (Throwable th) {
+                       trace.error("Weaving class problem. Original class has been returned. The error was caused because of: " + th, th);
+                       clazz= super.defineClass(name, orig, cs);
+               }
                if (trace.isTraceEnabled())
                        trace.exit("defineClass", clazz);
                return clazz;