Relates :
|
|
Relates :
|
|
Relates :
|
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); } }
|