RFR 7183985: Class.getAnnotation() throws an ArrayStoreException when the annotation class not present

joe darcy joe.darcy at oracle.com
Fri Feb 23 18:06:29 UTC 2018


On 2/23/2018 9:39 AM, Alan Bateman wrote:
> On 22/02/2018 23:20, Liam Miller-Cushon wrote:
>> Hello,
>>
>>
>> Please consider this fix for JDK-7183985.
>>
>>
>> bug: https://bugs.openjdk.java.net/browse/JDK-7183985
>>
>> webrev: http://cr.openjdk.java.net/~cushon/7183985/webrev.01/
>>
>>
>> I started a CSR for the change:
>> https://bugs.openjdk.java.net/browse/JDK-8198584
>>
>> We have been using the fix at Google for about two years, and there has
>> been no compatibility impact. I found very few places 
>> ArrayStoreException
>> was being explicitly handled, and none that were depending on the 
>> current
>> behaviour of getAnnotation().
>>
>>
>> There was some previous discussion of the bug on core-libs-dev:
>>
> Yes, this one comes up every few years. I'm hoping Joe Darcy will 
> reply to your review with any background or issues from when this came 
> up in the past. From a distance then retrofitting AnnotatedElement 
> getXXX methods to throw TypeNotPresentException seems reasonable, I'm 
> less sure about the isAnnotationPresent method as it might be 
> surprising for that to fail.
>

On my list!

Cheers,

-Joe



More information about the core-libs-dev mailing list