Bug 533488 - [9] @Deprecated may cause AIOOBE
Follow-up:
- integrate new test into the regression suite
- move existing related tests to the new test class
- remove bogus/redundant compliance checks
- avoid rawtypes rather than suppressing the warning
Change-Id: I641165fa68548e5b7f06f999ba87fdd8d57d3cb1
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 40190d2..d5a27a8e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -11866,69 +11866,4 @@
assertEquals(1, requestor.problemArguments.length);
assertEquals(JavaCore.COMPILER_PB_UNUSED_PARAMETER, requestor.problemArguments[0]);
}
-public void testBug521054a() throws Exception {
- if (this.complianceLevel <= ClassFileConstants.JDK1_8) {
- return;
- }
- this.runNegativeTest(
- new String[] {
- "X.java",
- "public @interface X {\n" +
- " String value(X this);\n" +
- "}\n",
- },
- "----------\n" +
- "1. ERROR in X.java (at line 2)\n" +
- " String value(X this);\n" +
- " ^^^^^^^^^^^^^\n" +
- "Annotation attributes cannot have parameters\n" +
- "----------\n",
- null, true);
-}
-public void testBug521054b() throws Exception {
- if (this.complianceLevel <= ClassFileConstants.JDK1_8) {
- return;
- }
- this.runNegativeTest(
- new String[] {
- "X.java",
- "@java.lang.annotation.Repeatable(Container.class)\n" +
- "public @interface X {\n" +
- " String value();\n" +
- "}\n" +
- "@interface Container {\n" +
- " X[] value(Container this);\n" +
- "}\n",
- },
- "----------\n" +
- "1. ERROR in X.java (at line 6)\n" +
- " X[] value(Container this);\n" +
- " ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Annotation attributes cannot have parameters\n" +
- "----------\n",
- null, true);
-}
-public void testBug521054c() throws Exception {
- if (this.complianceLevel <= ClassFileConstants.JDK1_8) {
- return;
- }
- this.runNegativeTest(
- new String[] {
- "X.java",
- "@java.lang.annotation.Repeatable(Container.class)\n" +
- "public @interface X {\n" +
- " String value(X this, int i);\n" +
- "}\n" +
- "@interface Container {\n" +
- " X[] value();\n" +
- "}\n",
- },
- "----------\n" +
- "1. ERROR in X.java (at line 3)\n" +
- " String value(X this, int i);\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "Annotation attributes cannot have parameters\n" +
- "----------\n",
- null, true);
-}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java
index 27dbb97..a2aff19 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java
@@ -8,11 +8,9 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import junit.framework.Test;
-@SuppressWarnings({ "rawtypes" })
public class AnnotationTest_9 extends AbstractComparableTest {
public AnnotationTest_9(String name) {
@@ -23,16 +21,11 @@
return buildMinimalComplianceTestSuite(testClass(), F_9);
}
- public static Class testClass() {
+ public static Class<?> testClass() {
return AnnotationTest_9.class;
}
public void testBug532913() throws Exception {
- this.complianceLevel = ClassFileConstants.JDK9;
- if (this.complianceLevel < ClassFileConstants.JDK9) {
- return;
- }
-
runConformTest(
new String[] {
"p/A.java",
@@ -51,4 +44,60 @@
"}\n",
},"", null, false, null);
}
+ public void testBug521054a() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public @interface X {\n" +
+ " String value(X this);\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " String value(X this);\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Annotation attributes cannot have parameters\n" +
+ "----------\n",
+ null, true);
+ }
+ public void testBug521054b() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "@java.lang.annotation.Repeatable(Container.class)\n" +
+ "public @interface X {\n" +
+ " String value();\n" +
+ "}\n" +
+ "@interface Container {\n" +
+ " X[] value(Container this);\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " X[] value(Container this);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Annotation attributes cannot have parameters\n" +
+ "----------\n",
+ null, true);
+ }
+ public void testBug521054c() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "@java.lang.annotation.Repeatable(Container.class)\n" +
+ "public @interface X {\n" +
+ " String value(X this, int i);\n" +
+ "}\n" +
+ "@interface Container {\n" +
+ " X[] value();\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " String value(X this, int i);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "Annotation attributes cannot have parameters\n" +
+ "----------\n",
+ null, true);
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index fd2f95e..b7d17f5 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -163,6 +163,7 @@
since_9.add(AutomaticModuleNamingTest.class);
since_9.add(UnnamedModuleTest.class);
since_9.add(NullAnnotationTests9.class);
+ since_9.add(AnnotationTest_9.class);
// add 10 specific test here (check duplicates)
ArrayList since_10 = new ArrayList();