Confusion over constructor invocation type arguments

Alex Buckley alex.buckley at oracle.com
Thu Jul 25 13:09:58 PDT 2013


Filed as JDK-8021427 in tools/javac with label 'type-annotations'.

Alex

On 7/25/2013 7:24 AM, Jonathan Gibbons wrote:
> 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