JDK-8079060 : javac does not generate RuntimeParameterAnnotation attributes for lambda expressions
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u60,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2015-04-29
  • Updated: 2015-10-22
  • Resolved: 2015-10-22
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 9
9Resolved
Related Reports
Relates :  
Relates :  
Relates :  
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);
    }
}

Comments
I'll carry over the test cleanup to https://bugs.openjdk.java.net/browse/JDK-8140279
22-10-2015

Please see https://bugs.openjdk.java.net/browse/JDK-8138612 and https://bugs.openjdk.java.net/browse/JDK-8140279 This one should be closed as not an issue and any follow ups should happen at https://bugs.openjdk.java.net/browse/JDK-8138612
22-10-2015

Not reproducible now. It looks like the issue was fixed by JDK-8037546. Nevertheless, tools/javac/classfiles/attributes/annotations/RuntimeParameterAnnotationsForLambdaTest.java fails because of a bug in the test.
08-10-2015