### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java,v retrieving revision 1.60 diff -u -r1.60 ASTModelBridgeTests.java --- src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 14 Oct 2008 13:47:33 -0000 1.60 +++ src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 17 Oct 2008 14:54:17 -0000 @@ -310,6 +310,48 @@ } /* + * Ensures that the IJavaElement of an IBinding representing an annotation on an annotation type is correct. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249844 ) + */ + public void testAnnotation6() throws JavaModelException { + ASTNode node = buildAST( + "/*start*/@MyAnnot/*end*/\n" + + "public @interface X {\n" + + "}\n" + + "@interface MyAnnot {\n" + + "}" + ); + IBinding binding = ((Annotation) node).resolveAnnotationBinding(); + IJavaElement element = binding.getJavaElement(); + assertElementEquals( + "Unexpected Java element", + "@MyAnnot [in X [in [Working copy] X.java [in [in src [in P]]]]]", + element + ); + } + + /* + * Ensures that the IJavaElement of an IBinding representing an annotation on an enum type is correct. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249844 ) + */ + public void testAnnotation7() throws JavaModelException { + ASTNode node = buildAST( + "/*start*/@MyAnnot/*end*/\n" + + "public enum X {\n" + + "}\n" + + "@interface MyAnnot {\n" + + "}" + ); + IBinding binding = ((Annotation) node).resolveAnnotationBinding(); + IJavaElement element = binding.getJavaElement(); + assertElementEquals( + "Unexpected Java element", + "@MyAnnot [in X [in [Working copy] X.java [in [in src [in P]]]]]", + element + ); + } + + /* * Ensures that the IJavaElement of an IBinding representing an anonymous type is correct. */ public void testAnonymousType() throws JavaModelException { #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/AnnotationBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnnotationBinding.java,v retrieving revision 1.11 diff -u -r1.11 AnnotationBinding.java --- dom/org/eclipse/jdt/core/dom/AnnotationBinding.java 27 Jun 2008 16:03:46 -0000 1.11 +++ dom/org/eclipse/jdt/core/dom/AnnotationBinding.java 17 Oct 2008 14:54:18 -0000 @@ -112,8 +112,10 @@ parentElement = ((ICompilationUnit) cu).getPackageDeclaration(pkgName); } break; + case ASTNode.ENUM_DECLARATION: case ASTNode.TYPE_DECLARATION: - parentElement = ((TypeDeclaration) parent).resolveBinding().getJavaElement(); + case ASTNode.ANNOTATION_TYPE_DECLARATION: + parentElement = ((AbstractTypeDeclaration) parent).resolveBinding().getJavaElement(); break; case ASTNode.FIELD_DECLARATION: VariableDeclarationFragment fragment = (VariableDeclarationFragment) ((FieldDeclaration) parent).fragments().get(0);