Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 415397

Summary: [1.8][compiler] Type Annotations on wildcard type argument dropped.
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: srikanth_sankaran: review+
Version: 4.4   
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 409235    
Attachments:
Description Flags
Fix and tests none

Description Srikanth Sankaran CLA 2013-08-20 01:36:54 EDT
BETA_JAVA8: 

From the spec: 

"An annotation on a wildcard type argument appears before the wildcard, as in 
MyClass<@Immutable ? extends Comparable<MyClass>>"

However, when the following program is compiled, the annotations are
accepted, but don't seem to make it to the class file:

// ---
import java.lang.annotation.*;
import java.util.List;
import static java.lang.annotation.ElementType.*; 
@Target(TYPE_USE)
@interface Immutable {}
class X {
	List<@Immutable ? extends Comparable<X>> x;
}

// ----

javac 8b100 emits:

RuntimeInvisibleTypeAnnotations:
      0: #9(): FIELD, location=[TYPE_ARGUMENT(0)]
Comment 1 Srikanth Sankaran CLA 2013-08-20 01:37:49 EDT
Andy, if you don't expect to get to this in the next 2-3 weeks, let me know.
I'll reassign. TIA.
Comment 2 Srikanth Sankaran CLA 2013-08-20 02:26:37 EDT
Regression tests will be available via org.eclipse.jdt.core.tests.compiler.regression.JSR308SpecSnippetTests.test011()
(to be released shortly).
Comment 3 Andrew Clement CLA 2013-08-22 01:06:07 EDT
Created attachment 234646 [details]
Fix and tests

Test and fix.

Might be easier to apply after the patch attached to bug 415543
Comment 4 Srikanth Sankaran CLA 2013-08-22 03:41:38 EDT
(In reply to comment #3)
> Created attachment 234646 [details]
> Fix and tests

Patch looks good. Thanks. For good measure I also updated
org.eclipse.jdt.internal.compiler.ast.Wildcard.traverse(ASTVisitor, ClassScope)
though I couldn't with minimal effort construct a test case that would prove
the need for this change.


Released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=ef77db37669242a4bac152127ea8ae67d10be39c
Comment 5 Andrew Clement CLA 2013-08-22 12:02:34 EDT
This contribution complies with http://www.eclipse.org/legal/CoO.php