Problem with type annotations on a type parameter
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Apr 24 21:53:25 PDT 2013
My guess is that this is a problem in TreeTranslator somehow/somewhere.
-- Jon
On 04/24/2013 09:34 PM, Werner Dietl wrote:
> Yes, it's lost, because its position is never set and UNKNOWN
> positions create the warning and are not written.
> So for some reason the position is correctly set when there is no
> instantiation, but not set if there is an instantiation.
> There must be some difference in what phases happen to the class
> depending on this.
>
> Thanks for looking into this!
> cu, WMD.
>
> On Thu, Apr 25, 2013 at 12:27 AM, Jonathan Gibbons
> <jonathan.gibbons at oracle.com> wrote:
>> Werner,
>>
>> Just to be clear, everything is OK in the generated output except the
>> missing type anno in the output, right? So the problem is just that the
>> type annos are getting "lost" along the way?
>>
>> -- Jon
>>
>>
>>
>>
>> On 04/04/2013 06:02 PM, Werner Dietl wrote:
>>> Jon, Steve, all,
>>>
>>> I'm debugging some strange behavior and I would appreciate a quick look by
>>> somebody else. I'm probably missing something very obvious.
>>>
>>> Take the attached class that contains a class nested within an anonymous
>>> class.
>>> Compile with the type-annotations javac and you'll get this output:
>>>
>>> ClassWriter: Position UNKNOWN in type annotation: @TA
>>> ClassWriter: Position UNKNOWN in type annotation: @TA
>>>
>>> That's bad, as it means that the type annotation is not written. We
>>> confirm this by running javap:
>>>
>>> javap -v NestedTest\$1\$Inner.class
>>>
>>> Nothing on the type parameter.
>>>
>>> The strange thing is that this works if we remove the declaration of field
>>> i1.
>>> It also works if instead of a method type parameter we declare a method
>>> parameter, or a class type parameter, or if the class is outside of the
>>> anonymous class.
>>>
>>> Does anybody understand the dependency between field i1 and the type
>>> parameter X?
>>>
>>> Steve: could you expand the tests in
>>> tools/javac/annotations/typeAnnotations/referenceinfos/ to ensure that
>>> annotations in anonymous classes and lambdas work as expected?
>>> Please also add a failing test for this.
>>>
>>> Thanks,
>>> cu, WMD.
>>>
>>> --
>>> http://www.google.com/profiles/wdietl
>>
>
>
More information about the type-annotations-dev
mailing list