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);
}
}
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);
}
}
- relates to
-
JDK-8140279 9.6.4.2: Do not retain declaration annotations on lambda formals
-
- Closed
-
-
JDK-8139198 [TEST_BUG]: tools/javac/classfiles/attributes/annotations/RuntimeParameterAnnotationsForLambdaTest.java fails
-
- Closed
-
-
JDK-8027181 Type Annotations Cleanup
-
- Closed
-