From d266e547aca31ae96fd8d469620b036ae9430989 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 10 Aug 2010 16:03:11 +0000 Subject: [PATCH] 175814: fixes: chaining preclinits if they are too large (too many tjpsps) and on error define original form of class and proceed, rather than failing completely --- .../weaver/loadtime/WeavingURLClassLoader.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java b/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java index eab084fb6..94ca39af1 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java @@ -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; -- 2.39.5