Bug 128655

Summary: [annotations]Compiler crashes (possibly due to declare @type)
Product: [Tools] AspectJ Reporter: Ramnivas Laddad <ramnivas>
Component: CompilerAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: DEVELOPMENT   
Target Milestone: 1.5.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ramnivas Laddad CLA 2006-02-20 09:53:35 EST
AJDT version: 1.3.1 (20060214104738)
AspectJ version: 1.5.1.20060131132251

Not very sure of the reason and couldn't reproduce on a smaller code base.

The compiler crashes on incremental compilation, but never when I do full "clean" build. Here is the stack trace:
java.lang.NullPointerException
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding.getAnnotationTagBits(MethodBinding.java:447)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.doDeclareAnnotations(AjLookupEnvironment.java:754)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.weaveInterTypeDeclarations(AjLookupEnvironment.java:571)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.weaveInterTypeDeclarations(AjLookupEnvironment.java:498)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.doPendingWeaves(AjLookupEnvironment.java:365)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:179)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:301)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:315)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:824)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:258)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:164)
at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117)
at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

NullPointerException thrown: null
Comment 1 Andrew Clement CLA 2006-02-20 10:14:40 EST
Line 769 in the latest version of AjLookupEnvironment I think.

Can I ask which file you are incrementally compiling ramnivas?  I assume it is not the file containing the declare - but is it a file affected by the declare or not?
Comment 2 Andrew Clement CLA 2006-02-20 10:20:00 EST
nevermind, recreated.
Comment 3 Andrew Clement CLA 2006-02-21 05:55:57 EST
Sometimes I amaze even myself.  I went home yesterday wondering if we could ever fix this (i.e. do the right thing - stopping the NPE is of course straightforward).  This morning I've fixed it.  The problem is to do with retrieving the annotation for the declare @type.  We NPE because we try and retrieve it off a binary type binding and eclipse binary type bindings dont know about annotations.  We have a binary type binding because it is an incremental compile so the 'supporting' types required by the one source file we are building come in as binary type bindings rather than as source type bindings.  What we have to do is access the annotations on the binary type binding through bcel, then construct a minimal eclipse annotation containing the type of the annotation and stick it onto the matched type.

I've put a few comments in the code about other bugs lurking but this was so serious I wanted to get the fix for the original discovered problem out asap.
Comment 4 Andrew Clement CLA 2006-02-21 07:05:01 EST
fix available.