### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java,v retrieving revision 1.36 diff -u -r1.36 MemberValuePair.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java 12 Sep 2008 13:11:54 -0000 1.36 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java 26 Jan 2009 13:09:00 -0000 @@ -192,6 +192,8 @@ } } } + } else { + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true); } break checkAnnotationMethodType; } #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v retrieving revision 1.194 diff -u -r1.194 AnnotationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 23 Jan 2009 15:05:53 -0000 1.194 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 26 Jan 2009 13:09:03 -0000 @@ -8792,4 +8792,36 @@ "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=262304 +public void test268() { + this.runNegativeTest( + new String[] { + "X.java", // ================= + "public class X {\n" + + " protected enum E {\n" + + " E1, E2\n" + + " }\n" + + " protected @interface Anno1 { E value(); }\n" + + " protected @interface Anno2 { E value(); }\n" + + " protected @interface Anno3 { E value(); }\n" + + " @Anno1(true ? E.E1 : E.E2)\n" + + " @Anno2(bar())\n" + + " @Anno3(((E.E1)))\n" + + " public void foo() {\n" + + " }\n" + + " public E bar() { return E.E1; }\n" + + "}\n", // ================= + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " @Anno1(true ? E.E1 : E.E2)\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "The value for annotation attribute X.Anno1.value must be an enum constant expression\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " @Anno2(bar())\n" + + " ^^^^^\n" + + "The value for annotation attribute X.Anno2.value must be an enum constant expression\n" + + "----------\n"); +} }