Bug 148537 - ClassCastException on private nested annotation with @Retention meta-annotation given an array-type value
Summary: ClassCastException on private nested annotation with @Retention meta-annotati...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.1   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: 1.5.3   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-24 13:30 EDT by Matt Whitlock CLA
Modified: 2006-07-05 05:41 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Whitlock CLA 2006-06-24 13:30:16 EDT
MyClass.java
============
public class MyClass {

	@Retention({RententionPolicy.RUNTIME})
	private @interface MyAnnotation {
	}
}

---

MyAspect.aj
===========
privileged public aspect MyAspect {

	declare @type : MyClass+ : @MyClass.MyAnnotation;

}

---

Internal Compiler Error:

java.lang.ClassCastException
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation.detectStandardAnnotation(Annotation.java:99)
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation.resolveType(Annotation.java:280)
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveAnnotations(ASTNode.java:436)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.getAnnotationTagBits(SourceTypeBinding.java:743)
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation.resolveType(Annotation.java:331)
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveAnnotations(ASTNode.java:436)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding.getAnnotationTagBits(MethodBinding.java:450)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor(SourceTypeBinding.java:1268)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.methods(SourceTypeBinding.java:1081)
at org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration.checkSpec(AspectDeclaration.java:131)
at org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration.buildInterTypeAndPerClause(AspectDeclaration.java:1070)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.buildInterTypeAndPerClause(AjLookupEnvironment.java:463)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.collectAllITDsAndDeclares(AjLookupEnvironment.java:332)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:173)
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:862)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:242)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:161)
at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122)
at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

ClassCastException thrown: org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer
Comment 1 Matt Whitlock CLA 2006-06-24 13:37:56 EDT
Actually, it turns out the aspect isn't even needed.

This is enough to trigger the Internal Compiler Error:

Bug.java
========
public class Bug {

	@Retention({RetentionPolicy.RUNTIME})
	public @interface MyAnnotation {
	}
}

---

I just realized that the @Retention meta-annotation isn't supposed to take an array-type value.  The problem goes away when I change it to the proper:

@Retention(RetentionPolicy.RUNTIME)

Therefore, this is a trivial bug.

It looks like the regular Java compiler also throws an Internal Compiler Error on the incorrect construct, so it's probably not specifically an AspectJ problem.
Comment 2 Andrew Clement CLA 2006-07-05 05:41:00 EDT
Fix committed. May already be fixed in the Eclipse 3.2 compiler - we should look out when we move to it.