Confusion over constructor invocation type arguments

Werner Dietl wdietl at gmail.com
Wed Jul 24 23:53:55 PDT 2013


Alex, Jon,

thanks for the bug report, Alex! I pushed the following changeset:

http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/8bee5839585f

Jon, could you please review?

Cheers,
cu, WMD.

On Wed, Jul 24, 2013 at 6:49 PM, Alex Buckley <alex.buckley at oracle.com> 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



-- 
http://www.google.com/profiles/wdietl


More information about the type-annotations-dev mailing list