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

javac does not generate RuntimeParameterAnnotation attributes for lambda expressions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 8u60, 9
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
      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

              Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              aeremeev Andrei Eremeev
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: