diff options
| author | Andrew Clement | 2013-08-23 05:25:20 +0000 |
|---|---|---|
| committer | ssankaran | 2013-08-23 05:25:20 +0000 |
| commit | 8499ee1311c075235e045f23469dcc5f2d30119d (patch) | |
| tree | 7f4b420029d17654f0943d1cdddc55247f7415d7 | |
| parent | e002812d8385bfcab83bbcee92fbb80489aadeb5 (diff) | |
| download | eclipse.jdt.core-8499ee1311c075235e045f23469dcc5f2d30119d.tar.gz eclipse.jdt.core-8499ee1311c075235e045f23469dcc5f2d30119d.tar.xz eclipse.jdt.core-8499ee1311c075235e045f23469dcc5f2d30119d.zip | |
Fixed Bug 414384 - [1.8] type annotation on abbreviated inner class is
not marked as inner type
Signed-off-by: Andrew Clement <aclement@gopivotal.com>
2 files changed, 86 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR308SpecSnippetTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR308SpecSnippetTests.java index dce6dc12e1..c8ae17c193 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR308SpecSnippetTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR308SpecSnippetTests.java @@ -17,6 +17,7 @@ * Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped * Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator * Bug 415470 - [1.8][compiler] Type annotations on class declaration go vanishing + * Bug 414384 - [1.8] type annotation on abbreviated inner class is not marked as inner type *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -2389,4 +2390,84 @@ public class JSR308SpecSnippetTests extends AbstractRegressionTest { " \n"; checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); } + + // Bug 414384 - [1.8] type annotation on abbreviated inner class is not marked as inner type + public void test043() throws Exception { + this.runConformTest( + new String[] { + "pkg/Clazz.java", + "package pkg;\n" + + "import java.lang.annotation.*;\n" + + "import static java.lang.annotation.ElementType.*;\n" + + "\n" + + "@Target({TYPE_USE}) @interface P { }\n" + + "@Target({TYPE_USE}) @interface O { }\n" + + "@Target({TYPE_USE}) @interface I { }\n" + + "\n" + + "public abstract class Clazz {\n" + + " public class Inner {}\n" + + " public abstract void n1(@I Inner i1);\n" + + " public abstract void n2(@O Clazz.@I Inner i2);\n" + + " public abstract void n3(pkg.@O Clazz.@I Inner i3);\n" + + "}\n", + }, + ""); + // javac b100 produces for the methods: + // public abstract void n1(pkg.Clazz$Inner); + // RuntimeInvisibleTypeAnnotations: + // 0: #14(): METHOD_FORMAL_PARAMETER, param_index=0, location=[INNER_TYPE] + // + // public abstract void n2(pkg.Clazz$Inner); + // RuntimeInvisibleTypeAnnotations: + // 0: #14(): METHOD_FORMAL_PARAMETER, param_index=0, location=[INNER_TYPE] + // 1: #16(): METHOD_FORMAL_PARAMETER, param_index=0 + // + // public abstract void n3(pkg.Clazz$Inner); + // RuntimeInvisibleTypeAnnotations: + // 0: #14(): METHOD_FORMAL_PARAMETER, param_index=0, location=[INNER_TYPE] + // 1: #16(): METHOD_FORMAL_PARAMETER, param_index=0 + String expectedOutput = + " // Method descriptor #15 (Lpkg/Clazz$Inner;)V\n" + + " public abstract void n1(pkg.Clazz.Inner arg0);\n" + + " RuntimeInvisibleTypeAnnotations: \n" + + " #17 @pkg.I(\n" + + " target type = 0x16 METHOD_FORMAL_PARAMETER\n" + + " method parameter index = 0\n" + + " location = [INNER_TYPE]\n" + + " )\n" + + " \n" + + + " // Method descriptor #15 (Lpkg/Clazz$Inner;)V\n" + + " public abstract void n2(pkg.Clazz.Inner arg0);\n" + + " RuntimeInvisibleTypeAnnotations: \n" + + " #19 @pkg.O(\n" + + " target type = 0x16 METHOD_FORMAL_PARAMETER\n" + + " method parameter index = 0\n" + + " )\n" + + " #17 @pkg.I(\n" + + " target type = 0x16 METHOD_FORMAL_PARAMETER\n" + + " method parameter index = 0\n" + + " location = [INNER_TYPE]\n" + + " )\n" + + " \n" + + + " // Method descriptor #15 (Lpkg/Clazz$Inner;)V\n" + + " public abstract void n3(pkg.Clazz.Inner arg0);\n" + + " RuntimeInvisibleTypeAnnotations: \n" + + " #19 @pkg.O(\n" + + " target type = 0x16 METHOD_FORMAL_PARAMETER\n" + + " method parameter index = 0\n" + + " )\n" + + " #17 @pkg.I(\n" + + " target type = 0x16 METHOD_FORMAL_PARAMETER\n" + + " method parameter index = 0\n" + + " location = [INNER_TYPE]\n" + + " )\n" + + "\n" + + " Inner classes:\n" + + " [inner class info: #24 pkg/Clazz$Inner, outer class info: #1 pkg/Clazz\n" + + " inner name: #26 Inner, accessflags: 1 public]\n" + + "}"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "pkg" + File.separator + "Clazz.class", "pkg.Clazz", expectedOutput, ClassFileBytesDisassembler.SYSTEM); + } }
\ No newline at end of file diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java index 097d966c74..fcf34c5c26 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java @@ -21,6 +21,7 @@ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) * Bug 409517 - [1.8][compiler] Type annotation problems on more elaborate array references * Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped + * Bug 414384 - [1.8] type annotation on abbreviated inner class is not marked as inner type *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -157,7 +158,10 @@ public abstract class Annotation extends Expression { } } Annotation[][] annotations = typeReference.annotations; - int annotationsLevels = annotations == null ? 0 : annotations.length; + if (annotations == null) { + annotations = new Annotation[][] { primaryAnnotation }; + } + int annotationsLevels = annotations.length; for (int i = 0; i < annotationsLevels; i++) { Annotation [] current = annotations[i]; int annotationsLength = current == null ? 0 : current.length; |
