diff options
author | mwebster <mwebster> | 2006-10-04 13:35:09 +0000 |
---|---|---|
committer | mwebster <mwebster> | 2006-10-04 13:35:09 +0000 |
commit | 6b31b32ae338cdecea6e20aa87fe05ca0cc2fb57 (patch) | |
tree | b22499c9d10ffeb8779f88e2dbd7c5bff447ffba /loadtime/src | |
parent | 513564a9e5b5ae5d03c4f0547ee7823e903d3c52 (diff) | |
download | aspectj-6b31b32ae338cdecea6e20aa87fe05ca0cc2fb57.tar.gz aspectj-6b31b32ae338cdecea6e20aa87fe05ca0cc2fb57.zip |
Bug 132080 "LTW concrete-aspect definitions not exposed to weaver"
Diffstat (limited to 'loadtime/src')
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java | 41 | ||||
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java | 4 |
2 files changed, 39 insertions, 6 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index e9d46182f..6d814ef95 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -40,6 +40,8 @@ import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; import org.aspectj.weaver.Lint.Kind; import org.aspectj.weaver.bcel.BcelWeaver; +import org.aspectj.weaver.bcel.BcelWorld; +import org.aspectj.weaver.bcel.Utility; import org.aspectj.weaver.loadtime.definition.Definition; import org.aspectj.weaver.loadtime.definition.DocumentParser; import org.aspectj.weaver.ltw.LTWWorld; @@ -73,6 +75,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { private StringBuffer namespace; private IWeavingContext weavingContext; + private List concreteAspects = new ArrayList(); + private static Trace trace = TraceFactory.getTraceFactory().getTrace(ClassLoaderWeavingAdaptor.class); public ClassLoaderWeavingAdaptor() { @@ -156,6 +160,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { // after adding aspects weaver.prepareForWeave(); + boolean success = weaveAndDefineConceteAspects(); + if (!success) disable(); } else { bcelWorld = null; @@ -410,11 +416,12 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { success = false; break; } - this.generatedClassHandler.acceptClass( - concreteAspect.name, - gen.getBytes() - ); - /*ResolvedType aspect = */weaver.addLibraryAspect(concreteAspect.name); + + ((BcelWorld)weaver.getWorld()).addSourceObjectType(Utility.makeJavaClass(concreteAspect.name, gen.getBytes())); + + concreteAspects.add(gen); + + weaver.addLibraryAspect(concreteAspect.name); //generate key for SC if(namespace==null){ @@ -425,7 +432,6 @@ 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) { @@ -442,6 +448,29 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { if (trace.isTraceEnabled()) trace.exit("registerAspects",isEnabled()); } + private boolean weaveAndDefineConceteAspects () { + if (trace.isTraceEnabled()) trace.enter("weaveAndDefineConceteAspects",this,concreteAspects); + boolean success = true; + + for (Iterator iterator = concreteAspects.iterator(); iterator.hasNext();) { + ConcreteAspectCodeGen gen = (ConcreteAspectCodeGen)iterator.next(); + String name = gen.getClassName(); + byte[] bytes = gen.getBytes(); + + try { + byte[] newBytes = weaveClass(name, bytes); + this.generatedClassHandler.acceptClass(name,newBytes); + } + catch (IOException ex) { + trace.error("weaveAndDefineConceteAspects",ex); + error("exception weaving aspect '" + name + "'",ex); + } + } + + if (trace.isTraceEnabled()) trace.exit("weaveAndDefineConceteAspects",success); + return success; + } + /** * Register the include / exclude filters * We duplicate simple patterns in startWith filters that will allow faster matching without ResolvedType diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java b/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java index c3e9614b3..2b3a36381 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java @@ -265,6 +265,10 @@ public class ConcreteAspectCodeGen { return false; } + public String getClassName () { + return m_concreteAspect.name; + } + /** * Build the bytecode for the concrete aspect * |