Spec clarification for RuntimeVisibleParameterAnnotations and synthetic/mandated parameters
Eric McCorkle
eric.mccorkle at oracle.com
Mon Oct 7 11:12:32 PDT 2013
I would like to request clarification on the proper behavior of javac
when generating RuntimeVisibleParameterAnnotations attributes for
methods with synthetic/mandated parameters.
Right now, the behavior of javac seems to be to omit these parameters
from the generated attribute. This causes problems with
java.lang.reflect.Executable.getParameterAnnotations() and
java.lang.reflect.Parameter.getAnnotations().
Here is an example:
Example code:
import java.lang.reflect.Parameter;
import java.lang.annotation.*;
public class InnerClassAnnotationTest {
public static void main(String[] args) {
Parameter p = E.class.getConstructors()[0].getParameters()[1];
p.getAnnotations();
}
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann {}
public class E {
public E(@Ann Object o) {}
}
}
The output of javap about the constructor is this:
public InnerClassAnnotationTest$E(InnerClassAnnotationTest,
java.lang.Object);
descriptor: (LInnerClassAnnotationTest;Ljava/lang/Object;)V
flags: ACC_PUBLIC
Code:
stack=2, locals=3, args_size=3
0: aload_0
1: aload_1
2: putfield #1 // Field
this$0:LInnerClassAnnotationTest;
5: aload_0
6: invokespecial #2 // Method
java/lang/Object."<init>":()V
9: return
LineNumberTable:
line 46: 0
MethodParameters:
Name Flags
this$0 final mandated
o
RuntimeVisibleParameterAnnotations:
parameter 0:
0: #17()
Note the disparity between MethodParameters and
RuntimeVisibleParameterAnnotations.
I need to know 1) is this an error (I suspect it is), and 2) should it
be fixed for 8?
Thanks,
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eric_mccorkle.vcf
Type: text/x-vcard
Size: 303 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20131007/6451cdb7/eric_mccorkle.vcf
More information about the compiler-dev
mailing list