Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayaprakash Arthanareeswaran2012-11-15 09:12:14 +0000
committerJayaprakash Arthanareeswaran2012-11-15 09:12:14 +0000
commita8ed5c9ce2b125913ea11ffa5f66b79c1153133a (patch)
treeffa0d72a4210e457ab6f0dd3b4221927ae8b982c
parentf47e26d3fcd26c7ac5e8da41bad4a70017e1dc8c (diff)
downloadeclipse.jdt.core-a8ed5c9ce2b125913ea11ffa5f66b79c1153133a.tar.gz
eclipse.jdt.core-a8ed5c9ce2b125913ea11ffa5f66b79c1153133a.tar.xz
eclipse.jdt.core-a8ed5c9ce2b125913ea11ffa5f66b79c1153133a.zip
Fix for bug 394355 - [1.8][compiler] Declaration annotations should be
rejected on receiver parameter (test only)
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java44
1 files changed, 44 insertions, 0 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 f8c0366398..c64f111243 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
@@ -3072,4 +3072,48 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest {
" )\n";
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=394355
+ public void testBug394355() {
+ this.runNegativeTest(
+ new String[]{
+ "X.java",
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "public class X {\n" +
+ " public void foo(@Marker @Marker2 X this) {}\n" +
+ " class Y {\n" +
+ " Y(@Marker @Marker2 X X.this) {}\n" +
+ " }\n" +
+ "}\n" +
+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ "@interface Marker {}\n" +
+ "@Target ({METHOD, PARAMETER, TYPE, PACKAGE, FIELD, CONSTRUCTOR, LOCAL_VARIABLE, TYPE_PARAMETER})\n" +
+ "@interface Marker2 {}",
+ "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 4)\n" +
+ " public void foo(@Marker @Marker2 X this) {}\n" +
+ " ^^^^^^^^\n" +
+ "The annotation @Marker2 is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " Y(@Marker @Marker2 X X.this) {}\n" +
+ " ^^^^^^^^\n" +
+ "The annotation @Marker2 is disallowed for this location\n" +
+ "----------\n");
+ }
} \ No newline at end of file

Back to the top