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 415399
Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR308SpecSnippetTests.java (-3 / +14 lines)
Lines 15-20 Link Here
15
 *                          Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped
15
 *                          Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped
16
 *                          Bug 415543 - [1.8][compiler] Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute
16
 *                          Bug 415543 - [1.8][compiler] Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute
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
 *******************************************************************************/
19
 *******************************************************************************/
19
package org.eclipse.jdt.core.tests.compiler.regression;
20
package org.eclipse.jdt.core.tests.compiler.regression;
20
21
Lines 662-668 public class JSR308SpecSnippetTests extends AbstractRegressionTest { Link Here
662
				"      )\n";
663
				"      )\n";
663
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
664
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
664
	}
665
	}
665
	public void test013() throws Exception { // WILL FAIL WHEN https://bugs.eclipse.org/bugs/show_bug.cgi?id=415399 IS FIXED.
666
	public void test013() throws Exception {
666
		this.runConformTest(
667
		this.runConformTest(
667
			new String[] {
668
			new String[] {
668
				"X.java",
669
				"X.java",
Lines 677-683 public class JSR308SpecSnippetTests extends AbstractRegressionTest { Link Here
677
				"}\n",
678
				"}\n",
678
		},
679
		},
679
		"");
680
		"");
681
		// javac b100 gives:
682
		//		RuntimeInvisibleTypeAnnotations:
683
		//		      0: #9(): METHOD_RETURN
680
		String expectedOutput =
684
		String expectedOutput =
685
				"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + 
681
				"class X {\n" + 
686
				"class X {\n" + 
682
				"  Constant pool:\n" + 
687
				"  Constant pool:\n" + 
683
				"    constant #1 class: #2 X\n" + 
688
				"    constant #1 class: #2 X\n" + 
Lines 693-700 public class JSR308SpecSnippetTests extends AbstractRegressionTest { Link Here
693
				"    constant #11 utf8: \"LocalVariableTable\"\n" + 
698
				"    constant #11 utf8: \"LocalVariableTable\"\n" + 
694
				"    constant #12 utf8: \"this\"\n" + 
699
				"    constant #12 utf8: \"this\"\n" + 
695
				"    constant #13 utf8: \"LX;\"\n" + 
700
				"    constant #13 utf8: \"LX;\"\n" + 
696
				"    constant #14 utf8: \"SourceFile\"\n" + 
701
				"    constant #14 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + 
697
				"    constant #15 utf8: \"X.java\"\n" + 
702
				"    constant #15 utf8: \"LImmutable;\"\n" + 
703
				"    constant #16 utf8: \"SourceFile\"\n" + 
704
				"    constant #17 utf8: \"X.java\"\n" + 
698
				"  \n" + 
705
				"  \n" + 
699
				"  // Method descriptor #6 ()V\n" + 
706
				"  // Method descriptor #6 ()V\n" + 
700
				"  // Stack: 1, Locals: 1\n" + 
707
				"  // Stack: 1, Locals: 1\n" + 
Lines 707-712 public class JSR308SpecSnippetTests extends AbstractRegressionTest { Link Here
707
				"        [pc: 4, line: 8]\n" + 
714
				"        [pc: 4, line: 8]\n" + 
708
				"      Local variable table:\n" + 
715
				"      Local variable table:\n" + 
709
				"        [pc: 0, pc: 5] local: this index: 0 type: X\n" + 
716
				"        [pc: 0, pc: 5] local: this index: 0 type: X\n" + 
717
				"    RuntimeInvisibleTypeAnnotations: \n" + 
718
				"      #15 @Immutable(\n" + 
719
				"        target type = 0x14 METHOD_RETURN\n" + 
720
				"      )\n" + 
710
				"}";
721
				"}";
711
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
722
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM);
712
	}
723
	}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-1 / +2 lines)
Lines 18-23 Link Here
18
 *                          Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator
18
 *                          Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator
19
 *                          Bug 409246 - [1.8][compiler] Type annotations on catch parameters not handled properly
19
 *                          Bug 409246 - [1.8][compiler] Type annotations on catch parameters not handled properly
20
 *                          Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped
20
 *                          Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped
21
 *                          Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator
21
 *******************************************************************************/
22
 *******************************************************************************/
22
package org.eclipse.jdt.internal.compiler;
23
package org.eclipse.jdt.internal.compiler;
23
24
Lines 2087-2093 public class ClassFile implements TypeConstants, TypeIds { Link Here
2087
					}
2088
					}
2088
				}
2089
				}
2089
				Annotation[] annotations = methodDeclaration.annotations;
2090
				Annotation[] annotations = methodDeclaration.annotations;
2090
				if (annotations != null && binding.returnType.id != T_void) {
2091
				if (annotations != null) {
2091
					methodDeclaration.getAllAnnotationContexts(AnnotationTargetTypeConstants.METHOD_RETURN, allTypeAnnotationContexts);
2092
					methodDeclaration.getAllAnnotationContexts(AnnotationTargetTypeConstants.METHOD_RETURN, allTypeAnnotationContexts);
2092
				}
2093
				}
2093
				if (!methodDeclaration.isConstructor() && !methodDeclaration.isClinit() && binding.returnType.id != T_void) {
2094
				if (!methodDeclaration.isConstructor() && !methodDeclaration.isClinit() && binding.returnType.id != T_void) {
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java (+12 lines)
Lines 18-30 Link Here
18
 *								bug 383368 - [compiler][null] syntactic null analysis for field references
18
 *								bug 383368 - [compiler][null] syntactic null analysis for field references
19
 *								bug 400421 - [compiler] Null analysis for fields does not take @com.google.inject.Inject into account
19
 *								bug 400421 - [compiler] Null analysis for fields does not take @com.google.inject.Inject into account
20
 *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis 
20
 *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis 
21
 *        Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
22
 *                          Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator
21
 *******************************************************************************/
23
 *******************************************************************************/
22
package org.eclipse.jdt.internal.compiler.ast;
24
package org.eclipse.jdt.internal.compiler.ast;
23
25
24
import java.util.ArrayList;
26
import java.util.ArrayList;
27
import java.util.List;
25
28
26
import org.eclipse.jdt.core.compiler.*;
29
import org.eclipse.jdt.core.compiler.*;
27
import org.eclipse.jdt.internal.compiler.*;
30
import org.eclipse.jdt.internal.compiler.*;
31
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
28
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
32
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
29
import org.eclipse.jdt.internal.compiler.codegen.*;
33
import org.eclipse.jdt.internal.compiler.codegen.*;
30
import org.eclipse.jdt.internal.compiler.flow.*;
34
import org.eclipse.jdt.internal.compiler.flow.*;
Lines 430-435 private void internalGenerateCode(ClassScope classScope, ClassFile classFile) { Link Here
430
	classFile.completeMethodInfo(this.binding, methodAttributeOffset, attributeNumber);
434
	classFile.completeMethodInfo(this.binding, methodAttributeOffset, attributeNumber);
431
}
435
}
432
436
437
public void getAllAnnotationContexts(int targetType, List allAnnotationContexts) {
438
	AnnotationCollector collector = new AnnotationCollector(this, targetType, allAnnotationContexts);
439
	for (int i = 0, max = this.annotations.length; i < max; i++) {
440
		Annotation annotation = this.annotations[i];
441
		annotation.traverse(collector, (BlockScope) null);
442
	}
443
}
444
433
public boolean isConstructor() {
445
public boolean isConstructor() {
434
	return true;
446
	return true;
435
}
447
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java (-1 / +10 lines)
Lines 19-24 Link Here
19
 *        Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
19
 *        Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
20
 *                          Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
20
 *                          Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
21
 *                          Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator
21
 *                          Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator
22
 *                          Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator
22
 *******************************************************************************/
23
 *******************************************************************************/
23
package org.eclipse.jdt.internal.compiler.ast;
24
package org.eclipse.jdt.internal.compiler.ast;
24
25
Lines 108-113 static class AnnotationCollector extends ASTVisitor { Link Here
108
	}
109
	}
109
110
110
	public AnnotationCollector(
111
	public AnnotationCollector(
112
			ConstructorDeclaration constructorDeclaration,
113
			int targetType,
114
			List annotationContexts) {
115
		this.annotationContexts = annotationContexts;
116
		this.targetType = targetType;
117
		this.primaryAnnotations = constructorDeclaration.annotations;
118
	}
119
120
	public AnnotationCollector(
111
			FieldDeclaration fieldDeclaration,
121
			FieldDeclaration fieldDeclaration,
112
			int targetType,
122
			int targetType,
113
			List annotationContexts) {
123
			List annotationContexts) {
114
- 

Return to bug 415399