[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: Re: [OpenJDK 2D-Dev] <Beans Dev> RFR: 8155874: Fix java.desktop deprecation warnings about Class.new
From: Alexandr Scherbatiy <alexandr.scherbatiy () oracle ! com>
Date: 2016-11-08 9:20:42
Message-ID: afac19cd-0a87-1e68-9763-67896fb73eed () oracle ! com
[Download RAW message or body]
The fix looks good to me.
Thanks,
Alexandr.
On 11/7/2016 10:12 PM, Sergey Bylokhov wrote:
> Looks fine.
>
> On 07.11.16 21:49, Phil Race wrote:
>> bug: https://bugs.openjdk.java.net/browse/JDK-8155874
>> Webrev: http://cr.openjdk.java.net/~prr/8155874/
>>
>> This hits all across the desktop module, hence the cross-post.
>>
>> The Class.newInstance() has been deprecated since it
>> may throw checked exceptions that are not declared.
>>
>> Class.getConstructor().newInstance() was recommended as a
>> replacement but it will return only public constructors.
>>
>> So if you have package access to a package private constructor it will
>> fail where
>> as the previous pattern succeeded
>>
>> So the recommendation now is to use
>> Class.getDeclaredConstructor().newInstance()
>> and this fix uses that except for some cases where we have a limited and
>> known
>> set of internal "service providers" which are known to use public
>> classes and constructors.
>>
>> Also some exception catching has been cleaned up as appropriate for the
>> new method call and taking advantage of the JDK 1.7
>> ReflectiveOperationException
>>
>> -phil.
>>
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic