Community
Participate
Working Groups
There is a performance optimization in CompilationAndWeavingContext that assumes by default that we are in a single threaded environment unless the JVMTI agent is used. Unfortunately this ignores other LTW scenarios including using the JRockit agent, Aj directly or instantiating a WeavingAdaptor. We should assume we are in a multi-threaded environment by default and determine when we are not instead e.g. AJDT or ajc. java.util.EmptyStackException at java.util.Stack.peek(Stack.java(Inlined Compiled Code)) at java.util.Stack.pop(Stack.java(Inlined Compiled Code)) at org.aspectj.bridge.context.CompilationAndWeavingContext.leavingPhase(CompilationAndWeavingContext.java(Inlined Compiled Code)) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java(Compiled Code)) at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java(Inlined Compiled Code)) at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java(Compiled Code)) at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConceteAspects(ClassLoaderWeavingAdaptor.java:471) at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(ClassLoaderWeavingAdaptor.java:159) at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(Aj.java(Inlined Compiled Code)) at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.getWeavingAdaptor(Aj.java(Inlined Compiled Code)) at org.aspectj.weaver.loadtime.Aj$WeaverContainer.getWeaver(Aj.java(Compiled Code)) at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java(Compiled Code)) ...
I believe this bug is caused by Bug 120817 "[performance]Thread Safety & 8% Optimization : Use ThreadLocal for CompilationAndWeavingContext". Although not explicit the commit comment "Put compilation-and-weaving-context into multi-thread mode when doing LTW" tallies with Comment #4 in the bug report. My suggested fix is to add a call setMultiThreaded(false) in AjBuildManager. This class cannot be called by the weaver (and so will not affect LTW) as it is in a higher module. It is used by all the command line tools via org.aspectj.tools.ajc.Main and AJDT etc via the new AjCompiler.