Bug 171069 - java.util.EmptyStackException in CompilationAndWeavingContext using LTW
Summary: java.util.EmptyStackException in CompilationAndWeavingContext using LTW
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: 1.5.3RC1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-19 11:27 EST by Matthew Webster CLA
Modified: 2007-01-22 10:12 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Webster CLA 2007-01-19 11:27:04 EST
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))
	...
Comment 1 Matthew Webster CLA 2007-01-22 10:12:48 EST
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.