Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 414384
Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR308SpecSnippetTests.java (+83 lines)
Lines 17-22 Link Here
17
 *                          Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped
17
 *                          Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped
18
 *                          Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator
18
 *                          Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator
19
 *                          Bug 415470 - [1.8][compiler] Type annotations on class declaration go vanishing
19
 *                          Bug 415470 - [1.8][compiler] Type annotations on class declaration go vanishing
20
 *                          Bug 414384 - [1.8] type annotation on abbreviated inner class is not marked as inner type
20
 *******************************************************************************/
21
 *******************************************************************************/
21
package org.eclipse.jdt.core.tests.compiler.regression;
22
package org.eclipse.jdt.core.tests.compiler.regression;
22
23
Lines 2071-2074 public class JSR308SpecSnippetTests extends AbstractRegressionTest { Link Here
2071
				"}";
2072
				"}";
2072
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
2073
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
2073
	}
2074
	}
2075
	
2076
	// Bug 414384 - [1.8] type annotation on abbreviated inner class is not marked as inner type
2077
	public void test035() throws Exception {
2078
		this.runConformTest(
2079
			new String[] {
2080
				"pkg/Clazz.java",
2081
				"package pkg;\n" +
2082
				"import java.lang.annotation.*;\n" +
2083
				"import static java.lang.annotation.ElementType.*;\n" +
2084
				"\n" +
2085
				"@Target({TYPE_USE}) @interface P { }\n" +
2086
				"@Target({TYPE_USE}) @interface O { }\n" +
2087
				"@Target({TYPE_USE}) @interface I { }\n" +
2088
				"\n" +
2089
				"public abstract class Clazz {\n" +
2090
				"  public class Inner {}\n" +
2091
				"  public abstract void n1(@I Inner i1);\n" +
2092
				"  public abstract void n2(@O Clazz.@I Inner i2);\n" +
2093
				"  public abstract void n3(pkg.@O Clazz.@I Inner i3);\n" +
2094
				"}\n",
2095
		},
2096
		"");
2097
		// javac b100 produces for the methods:
2098
		//		  public abstract void n1(pkg.Clazz$Inner);
2099
		//		    RuntimeInvisibleTypeAnnotations:
2100
		//		      0: #14(): METHOD_FORMAL_PARAMETER, param_index=0, location=[INNER_TYPE]
2101
		//
2102
		//		  public abstract void n2(pkg.Clazz$Inner);
2103
		//		    RuntimeInvisibleTypeAnnotations:
2104
		//		      0: #14(): METHOD_FORMAL_PARAMETER, param_index=0, location=[INNER_TYPE]
2105
		//		      1: #16(): METHOD_FORMAL_PARAMETER, param_index=0
2106
		//
2107
		//		  public abstract void n3(pkg.Clazz$Inner);
2108
		//		    RuntimeInvisibleTypeAnnotations:
2109
		//		      0: #14(): METHOD_FORMAL_PARAMETER, param_index=0, location=[INNER_TYPE]
2110
		//		      1: #16(): METHOD_FORMAL_PARAMETER, param_index=0
2111
		String expectedOutput =
2112
				"  // Method descriptor #15 (Lpkg/Clazz$Inner;)V\n" + 
2113
				"  public abstract void n1(pkg.Clazz.Inner arg0);\n" + 
2114
				"    RuntimeInvisibleTypeAnnotations: \n" + 
2115
				"      #17 @pkg.I(\n" + 
2116
				"        target type = 0x16 METHOD_FORMAL_PARAMETER\n" + 
2117
				"        method parameter index = 0\n" + 
2118
				"        location = [INNER_TYPE]\n" + 
2119
				"      )\n" + 
2120
				"  \n" + 
2121
				
2122
				"  // Method descriptor #15 (Lpkg/Clazz$Inner;)V\n" + 
2123
				"  public abstract void n2(pkg.Clazz.Inner arg0);\n" + 
2124
				"    RuntimeInvisibleTypeAnnotations: \n" + 
2125
				"      #19 @pkg.O(\n" + 
2126
				"        target type = 0x16 METHOD_FORMAL_PARAMETER\n" + 
2127
				"        method parameter index = 0\n" + 
2128
				"      )\n" + 
2129
				"      #17 @pkg.I(\n" + 
2130
				"        target type = 0x16 METHOD_FORMAL_PARAMETER\n" + 
2131
				"        method parameter index = 0\n" + 
2132
				"        location = [INNER_TYPE]\n" + 
2133
				"      )\n" + 
2134
				"  \n" + 
2135
				
2136
				"  // Method descriptor #15 (Lpkg/Clazz$Inner;)V\n" + 
2137
				"  public abstract void n3(pkg.Clazz.Inner arg0);\n" + 
2138
				"    RuntimeInvisibleTypeAnnotations: \n" + 
2139
				"      #19 @pkg.O(\n" + 
2140
				"        target type = 0x16 METHOD_FORMAL_PARAMETER\n" + 
2141
				"        method parameter index = 0\n" + 
2142
				"      )\n" + 
2143
				"      #17 @pkg.I(\n" + 
2144
				"        target type = 0x16 METHOD_FORMAL_PARAMETER\n" + 
2145
				"        method parameter index = 0\n" + 
2146
				"        location = [INNER_TYPE]\n" + 
2147
				"      )\n" + 
2148
				"\n" + 
2149
				"  Inner classes:\n" + 
2150
				"    [inner class info: #24 pkg/Clazz$Inner, outer class info: #1 pkg/Clazz\n" + 
2151
				"     inner name: #26 Inner, accessflags: 1 public]\n" + 
2152
				"}";
2153
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "pkg" + File.separator + "Clazz.class", "pkg.Clazz", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
2154
	}
2155
	
2156
2074
}
2157
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java (-1 / +4 lines)
Lines 21-26 Link Here
21
 *                          Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
21
 *                          Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
22
 *                          Bug 409517 - [1.8][compiler] Type annotation problems on more elaborate array references
22
 *                          Bug 409517 - [1.8][compiler] Type annotation problems on more elaborate array references
23
 *                          Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped
23
 *                          Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped
24
 *                          Bug 414384 - [1.8] type annotation on abbreviated inner class is not marked as inner type
24
 *******************************************************************************/
25
 *******************************************************************************/
25
package org.eclipse.jdt.internal.compiler.ast;
26
package org.eclipse.jdt.internal.compiler.ast;
26
27
Lines 157-162 public abstract class Annotation extends Expression { Link Here
157
					}
158
					}
158
				}
159
				}
159
				Annotation[][] annotations = typeReference.annotations;
160
				Annotation[][] annotations = typeReference.annotations;
161
				if (annotations == null) {
162
					annotations = new Annotation[][] { primaryAnnotation };
163
				}
160
				int annotationsLevels = annotations == null ? 0 : annotations.length;
164
				int annotationsLevels = annotations == null ? 0 : annotations.length;
161
				for (int i = 0; i < annotationsLevels; i++) {
165
				for (int i = 0; i < annotationsLevels; i++) {
162
					Annotation [] current = annotations[i];
166
					Annotation [] current = annotations[i];
163
- 

Return to bug 414384