Review request for 8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type

Eric McCorkle eric.mccorkle at oracle.com
Wed Nov 5 21:57:26 UTC 2014


A word on the tests: I don't think there's a stable way to check the
types on getParameterizedType() and getAnnotatedType().  So I checked
the type on getType() only.

The problem is, you have to detect and cast from ParameterizedType and
AnnotatedType respectively, but depending on the situation with generic
signatures and method parameters information (and type annotations), you
might not actually get back one of these.

On 11/05/14 10:10, Joel Borggrén-Franck wrote:
> Hi Eric,
> 
> I think caching the real parameter type array on Executable is the wrong thing to do considering we can have a lot of instances of Executable but fairly few will be examined for parameters and the vast majority of those will never have this issue.
> 
> Also, the tests are a bit minimal, I would expect you to check that the type of the parameter is correct. The tests should also have a @bug line.
> 
> I think you are overly cautious here. I’m not sure we need to work around potential bugs in non-Java compilers. If language Y inserts synthetic/mandated parameters anywhere else than as a prefix they better generate a correct Signature (or non at all). This is a discussion we can defer however.
> 
> If you flesh out the test and remove the caching I think this is a fine fix for both 8u and 9.
> 
> cheers
> /Joel
> 
> On 31 okt 2014, at 17:15, Eric McCorkle <eric.mccorkle at oracle.com> wrote:
> 
>> Hello,
>>
>> Please review this patch which fixes issues that arise with
>> getGenericParameterTypes() and getAnnotatedParameterTypes() when there
>> are generic signatures and synthetic parameters.
>>
>> Please note that a complete fix is not possible for all cases.  See
>> discussion on https://bugs.openjdk.java.net/browse/JDK-8062582 for details.
>>
>> This patch will cause Executable.getAnnotatedParameterTypes(),
>> Parameter.getAnnotatedType(), and Parameter.getParameterizedType() to
>> report the correct types in the following cases:
>>
>> * No generic signature is present.
>> * Both a generic signature and method parameters information are present
>> * A generic signature is present, but method parameters information is
>> not present, but the number of parameters in the generic signature and
>> the number of parameters in the method descriptor are the same.
>>
>> In the problematic case, where there is a generic signature, no method
>> parameters information, and the generic signature does not match the
>> method descriptor, these methods will return the correct /non/-generic
>> type, as there is no general way of associating parameters in the
>> generic signature with those in the method descriptor in this case.
>>
>> Please also note that there is currently a bug in javac which causes
>> type annotations' parameter indexes to be wrong when synthetic
>> parameters are generated: https://bugs.openjdk.java.net/browse/JDK-8029012.
>>
>> The bug report is here:
>> https://bugs.openjdk.java.net/browse/JDK-8055063
>>
>> The webrev is here:
>> http://cr.openjdk.java.net/~emc/8055063/
> 



More information about the core-libs-dev mailing list