Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 234649 Details for
Bug 415399
[1.8][compiler] Type annotations on constructor results dropped by the code generator
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Test and fix
0001-Fix-Bug-415399.patch (text/plain), 8.67 KB, created by
Andrew Clement
on 2013-08-22 01:34:47 EDT
(
hide
)
Description:
Test and fix
Filename:
MIME Type:
Creator:
Andrew Clement
Created:
2013-08-22 01:34:47 EDT
Size:
8.67 KB
patch
obsolete
>From 0ec046ff81bdbdc66f8db35494a7333b8fca8902 Mon Sep 17 00:00:00 2001 >From: Andy Clement <aclement@gopivotal.com> >Date: Wed, 21 Aug 2013 22:32:32 -0700 >Subject: [PATCH] Fix Bug 415399 > >--- > .../compiler/regression/JSR308SpecSnippetTests.java | 17 ++++++++++++++--- > .../org/eclipse/jdt/internal/compiler/ClassFile.java | 3 ++- > .../internal/compiler/ast/ConstructorDeclaration.java | 12 ++++++++++++ > .../jdt/internal/compiler/ast/TypeReference.java | 10 ++++++++++ > 4 files changed, 38 insertions(+), 4 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 52292ec..441bbbe 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 >@@ -15,6 +15,7 @@ > * Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped > * Bug 415543 - [1.8][compiler] Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute > * 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 > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -662,7 +663,7 @@ public class JSR308SpecSnippetTests extends AbstractRegressionTest { > " )\n"; > checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); > } >- public void test013() throws Exception { // WILL FAIL WHEN https://bugs.eclipse.org/bugs/show_bug.cgi?id=415399 IS FIXED. >+ public void test013() throws Exception { > this.runConformTest( > new String[] { > "X.java", >@@ -677,7 +678,11 @@ public class JSR308SpecSnippetTests extends AbstractRegressionTest { > "}\n", > }, > ""); >+ // javac b100 gives: >+ // RuntimeInvisibleTypeAnnotations: >+ // 0: #9(): METHOD_RETURN > String expectedOutput = >+ "// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + > "class X {\n" + > " Constant pool:\n" + > " constant #1 class: #2 X\n" + >@@ -693,8 +698,10 @@ public class JSR308SpecSnippetTests extends AbstractRegressionTest { > " constant #11 utf8: \"LocalVariableTable\"\n" + > " constant #12 utf8: \"this\"\n" + > " constant #13 utf8: \"LX;\"\n" + >- " constant #14 utf8: \"SourceFile\"\n" + >- " constant #15 utf8: \"X.java\"\n" + >+ " constant #14 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + >+ " constant #15 utf8: \"LImmutable;\"\n" + >+ " constant #16 utf8: \"SourceFile\"\n" + >+ " constant #17 utf8: \"X.java\"\n" + > " \n" + > " // Method descriptor #6 ()V\n" + > " // Stack: 1, Locals: 1\n" + >@@ -707,6 +714,10 @@ public class JSR308SpecSnippetTests extends AbstractRegressionTest { > " [pc: 4, line: 8]\n" + > " Local variable table:\n" + > " [pc: 0, pc: 5] local: this index: 0 type: X\n" + >+ " RuntimeInvisibleTypeAnnotations: \n" + >+ " #15 @Immutable(\n" + >+ " target type = 0x14 METHOD_RETURN\n" + >+ " )\n" + > "}"; > checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java >index dca6633..e8b2c90 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java >@@ -18,6 +18,7 @@ > * Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator > * Bug 409246 - [1.8][compiler] Type annotations on catch parameters not handled properly > * Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped >+ * Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler; > >@@ -2087,7 +2088,7 @@ public class ClassFile implements TypeConstants, TypeIds { > } > } > Annotation[] annotations = methodDeclaration.annotations; >- if (annotations != null && binding.returnType.id != T_void) { >+ if (annotations != null) { > methodDeclaration.getAllAnnotationContexts(AnnotationTargetTypeConstants.METHOD_RETURN, allTypeAnnotationContexts); > } > if (!methodDeclaration.isConstructor() && !methodDeclaration.isClinit() && binding.returnType.id != T_void) { >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java >index 2f93e73..a02523c 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java >@@ -18,13 +18,17 @@ > * bug 383368 - [compiler][null] syntactic null analysis for field references > * bug 400421 - [compiler] Null analysis for fields does not take @com.google.inject.Inject into account > * Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis >+ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for >+ * Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > > import java.util.ArrayList; >+import java.util.List; > > import org.eclipse.jdt.core.compiler.*; > import org.eclipse.jdt.internal.compiler.*; >+import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.*; > import org.eclipse.jdt.internal.compiler.flow.*; >@@ -430,6 +434,14 @@ private void internalGenerateCode(ClassScope classScope, ClassFile classFile) { > classFile.completeMethodInfo(this.binding, methodAttributeOffset, attributeNumber); > } > >+public void getAllAnnotationContexts(int targetType, List allAnnotationContexts) { >+ AnnotationCollector collector = new AnnotationCollector(this, targetType, allAnnotationContexts); >+ for (int i = 0, max = this.annotations.length; i < max; i++) { >+ Annotation annotation = this.annotations[i]; >+ annotation.traverse(collector, (BlockScope) null); >+ } >+} >+ > public boolean isConstructor() { > return true; > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java >index 0c445be..3f70869 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java >@@ -19,6 +19,7 @@ > * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for > * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) > * Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator >+ * Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -108,6 +109,15 @@ static class AnnotationCollector extends ASTVisitor { > } > > public AnnotationCollector( >+ ConstructorDeclaration constructorDeclaration, >+ int targetType, >+ List annotationContexts) { >+ this.annotationContexts = annotationContexts; >+ this.targetType = targetType; >+ this.primaryAnnotations = constructorDeclaration.annotations; >+ } >+ >+ public AnnotationCollector( > FieldDeclaration fieldDeclaration, > int targetType, > List annotationContexts) { >-- >1.7.11.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 415399
: 234649