Spec clarification for RuntimeVisibleParameterAnnotations and synthetic/mandated parameters
Alex Buckley
alex.buckley at oracle.com
Mon Oct 7 11:13:47 PDT 2013
Isn't this covered by the comments in JDK-8024694 ?
Alex
On 10/7/2013 11:12 AM, Eric McCorkle wrote:
> 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
>
More information about the compiler-dev
mailing list