JDK 9 RFR of JDK-8159330: Improve deprecation text for Class.newInstance

Roger Riggs Roger.Riggs at Oracle.com
Mon Jun 13 13:59:21 UTC 2016


Hi,

That example kind of glosses over the need to handle 3 new exceptions.
That's been my annoyance with this change.

throws InstantiationException, IllegalAccessException, 
InvocationTargetException

Roger



On 6/12/2016 11:43 PM, joe darcy wrote:
>
> On 6/12/2016 7:21 PM, Wang Weijun wrote:
>> Why not just clazz.getConstructor().newInstance()?
>
> That seems to work to and is much shorter; thanks :-)
>
> -Joe
>
>>
>>> +     * can be replaced by
>>> +     *
>>> +     * <pre>{@code
>>> +     * clazz.getConstructor(new 
>>> Class<?>[0]).newInstance((Object[])null);
>>> +     * }</pre>
>



More information about the core-libs-dev mailing list