getDeclaredConstructor() will find non-public constructors - that is not a
1:1 replacement.

I wouldn't litter the codebase with code to do all the needed checks if you
replaced it - rather add a "<T> newInstance(Class<T>, ClassLoader)" method
somewhere.

-Tim

On Fri, Mar 29, 2019 at 3:44 PM Brad Walker <bwal...@musings.com> wrote:

> I've been using/building Netbeans for the past few months..
>
> I'm interested in helping w/ development. So I was thinking that I could
> fix some of the "low-hanging" issues that would be easy for me to complete.
> This would also help me with learning the process.
>
> There are several places in the code where the following Java code exists.
> Class<?> clz = Class.forName(cslLanguageClass, true, myClassLoader);
> Object o = clz.newInstance();
>
> This causes the following error when compiling.
>
>    [repeat]
>
> /home/bwalker/src/netbeans-10.0-test/ide/csl.api/anttask/src/org/netbeans/modules/csl/CslJar.java:274:
> warning: [deprecation] newInstance() in Class has been deprecated
>    [repeat]       Object o = clz.newInstance();
>
> I was thinking about fixing these to use the getDeclaredConstructor()
> method
> as that is the recommended solution. I've also looked over the
> documentation and it looks to be correct.
>
> There are many instances of this and before I take the effort to fix them,
> I wanted to check with the dev team to see if that would be acceptable and
> a good course of action.
>
> Any advice is appreciated.
>
> -brad w.
>
-- 
http://timboudreau.com

Reply via email to