Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrikanth2012-10-17 05:53:31 +0000
committerSrikanth2012-10-17 05:53:31 +0000
commit53b05c23cf839b3cc88e44aaf71a3bc8827a1b42 (patch)
tree40addabb4154d2cc53e443a9efc4a82593df8b22 /org.eclipse.jdt.core.tests.compiler
parentb0d0325dfb965a2c15932e4737e1e47a197d7d43 (diff)
downloadeclipse.jdt.core-53b05c23cf839b3cc88e44aaf71a3bc8827a1b42.tar.gz
eclipse.jdt.core-53b05c23cf839b3cc88e44aaf71a3bc8827a1b42.tar.xz
eclipse.jdt.core-53b05c23cf839b3cc88e44aaf71a3bc8827a1b42.zip
Fixed bug 392119: [1.8][compiler] Annotations with hybrid SE7 & SE8
targets don't make it to class files.
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java173
1 files changed, 172 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
index 010b5b6417..f8c0366398 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
@@ -14,6 +14,9 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
+import java.io.File;
+
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
import junit.framework.Test;
public class NegativeTypeAnnotationTest extends AbstractRegressionTest {
@@ -2901,4 +2904,172 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest {
"Type annotation is illegal for a method that returns void\n" +
"----------\n");
}
-}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=392119
+ public void test392119() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java", //-----------------------------------------------------------------------
+ "@Marker78 @Marker8 @Marker7\n" +
+ "public class X {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.TYPE})\n" +
+ "@interface Marker78 {\n" +
+ "}\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE})\n" +
+ "@interface Marker7 {\n" +
+ "}\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE_USE})\n" +
+ "@interface Marker8 {\n" +
+ "}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n" +
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true, // flush output
+ null,
+ true, // generate output
+ false,
+ false);
+ String expectedOutput =
+ " RuntimeInvisibleAnnotations: \n" +
+ " #24 @Marker78(\n" +
+ " )\n" +
+ " #25 @Marker7(\n" +
+ " )\n";
+ checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=392119, variant with explicit class file retention.
+ public void test392119b() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java", //-----------------------------------------------------------------------
+ "@Marker78 @Marker8 @Marker7\n" +
+ "public class X {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS)\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.TYPE})\n" +
+ "@interface Marker78 {\n" +
+ "}\n" +
+ "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS)\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE})\n" +
+ "@interface Marker7 {\n" +
+ "}\n" +
+ "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS)\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE_USE})\n" +
+ "@interface Marker8 {\n" +
+ "}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n" +
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true, // flush output
+ null,
+ true, // generate output
+ false,
+ false);
+ String expectedOutput =
+ " RuntimeInvisibleAnnotations: \n" +
+ " #24 @Marker78(\n" +
+ " )\n" +
+ " #25 @Marker7(\n" +
+ " )\n";
+ checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=392119, variant with explicit class file retention.
+ public void test392119c() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java", //-----------------------------------------------------------------------
+ "@Marker78 @Marker8 @Marker7\n" +
+ "public class X {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.TYPE})\n" +
+ "@interface Marker78 {\n" +
+ "}\n" +
+ "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE})\n" +
+ "@interface Marker7 {\n" +
+ "}\n" +
+ "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" +
+ "@java.lang.annotation.Target ({java.lang.annotation.ElementType.TYPE_USE})\n" +
+ "@interface Marker8 {\n" +
+ "}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n" +
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true, // flush output
+ null,
+ true, // generate output
+ false,
+ false);
+ String expectedOutput =
+ " RuntimeVisibleAnnotations: \n" +
+ " #24 @Marker78(\n" +
+ " )\n" +
+ " #25 @Marker7(\n" +
+ " )\n";
+ checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
+ }
+} \ No newline at end of file

Back to the top