Bug 255555 - EclipseSourceType.addAnnotation Not implemented and throws compiler error
Summary: EclipseSourceType.addAnnotation Not implemented and throws compiler error
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P4 normal (vote)
Target Milestone: 1.6.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 260378 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-17 14:11 EST by Andrew Eisenberg CLA
Modified: 2010-03-15 17:07 EDT (History)
2 users (show)

See Also:


Attachments
project that exhibits this error (7.38 KB, application/octet-stream)
2008-11-17 14:12 EST, Andrew Eisenberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2008-11-17 14:11:49 EST
I am getting the following error when trying to compile a project (attachment to follow):

Compile error: RuntimeException thrown: EclipseSourceType.addAnnotation() not implemented

Indeed, when I look at the EclipseSourceType.addAnnotation method, I see:

<snip>
	public void addAnnotation(AnnotationAJ annotationX) {
		// XXX Big hole here - annotationX holds a BCEL annotation but
		// we need an Eclipse one here, we haven't written the conversion utils
		// yet. Not sure if this method will be called in practice...
		throw new RuntimeException("EclipseSourceType.addAnnotation() not implemented");
	}
</snip>


FWIW, here is the stack trace:

java.lang.RuntimeException: EclipseSourceType.addAnnotation() not implemented
at org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType.addAnnotation(EclipseSourceType.java:469)
at org.aspectj.weaver.ReferenceType.addAnnotation(ReferenceType.java:136)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.doDeclareAnnotations(AjLookupEnvironment.java:1042)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.weaveInterTypeDeclarations(AjLookupEnvironment.java:701)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.weaveInterTypeDeclarations(AjLookupEnvironment.java:613)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.doPendingWeaves(AjLookupEnvironment.java:438)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:211)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:616)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:357)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:371)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:975)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:301)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:183)
at org.aspectj.ajde.core.internal.AjdeCoreBuildManager.performBuild(AjdeCoreBuildManager.java:126)
at org.aspectj.ajde.core.AjCompiler.build(AjCompiler.java:88)
at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:228)
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 1 Andrew Eisenberg CLA 2008-11-17 14:12:35 EST
Created attachment 118083 [details]
project that exhibits this error
Comment 2 Andrew Eisenberg CLA 2008-11-17 14:30:30 EST
Should have looked into this more before I posted.

Seems that doing a clean build will solve the problem.
Comment 3 Andrew Eisenberg CLA 2008-11-17 15:04:30 EST
OK...I found another error, that is reproducible. Paste this into the MyAspect.aj file:

	declare @field: (int Demo.x): @Deprecated;
	declare @method: (void Demo.foo(..): @Deprecated;
	declare @constructor: (public Demo.new(int)): @Deprecated;

I think it is a similar problem as above, but is occurring on methods fields and constructors, not types.

The following compiler error occurs:


java.lang.NullPointerException
at org.aspectj.ajdt.internal.compiler.lookup.EclipseResolvedMember.getEclipseAnnotations(EclipseResolvedMember.java:215)
at org.aspectj.ajdt.internal.compiler.lookup.EclipseResolvedMember.getAnnotations(EclipseResolvedMember.java:91)
at org.aspectj.weaver.patterns.DeclareAnnotation.ensureAnnotationDiscovered(DeclareAnnotation.java:317)
at org.aspectj.weaver.patterns.DeclareAnnotation.getAnnotationX(DeclareAnnotation.java:302)
at org.aspectj.weaver.bcel.BcelWeaver.applyDeclareAtType(BcelWeaver.java:1586)
at org.aspectj.weaver.bcel.BcelWeaver.weaveParentTypeMungers(BcelWeaver.java:1549)
at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:1401)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1210)
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:975)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:265)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:179)
at org.aspectj.ajde.core.internal.AjdeCoreBuildManager.performBuild(AjdeCoreBuildManager.java:104)
at org.aspectj.ajde.core.AjCompiler.buildFresh(AjCompiler.java:97)
at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:226)
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 4 Andrew Clement CLA 2008-11-28 19:09:33 EST
Looks like two entirely different things to fix - even though you might be doing the same kind of thing with annotations.  The first is clearly an incremental compilation issue - can you recreate it now?  Which file do you change and save in order to trigger the problem?


I have recreated the second problem as per comment 3 and will look into that.

the test programs could be a bit simpler...
Comment 5 Andrew Clement CLA 2008-11-28 19:39:47 EST
A simpler MyAspect that shows the same problem is:

package test;
import java.util.List;

public privileged aspect MyAspect {
        void Demo.foo(java.util.List<String> x) { }
        declare @method: (void Demo.foo(..): @Deprecated;
        declare @type: Demo: @Deprecated;
}

the problem with the added lines specified in comment 3 is that they are not valid syntax.  the declare @field and @constructor lines specify parenthese around the field pattern and constructor pattern respectively - which is not supported.  And the declare @method attempts the same but is missing a parentheses to balance it out anyway.  So the first problem here is just our old friend 'weaving broken code' - this is another situation where there are problems.

The second problem is that we should probably tolerate parentheses in these situations.

So really the stack trace for which this was raised (the incremental build problem) is more serious as it relates to incrementally compiling valid code whilst the second stack trace is related to coping with broken code correctly.
Comment 6 Andrew Clement CLA 2008-11-29 15:46:58 EST
fix for stack trace in comment 3 is committed.  we cope with weaving code broken involving declare anno.  we also now support parentheses around the signature patterns for @field, @method, @constructor.

Can't close this until original issue addressed though.
Comment 7 Andrew Clement CLA 2009-01-20 17:44:38 EST
this method:

java.lang.RuntimeException: EclipseSourceType.addAnnotation() not implemented

no longer exists so the problem occurring in the first comment on this bug can't happen.  That code was removed with the promotion of annotation storage to the ReferenceType level (bug 258510).  It may yet fail in a different way, but it can't fail in this way :)
Comment 8 Andrew Clement CLA 2010-03-15 17:07:56 EDT
*** Bug 260378 has been marked as a duplicate of this bug. ***