Confusion over constructor invocation type arguments

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu Jul 25 07:24:01 PDT 2013


Alex,

Can you file a bug to track the bad news?

-- Jon

On 07/24/2013 06:49 PM, Alex Buckley wrote:
> Here is a simple annotation type X:
>
>   @Retention(RetentionPolicy.RUNTIME)
>   @Target(ElementType.TYPE_USE)
>   @interface X {}
>
> and a simple class with two annotations of type X:
>
>   class Foo {
>     <T> Foo(int i) { new <@X String> Foo(); }
>     <T> Foo()      { <@X String>this(0); }
>   }
>
> The good news: the @X on the type argument of the new expression is 
> compiled to a type_annotation structure with a target_type of 0x48, 
> CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT.
>
> The bad news: the @X on the type argument of the explicit constructor 
> invocation statement (JLS 8.8.7.1) is compiled to a type_annotation 
> structure with a target_type of 0x49, METHOD_INVOCATION_TYPE_ARGUMENT. 
> It should be 0x48. The same applies for "<@X String>super();".
>
> Alex



More information about the type-annotations-dev mailing list