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 50036 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]
Regression tests for 3.2 maintenance branch
patch_149751_tests.txt (text/plain), 10.04 KB, created by
Olivier Thomann
on 2006-09-13 10:23:00 EDT
(
hide
)
Description:
Regression tests for 3.2 maintenance branch
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-09-13 10:23:00 EDT
Size:
10.04 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 13 Sep 2006 14:25:30 -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 }; > } > >@@ -6158,7 +6158,7 @@ > "1. ERROR in X.java (at line 4)\n" + > " @A1(values = new int[] { 1, 2 })\n" + > " ^^^^^^^^^^^^^^^^^^\n" + >- "The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + >+ "The value for annotation attribute A1.values must be an array initializer\n" + > "----------\n"); > } > // partial recompile - keep a binary >@@ -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 value for annotation attribute MyAnnotation.values must be an array initializer\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 value for annotation attribute MyAnnotation.values must be an array initializer\n" + >+ "----------\n"); >+} > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.200.2.1 >diff -u -r1.200.2.1 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 2 Jul 2006 10:06:41 -0000 1.200.2.1 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 13 Sep 2006 14:25:31 -0000 >@@ -6347,9 +6347,9 @@ > assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); > CompilationUnit compilationUnit = (CompilationUnit) node; > String problems = >- "The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + >- "The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + >- "The array creation is unnecessary in an annotation value; only an array initializer is allowed"; >+ "The value for annotation attribute A1.list must be an array initializer\n" + >+ "The value for annotation attribute A2.list must be an array initializer\n" + >+ "The value for annotation attribute A3.list must be an array initializer"; > assertProblemsSize(compilationUnit, 3, problems); > List imports = compilationUnit.imports(); > assertEquals("wrong size", 1, imports.size());
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