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

javac does not generate RuntimeParameterAnnotation attributes for lambda expressions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • 9
    • 8u60, 9
    • tools
    • None

    Description

      javac does not generate RuntimeParameterAnnotation attributes for lambda expressions.
      javac does not generate attributes for both runtime visible and runtime invisible annotations.

      To reproduce use the following code:

      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;

      import com.sun.tools.classfile.Attribute;
      import com.sun.tools.classfile.ClassFile;
      import com.sun.tools.classfile.Method;
      import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;

      public class Temp {
          public static void main(String[] args) throws Exception {
              I i = (@A int a) -> {};
              ClassFile classfile = ClassFile.read(Temp.class.getResourceAsStream("Temp.class"));
              for (Method m : classfile.methods) {
                  if (m.getName(classfile.constant_pool).startsWith("lambda$")) {
                      RuntimeVisibleParameterAnnotations_attribute a = (RuntimeVisibleParameterAnnotations_attribute) m.attributes.get(Attribute.RuntimeVisibleParameterAnnotations);
                      System.out.println(a);
                  }
              }
          }

          @Retention(RetentionPolicy.RUNTIME)
          @interface A {}
          interface I {
              void f(int a);
          }
      }

      Attachments

        Issue Links

          Activity

            People

              sadayapalam Srikanth Adayapalam (Inactive)
              aeremeev Andrei Eremeev
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: