Spec clarification for RuntimeVisibleParameterAnnotations and synthetic/mandated parameters
Vicente-Arturo Romero-Zaldivar
vicente.romero at oracle.com
Tue Oct 8 01:13:33 PDT 2013
Hi Eric,
Jan is right now working in a bug, 8024694: javac always expects
signature attribute for enum constructors, that is related to this
issue. You can check the comments for more information.
The idea is to fix this issue so that Runtime Visible / Invisible
Parameter Annotations are mapped to the exact number of parameters.
Vicente
On 07/10/13 20:12, 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20131008/2a40640e/attachment.html
More information about the compiler-dev
mailing list