### Eclipse Workspace Patch 1.0 #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.153 diff -u -r1.153 AnnotationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 8 Jun 2006 13:07:58 -0000 1.153 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 7 Jul 2006 14:35:05 -0000 @@ -39,7 +39,7 @@ // All specified tests which do not belong to the class are skipped... static { // TESTS_NAMES = new String[] { "test127" }; -// TESTS_NUMBERS = new int[] { 196 }; +// TESTS_NUMBERS = new int[] { 210, 211 }; // TESTS_RANGE = new int[] { 169, 180 }; } @@ -521,12 +521,12 @@ "1. ERROR in X.java (at line 2)\n" + " int value() default X.val();\n" + " ^^^^^^^\n" + - "The value for annotation attribute Foo.value must be a constant expression\n" + + "The value for annotation attribute Foo.value must be an enum constant expression\n" + "----------\n" + "2. ERROR in X.java (at line 6)\n" + " @Foo( val() )\n" + " ^^^^^\n" + - "The value for annotation attribute Foo.value must be a constant expression\n" + + "The value for annotation attribute Foo.value must be an enum constant expression\n" + "----------\n"); } // check String annotation member value must be a constant @@ -548,12 +548,12 @@ "1. ERROR in X.java (at line 2)\n" + " String value() default X.val();\n" + " ^^^^^^^\n" + - "The value for annotation attribute Foo.value must be a constant expression\n" + + "The value for annotation attribute Foo.value must be an enum constant expression\n" + "----------\n" + "2. ERROR in X.java (at line 6)\n" + " @Foo( val() )\n" + " ^^^^^\n" + - "The value for annotation attribute Foo.value must be a constant expression\n" + + "The value for annotation attribute Foo.value must be an enum constant expression\n" + "----------\n"); } @@ -575,12 +575,12 @@ "1. ERROR in X.java (at line 2)\n" + " String[] value() default null;\n" + " ^^^^\n" + - "The value for annotation attribute Foo.value must be a constant expression\n" + + "The value for annotation attribute Foo.value must be an enum constant expression\n" + "----------\n" + "2. ERROR in X.java (at line 6)\n" + " @Foo( null )\n" + " ^^^^\n" + - "The value for annotation attribute Foo.value must be a constant expression\n" + + "The value for annotation attribute Foo.value must be an enum constant expression\n" + "----------\n"); } @@ -1122,7 +1122,7 @@ "1. ERROR in X.java (at line 10)\n" + " @I(val = bar()) void foo() {\n" + " ^^^^^\n" + - "The value for annotation attribute I.val must be a constant expression\n" + + "The value for annotation attribute I.val must be an enum constant expression\n" + "----------\n"); } @@ -1198,7 +1198,7 @@ "1. ERROR in X.java (at line 6)\n" + " @I(value={false, X.class != null }) void foo() {\n" + " ^^^^^^^^^^^^^^^\n" + - "The value for annotation attribute I.value must be a constant expression\n" + + "The value for annotation attribute I.value must be an enum constant expression\n" + "----------\n"); } @@ -2116,12 +2116,12 @@ "4. ERROR in X.java (at line 8)\n" + " @I(ids = {{1 , 2}, { 3 }}) public void foo(){\n" + " ^^^^^^^\n" + - "The value for annotation attribute I.ids must be a constant expression\n" + + "The value for annotation attribute I.ids must be an enum constant expression\n" + "----------\n" + "5. ERROR in X.java (at line 8)\n" + " @I(ids = {{1 , 2}, { 3 }}) public void foo(){\n" + " ^^^^^\n" + - "The value for annotation attribute I.ids must be a constant expression\n" + + "The value for annotation attribute I.ids must be an enum constant expression\n" + "----------\n"); } @@ -3320,7 +3320,7 @@ "1. ERROR in X.java (at line 2)\n" + " int[] bar() default null;\n" + " ^^^^\n" + - "The value for annotation attribute X.bar must be a constant expression\n" + + "The value for annotation attribute X.bar must be an enum constant expression\n" + "----------\n"); } @@ -3338,7 +3338,7 @@ "1. ERROR in X.java (at line 4)\n" + " @Ann(bar=null) class X {}\n" + " ^^^^\n" + - "The value for annotation attribute Ann.bar must be a constant expression\n" + + "The value for annotation attribute Ann.bar must be an enum constant expression\n" + "----------\n"); } @@ -3574,7 +3574,7 @@ "1. ERROR in X.java (at line 4)\n" + " @Annot( foo = new String(){} )\n" + " ^^^^^^^^^^^^^^\n" + - "The value for annotation attribute Annot.foo must be a constant expression\n" + + "The value for annotation attribute Annot.foo must be an enum constant expression\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " @Annot( foo = new String(){} )\n" + @@ -4876,7 +4876,7 @@ "1. ERROR in X.java (at line 6)\n" + " @Annot(foo = kkk)\n" + " ^^^\n" + - "The value for annotation attribute Annot.foo must be a constant expression\n" + + "The value for annotation attribute Annot.foo must be an enum constant expression\n" + "----------\n" + "2. ERROR in X.java (at line 10)\n" + " @Annot(foo = fff)\n" + @@ -6482,7 +6482,7 @@ "1. ERROR in X.java (at line 5)\n" + " public MyEnum theValue() default null;\n" + " ^^^^\n" + - "The value for annotation attribute X.theValue must be a constant expression\n" + + "The value for annotation attribute X.theValue must be an enum constant expression\n" + "----------\n"); } // no override between package private methods @@ -6815,4 +6815,128 @@ "NonExisting cannot be resolved to a type\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=149751 +public void test208() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.lang.annotation.Retention;\n" + + "import static java.lang.annotation.RetentionPolicy.RUNTIME;\n" + + "@Retention(RUNTIME) @interface MyAnnotation {\n" + + " public MyEnum value();\n" + + "}\n" + + "enum MyEnum {\n" + + " ONE, TWO, THREE\n" + + "}\n" + + "@MyAnnotation(X.FOO) class MyClass {\n" + + "}\n" + + "public class X {\n" + + " public static final MyEnum FOO = MyEnum.TWO;\n" + + " public static void main(String[] args) {\n" + + " MyAnnotation annotation =\n" + + " MyClass.class.getAnnotation(MyAnnotation.class);\n" + + " System.out.println(annotation.value().toString());\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " @MyAnnotation(X.FOO) class MyClass {\n" + + " ^^^^^\n" + + "The value for annotation attribute MyAnnotation.value must be an enum constant expression\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=149751 +public void test209() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.lang.annotation.Retention;\n" + + "import static java.lang.annotation.RetentionPolicy.RUNTIME;\n" + + "@Retention(RUNTIME) @interface MyAnnotation {\n" + + " public MyEnum value();\n" + + "}\n" + + "enum MyEnum {\n" + + " ONE, TWO, THREE\n" + + "}\n" + + "@MyAnnotation(value=X.FOO) class MyClass {\n" + + "}\n" + + "public class X {\n" + + " public static final MyEnum FOO = MyEnum.TWO;\n" + + " public static void main(String[] args) {\n" + + " MyAnnotation annotation =\n" + + " MyClass.class.getAnnotation(MyAnnotation.class);\n" + + " System.out.println(annotation.value().toString());\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " @MyAnnotation(value=X.FOO) class MyClass {\n" + + " ^^^^^\n" + + "The value for annotation attribute MyAnnotation.value must be an enum constant expression\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=149751 +public void test210() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.lang.annotation.Retention;\n" + + "import static java.lang.annotation.RetentionPolicy.RUNTIME;\n" + + "@Retention(RUNTIME) @interface MyAnnotation {\n" + + " public MyEnum[] value();\n" + + "}\n" + + "enum MyEnum {\n" + + " ONE, TWO, THREE\n" + + "}\n" + + "@MyAnnotation(value= { X.FOO }) class MyClass {\n" + + "}\n" + + "public class X {\n" + + " public static final MyEnum FOO = MyEnum.TWO;\n" + + " public static void main(String[] args) {\n" + + " MyAnnotation annotation =\n" + + " MyClass.class.getAnnotation(MyAnnotation.class);\n" + + " System.out.println(annotation.value().toString());\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " @MyAnnotation(value= { X.FOO }) class MyClass {\n" + + " ^^^^^\n" + + "The value for annotation attribute MyAnnotation.value must be an enum constant expression\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=149751 +public void test211() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.lang.annotation.Retention;\n" + + "import static java.lang.annotation.RetentionPolicy.RUNTIME;\n" + + "@Retention(RUNTIME) @interface MyAnnotation {\n" + + " public MyEnum[] value();\n" + + "}\n" + + "enum MyEnum {\n" + + " ONE, TWO, THREE\n" + + "}\n" + + "@MyAnnotation(value= { null }) class MyClass {\n" + + "}\n" + + "public class X {\n" + + " public static final MyEnum FOO = MyEnum.TWO;\n" + + " public static void main(String[] args) {\n" + + " MyAnnotation annotation =\n" + + " MyClass.class.getAnnotation(MyAnnotation.class);\n" + + " System.out.println(annotation.value().toString());\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " @MyAnnotation(value= { null }) class MyClass {\n" + + " ^^^^\n" + + "The value for annotation attribute MyAnnotation.value must be an enum constant expression\n" + + "----------\n"); } +} \ No newline at end of file