Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 51099 Details for
Bug 149751
Enum-valued annotation element handles non-enum constant badly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated regression tests
patch_149751_tests.txt (text/plain), 8.23 KB, created by
Olivier Thomann
on 2006-09-28 12:05:08 EDT
(
hide
)
Description:
Updated regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-09-28 12:05:08 EDT
Size:
8.23 KB
patch
obsolete
>### 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.152.2.1 >diff -u -r1.152.2.1 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 2 Jul 2006 10:15:21 -0000 1.152.2.1 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 28 Sep 2006 16:08:08 -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[] { 212, 213 }; > // TESTS_RANGE = new int[] { 169, 180 }; > } > >@@ -6815,4 +6815,189 @@ > "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 a 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 a 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 a 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 a constant expression\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156891 >+public void test212() { >+ 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[] values();\n" + >+ "}\n" + >+ "enum MyEnum {\n" + >+ " ONE, TWO, THREE\n" + >+ "}\n" + >+ "public class X {\n" + >+ "\n" + >+ " private static final MyEnum[] myValues = { MyEnum.ONE, MyEnum.TWO };\n" + >+ " @MyAnnotation(values=myValues) \n" + >+ " public void dothetrick(){} \n" + >+ "\n" + >+ " public static void main(String[] args)throws Exception {\n" + >+ " MyAnnotation sluck = X.class.getMethod(\"dothetrick\", new Class[0]).getAnnotation(MyAnnotation.class);\n" + >+ " System.out.println(sluck.values().length);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 12)\n" + >+ " @MyAnnotation(values=myValues) \n" + >+ " ^^^^^^^^\n" + >+ "The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156891 >+public void test213() { >+ 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 int[] values();\n" + >+ "}\n" + >+ "public class X {\n" + >+ "\n" + >+ " private static final int[] myValues = { 1, 2, 3 };\n" + >+ " @MyAnnotation(values=myValues) \n" + >+ " public void dothetrick(){} \n" + >+ "\n" + >+ " public static void main(String[] args)throws Exception {\n" + >+ " MyAnnotation sluck = X.class.getMethod(\"dothetrick\", new Class[0]).getAnnotation(MyAnnotation.class);\n" + >+ " System.out.println(sluck.values().length);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " @MyAnnotation(values=myValues) \n" + >+ " ^^^^^^^^\n" + >+ "The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + >+ "----------\n"); >+} > } >#P org.eclipse.jdt.core.tests.model
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 149751
:
45920
|
45921
|
49948
|
49974
|
49975
|
50002
|
50003
|
50036
|
51098
| 51099