Confusion over constructor invocation type arguments

Alex Buckley alex.buckley at oracle.com
Wed Jul 24 18:49:41 PDT 2013


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