Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8006825

type annotations on lambda expression are not written to class file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • tools
    • generic
    • generic

      This sample code, when compiled, has no annotations in class file:
      import java.lang.annotation.*;
      import static java.lang.annotation.RetentionPolicy.*;
      import static java.lang.annotation.ElementType.*;

      public class lambda1 {
          IntOperation dubble = (@A Integer I) -> I * 2;
          PrintString PS = (@A String msg) -> System.out.println(msg);
          PrintString Debug = (@A String msg) -> { @A @A String dbg="DEBUG:";
                                                   dbg=dbg.concat(msg);
                                                   System.out.println(dbg); };

          public void test(Integer i) {
             Debug.print("Annotated types in lambda expressions test.");
             for(int j = 0; j<i; j++)
                PS.print( dubble.operate(j).toString() );
          }

          public static void main(String... args) {
              lambda1 l = new lambda1();
              l.test(5);
          }

          interface IntOperation { Integer operate(Integer i); }
          interface PrintString { void print(String s); }

          @Retention(RUNTIME)
          @Target({TYPE_USE})
          @Repeatable( AC.class)
          @interface A {}

          @Retention(RUNTIME)
          @Target({TYPE_USE})
          @interface AC { A[] value(); }
      }

            ssides Steve Sides
            ssides Steve Sides
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: