summaryrefslogtreecommitdiffstats
path: root/loadtime
diff options
context:
space:
mode:
authormwebster <mwebster>2006-08-24 17:32:00 +0000
committermwebster <mwebster>2006-08-24 17:32:00 +0000
commit04fa1dcce12934cc5cfe1e5e8b66523c10e93672 (patch)
tree1e8d4eca711228fbc0fd1cc21fe958fdd1f77e54 /loadtime
parent137ce3fd3c106581c35b3eba6f2e95612a34046a (diff)
downloadaspectj-04fa1dcce12934cc5cfe1e5e8b66523c10e93672.tar.gz
aspectj-04fa1dcce12934cc5cfe1e5e8b66523c10e93672.zip
Bug 129525 "Don't Dump Bytecodes to Syserr in LTW" (don't throw AbortException in LTW message handler)
Diffstat (limited to 'loadtime')
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java11
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java23
2 files changed, 31 insertions, 3 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
index 2e53d0cfa..7e2edb5c0 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
@@ -355,6 +355,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
*/
private void registerAspects(final BcelWeaver weaver, final ClassLoader loader, final List definitions) {
if (trace.isTraceEnabled()) trace.enter("registerAspects",this, new Object[] { weaver, loader, definitions} );
+ boolean success = true;
+
//TODO: the exclude aspect allow to exclude aspect defined upper in the CL hierarchy - is it what we want ??
// if not, review the getResource so that we track which resource is defined by which CL
@@ -393,6 +395,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
ConcreteAspectCodeGen gen = new ConcreteAspectCodeGen(concreteAspect, weaver.getWorld());
if (!gen.validate()) {
error("Concrete-aspect '"+concreteAspect.name+"' could not be registered");
+ success = false;
break;
}
this.generatedClassHandler.acceptClass(
@@ -412,8 +415,14 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
}
// System.out.println("ClassLoaderWeavingAdaptor.registerAspects() classloader=" + weavingContext.getClassLoaderName() + ", namespace=" + namespace);
+ /* We couldn't register one or more aspects so disable the adaptor */
+ if (!success) {
+ disable();
+ warn("failure(s) registering aspects. Disabling weaver for class loader " + getClassLoaderName(loader));
+ }
+
/* We didn't register any aspects so disable the adaptor */
- if (namespace == null) {
+ else if (namespace == null) {
disable();
info("no aspects registered. Disabling weaver for class loader " + getClassLoaderName(loader));
}
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java b/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java
index 0dc1506df..fca4a23a5 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java
@@ -24,7 +24,10 @@ import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import org.aspectj.bridge.AbortException;
import org.aspectj.weaver.ExtensibleURLClassLoader;
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
import org.aspectj.weaver.tools.WeavingAdaptor;
import org.aspectj.weaver.tools.WeavingClassLoader;
@@ -37,6 +40,8 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
private WeavingAdaptor adaptor;
private boolean initializingAdaptor;
private Map generatedClasses = new HashMap(); /* String -> byte[] */
+
+ private static Trace trace = TraceFactory.getTraceFactory().getTrace(WeavingURLClassLoader.class);
/*
* This constructor is needed when using "-Djava.system.class.loader".
@@ -48,7 +53,9 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
public WeavingURLClassLoader (URL[] urls, ClassLoader parent) {
super(urls,parent);
+ if (trace.isTraceEnabled()) trace.enter("<init>",this,new Object[] { urls, parent });
// System.out.println("WeavingURLClassLoader.WeavingURLClassLoader()");
+ if (trace.isTraceEnabled()) trace.exit("<init>");
}
public WeavingURLClassLoader (URL[] classURLs, URL[] aspectURLs, ClassLoader parent) {
@@ -106,6 +113,7 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
* Override to weave class using WeavingAdaptor
*/
protected Class defineClass(String name, byte[] b, CodeSource cs) throws IOException {
+ if (trace.isTraceEnabled()) trace.enter("defineClass",this,new Object[] { name, b, cs });
// System.err.println("? WeavingURLClassLoader.defineClass(" + name + ", [" + b.length + "])");
/* Avoid recursion during adaptor initialization */
@@ -116,9 +124,20 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
createAdaptor();
}
- b = adaptor.weaveClass(name,b);
+ try {
+ b = adaptor.weaveClass(name,b);
+ }
+ catch (AbortException ex) {
+ trace.error("defineClass",ex);
+ throw ex;
+ }
+ catch (Throwable th) {
+ trace.error("defineClass",th);
+ }
}
- return super.defineClass(name, b, cs);
+ Class clazz = super.defineClass(name, b, cs);
+ if (trace.isTraceEnabled()) trace.exit("defineClass",clazz);
+ return clazz;
}
private void createAdaptor () {