JDK 9 RFR of JDK-8074977: Constructor.getAnnotatedParameterTypes returns wrong value

joe darcy joe.darcy at oracle.com
Sat May 27 17:43:31 UTC 2017


Hi Joel,

Thanks for the comments. I'll include an update/correction as part of 
the follow-up work in JDK 10.

Cheers,

-Joe


On 5/27/2017 1:48 AM, Joel Borggrén-Franck wrote:
> Hi Joe,
>
> Looks Good.
>
> Nit: TypeAnnotationParser.java
>
> "126         // If a constructor has a mandated outer this, that parameter
>   127         // has no annotations and the annotations to parameter mapping
>   128         // should be offset by 1."
>
>  From memory this comment is a bit misleading since the outer this
> might actually have a receiver type annotation. The outcome seem
> correct though.
>
> cheers
> /Joel
>
> On Fri, May 19, 2017 at 11:31 PM, joe darcy <joe.darcy at oracle.com> wrote:
>> Hello,
>>
>> Please review the webrev to fix
>>
>>      JDK-8074977: Constructor.getAnnotatedParameterTypes returns wrong value
>>      http://cr.openjdk.java.net/~darcy/8074977.3/
>>
>> To condense a complicated situation, there are cases where the number of
>> parameters present for a constructor in source code and the number of
>> parameters present for that constructor in the class file differ. One of
>> those cases occurs for the constructor of a non-static member class [1]
>> where there is a leading parameter to accept the outer this argument.
>>
>> Bug JDK-8074977 reports on a situation where the type annotations on
>> constructor parameters are incorrectly reported. Essentially, an off-by-one
>> error is the cause since the annotation information is stored with respect
>> to the number of parameters present in the source and an additional
>> parameter is present at runtime.
>>
>> An analogous situation exists for declaration annotations and constructor
>> parameters, declaration annotations being the traditional flavor of
>> annotations.
>>
>> Type annotations and declaration annotations are read using different APIs
>> so require separate fixes to detect the additional parameter and make the
>> necessary adjustments in the returned information.
>>
>> The regression tests cover both the type annotation reading API and the two
>> ways of reading declaration annotations on parameters, calling
>> getParameterAnnotations on the constructor or call getParameters on the
>> constructor and then calling getAnnotations on each parameter. The
>> getParameters API was added in JDK 8.
>>
>> Static member and non-static member classes are used as test cases, as are
>> constructors with and without generic type information.
>>
>> Thanks,
>>
>> -Joe
>>
>> [1]
>> https://blogs.oracle.com/darcy/nested,-inner,-member,-and-top-level-classes
>>



More information about the core-libs-dev mailing list