Bug 271704 - RTE in weaver from AJDT
Summary: RTE in weaver from AJDT
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.4   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 1.6.5   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-08 17:14 EDT by Ron Bodkin CLA
Modified: 2009-05-08 13:07 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2009-04-08 17:14:01 EDT
I get this error using the weaving JDT version of AJDT for Eclipse 3.5 M6:

java.lang.RuntimeException
at org.aspectj.weaver.bcel.LazyMethodGen.<init>(LazyMethodGen.java:221)
at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:305)
at org.aspectj.weaver.bcel.BcelObjectType.getLazyClassGen(BcelObjectType.java:524)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1728)
at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1696)
at org.aspectj.weaver.bcel.BcelWeaver.weaveA ... or.MethodMonitorUnitTest$DriverBase.logWarn(java.lang.String, java.lang.Throwable) on abstract class glassbox.monitor.MethodMonitorUnitTest$DriverBase
Comment 1 Ron Bodkin CLA 2009-04-08 17:15:22 EDT
The problem log has more detail. This code compiles properly using ant with the classic compiler - looks like the JDT weaving mode is confused by Glassbox's ITD's...

java.lang.RuntimeException: bad non-abstract method with no code: void glassbox.monitor.MethodMonitorUnitTest$DriverBase.logWarn(java.lang.String, java.lang.Throwable) on abstract class glassbox.monitor.MethodMonitorUnitTest$DriverBase
	at org.aspectj.weaver.bcel.LazyMethodGen.<init>(LazyMethodGen.java:221)
	at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:305)
	at org.aspectj.weaver.bcel.BcelObjectType.getLazyClassGen(BcelObjectType.java:524)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1728)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1696)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1458)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1272)
	at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:435)
	at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:371)
	at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:358)
	at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:98)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:652)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:392)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1001)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:266)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:180)
	at org.aspectj.ajde.core.internal.AjdeCoreBuildManager.performBuild(AjdeCoreBuildManager.java:105)
	at org.aspectj.ajde.core.AjCompiler.buildFresh(AjCompiler.java:97)
	at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:231)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:633)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 2 Ron Bodkin CLA 2009-04-08 17:16:01 EDT
This error happens with a clean build, so the JDT weaving compilation is unable to compile Glassbox...
Comment 3 Ron Bodkin CLA 2009-04-08 17:19:45 EDT
Even disabling JDT weaving mode still fails and the compilation won't work in the 1.7 dev mode AJDT.
Comment 4 Andrew Clement CLA 2009-04-08 17:37:14 EDT
Anything funny about that method Ron?

void
glassbox.monitor.MethodMonitorUnitTest$DriverBase.logWarn(java.lang.String,
java.lang.Throwable) on abstract class
glassbox.monitor.MethodMonitorUnitTest$DriverBase

is it abstract?
Comment 5 Andrew Clement CLA 2009-04-08 17:40:45 EDT
downloading the source at the moment... chug chug
Comment 6 Andrew Eisenberg CLA 2009-04-08 17:48:58 EDT
Is this working in eclipse 3.4 and AJDT 1.6?
Comment 7 Andrew Clement CLA 2009-04-13 16:57:15 EDT
I have glassbox building now - and showing the problem.  For some reason the method created to represent the ITD has no Code attribute (that is not allowed unless it is abstract or native).  I just can't recreate it with a smaller example at the moment, this is tricky
Comment 8 Andrew Clement CLA 2009-04-13 22:04:34 EDT
yuck.

The problem is that in determining whether a type already implements an ITD method, we trigger resolution of the set of 'abstract methods' that the type inherits.  Because a declare parents has already added the Logger interface to the hierarchy it sees all the methods on that interface as abstract methods and produces empty code entries for them.  I thought I could address this by modifying it to use the 'declared supertypes' rather than the 'actual supertypes' since whenever a type is affected by a declare parents we take a snapshot of its hierarchy as declared.  However, this only works when we have a SourceTypeBinding for the type in question - and not for binary types in the supertype hierarchy. hmmm.  
Comment 9 Andrew Clement CLA 2009-04-17 18:37:12 EDT
this is a brain bender, but I have something that seems to work - just need to convert it from a hack to a real solution.
Comment 10 Andrew Clement CLA 2009-04-18 16:01:01 EDT
fixed.  nice simple fix in the end it seems

JDT was assuming (rightly for Java) that all interface methods are abstract.  In the AspectJ case they may not be abstract in the case of an intertype declaration onto an interface.  So instead of just checking if abstract class X provides an implementation of some interface method it extends, we also check if in fact that interface method is not abstract - and if it isn't we don't mind whether this class implements it or not.

This check causes the problematic methods not to be generated in the target type with empty bodies and so the 'assertion' here:

java.lang.RuntimeException
at org.aspectj.weaver.bcel.LazyMethodGen.<init>(LazyMethodGen.java:221)
at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:305)

doesn't fail.

I'm not really sure why more people haven't hit this but it does have to be a certain combination of types and itds amongst them that trigger the code that looks for unimplemented abstract methods.  The combination here was an interface with an itd upon it and then that interface is declare parents'd onto another type which is an abstract class and then the abstract class is extended.  But my attempts to recreate a similar failing scenario have failed.  We should keep glassbox around as a test project.
Comment 11 Ron Bodkin CLA 2009-05-08 00:28:43 EDT
I'd love to test this out. But it looks like the latest development AJDT is still back at AspectJ 1.6.4.20090227125800, so I can't. Is there any way to get it patched into AJDT to try it? I have to go back to Eclipse 3.3 and an old AJDT release to have tools support and would love to roll forward :-)
Comment 12 Andrew Eisenberg CLA 2009-05-08 00:52:46 EDT
Hi Ron,

What update site are you using?  I see 1.6.5.20090507194818 from:

http://download.eclipse.org/tools/ajdt/34/dev/update
Comment 13 Ron Bodkin CLA 2009-05-08 13:07:25 EDT
My mistake I was using http://download.eclipse.org/tools/ajdt/34/update - I thought I had /dev.

And hooray it is working now. I'm eager to try out the new JDT weaving approach to AJDT!!