diff options
author | ssankaran | 2013-08-13 08:27:08 +0000 |
---|---|---|
committer | ssankaran | 2013-08-13 08:27:08 +0000 |
commit | 49894ec43e425d82d6841fb37405b9e39799b63c (patch) | |
tree | 4a522f93e59bab403ba9363a07d97e2b404ed092 /org.eclipse.jdt.core.tests.compiler | |
parent | 1513eebd74ab45e8a8f50e93dd2da30af183a918 (diff) | |
download | eclipse.jdt.core-49894ec43e425d82d6841fb37405b9e39799b63c.tar.gz eclipse.jdt.core-49894ec43e425d82d6841fb37405b9e39799b63c.tar.xz eclipse.jdt.core-49894ec43e425d82d6841fb37405b9e39799b63c.zip |
Fixed Bug 409244 - [1.8][compiler] Type annotations on redundant casts
dropped.
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/TypeAnnotationTest.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java index da190f934b..6f7fe4b3ef 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java @@ -4623,5 +4623,82 @@ public class TypeAnnotationTest extends AbstractRegressionTest { " )\n"; checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=409244, [1.8][compiler] Type annotations on redundant casts dropped. + public void testAnnotatedRedundantCast() throws Exception { + this.runConformTest( + new String[] { + "X.java", + "class X {\n" + + " String s = (@NonNull String) \"Hello\";\n" + + "}\n", + + "NonNull.java", + "import java.lang.annotation.*;\n" + + "@Target(ElementType.TYPE_USE)\n" + + "@Retention(RetentionPolicy.RUNTIME)\n" + + "@interface NonNull {}\n", + }, + ""); + String expectedOutput = + " // Method descriptor #8 ()V\n" + + " // Stack: 2, Locals: 1\n" + + " X();\n" + + " 0 aload_0 [this]\n" + + " 1 invokespecial java.lang.Object() [10]\n" + + " 4 aload_0 [this]\n" + + " 5 ldc <String \"Hello\"> [12]\n" + + " 7 checkcast java.lang.String [14]\n" + + " 10 putfield X.s : java.lang.String [16]\n" + + " 13 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 1]\n" + + " [pc: 4, line: 2]\n" + + " [pc: 13, line: 1]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 14] local: this index: 0 type: X\n" + + " RuntimeVisibleTypeAnnotations: \n" + + " #23 @NonNull(\n" + + " target type = 0x47 CAST\n" + + " offset = 7\n" + + " type argument index = 0\n" + + " )\n" + + "}"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=409244, [1.8][compiler] Type annotations on redundant casts dropped. + public void testAnnotatedRedundantCast2() throws Exception { + this.runConformTest( + new String[] { + "X.java", + "class X {\n" + + " String s = (String) \"Hello\";\n" + + "}\n", + + "NonNull.java", + "import java.lang.annotation.*;\n" + + "@Target(ElementType.TYPE_USE)\n" + + "@Retention(RetentionPolicy.RUNTIME)\n" + + "@interface NonNull {}\n", + }, + ""); + String expectedOutput = + " // Method descriptor #8 ()V\n" + + " // Stack: 2, Locals: 1\n" + + " X();\n" + + " 0 aload_0 [this]\n" + + " 1 invokespecial java.lang.Object() [10]\n" + + " 4 aload_0 [this]\n" + + " 5 ldc <String \"Hello\"> [12]\n" + + " 7 putfield X.s : java.lang.String [14]\n" + + " 10 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 1]\n" + + " [pc: 4, line: 2]\n" + + " [pc: 10, line: 1]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 11] local: this index: 0 type: X\n" + + "}"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); + } } |