Confusion over constructor invocation type arguments

Alex Buckley alex.buckley at oracle.com
Thu Jul 25 13:12:26 PDT 2013


Many thanks Werner!

Alex

On 7/24/2013 11:53 PM, Werner Dietl wrote:
> 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
>
>
>


More information about the type-annotations-dev mailing list