Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314965

Summary: misleading error: Cannot use annotationvalues with a wild annotation pattern
Product: [Tools] AspectJ Reporter: max.kramer
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: aclement
Version: 1.6.7   
Target Milestone: 1.6.9   
Hardware: PC   
OS: Linux   
Whiteboard:

Description max.kramer CLA 2010-05-28 19:23:14 EDT
The aspectj weaver issues the following error if I try to declare an annotation using a misspelled annotation:


java.lang.IllegalStateException
at org.aspectj.weaver.patterns.WildAnnotationTypePattern.matches(WildAnnotationTypePattern.java:206)
at org.aspectj.weaver.patterns.WildAnnotationTypePattern.matches(WildAnnotationTypePattern.java:68)
at org.aspectj.weaver.patterns.AnyWithAnnotationTypePattern.matchesExactly(TypePattern.java:567)
at org.aspectj.weaver.patterns.TypePattern.matchesStatically(TypePattern.java:133)
at org.aspectj.weaver.patterns.D ... core.internal.jobs.Worker.run(Worker.java:55)

Compile error: IllegalStateException thrown: Cannot use annotationvalues with a wild annotation pattern


I know that this is not a severe error but a proper "... cannot be resolved to a type" might help other users and as I spent some time creating a minimal example to find the error I wanted to file it as a bug.

A minimal example would be:


public aspect MinimalExample {
	declare @type : @AnnotationWithParam("arg") * : @AnnotationWithParam2("gra");
	// the following lines leads to a misleading compiler error
	declare @type : @AnnotationWithParamAndTypo("arg") * : @AnnotationWithParam2("gra");
}

@interface AnnotationWithParam {
	String value();
}

@interface AnnotationWithParam2 {
	String value();
}
Comment 1 Andrew Clement CLA 2010-05-31 13:39:17 EDT
As the type name wasn't found the WildTypePattern wasn't resolved to an exact type pattern.  This meant the check later thought annotation values had been specified for a wild type pattern.  The solution is to remember when resolution fails and use that additional information when checking about whether the annotation values are allowed.