JDK-8008182 : Repeated type-annotation on type arg in method reference not written to class file
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2013-02-13
  • Updated: 2013-08-30
  • Resolved: 2013-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Relates :  
Description
A repeated type-annotation on a type argument in a method reference is not written to the class file.
A single type-annotation is.  In the sample below, there is one  RuntimeVisibleTypeAnnotations:
      0: #25(): METHOD_REFERENCE_TYPE_ARGUMENT, offset=42, type_index=0
- - - - - - - - - - - - - - - - - - - - - - 
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*; 
import static java.lang.annotation.ElementType.*; 
import java.util.List; 
import java.util.ArrayList;

//case6:(repeating) type annotations on type parm in method reference.
class Test6{
    interface PrintString   { void    print(String s); }
    public void printArray(Object[] oa, PrintString ps) {
        for(Object o : oa ) ps.print(o.toString());
    }

    public void test() {
        Integer[] intarray = {1,2,3,4,5};
        printArray(intarray, TPrint::<@A String>print);               //okay
        printArray(intarray, TPrint::<@A @A String>print);        //no annotations in class file
        printArray(intarray, TPrint::<@A @A @B String>print); //okay
        printArray(intarray, TPrint::<@A @A @B @B String>print);        //no annotations in class file

    }

    public static void main(String... args) {new Test6().test(); }
}

class TPrint {
   public static <T> void print(T t) { System.out.println( t.toString()); }
}

@Retention(RUNTIME) @Target({TYPE_USE,TYPE}) @Repeatable( AC.class ) @interface A { }
@Retention(RUNTIME) @Target({TYPE_USE,TYPE}) @interface AC { A[] value(); } 

@Retention(RUNTIME) @Target({TYPE_USE,TYPE}) @Repeatable( BC.class ) @interface B { }
@Retention(RUNTIME) @Target({TYPE_USE,TYPE}) @interface BC { B[] value(); } 
Comments
This bug is not reproducible in TL anymore.
30-08-2013

Although JDK-8005681 is fixed in the type annotations forest this bug is still open there
14-05-2013

I find this bug below has the same behavior as the bug for repeating annotations on new,cast,array levels( 8005681). If there is only even numbers of annotations, they do not show up.
13-02-2013