Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314965 - misleading error: Cannot use annotationvalues with a wild annotation pattern
Summary: misleading error: Cannot use annotationvalues with a wild annotation pattern
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.7   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: 1.6.9   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-28 19:23 EDT by max.kramer CLA
Modified: 2010-05-31 13:39 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.