You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Brad Walker <bw...@musings.com> on 2019/03/29 19:43:56 UTC

? about development

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.

Re: ? about development

Posted by Tushar Joshi <tu...@gmail.com>.
I liked this idea.  So we will have a new method overriding the Object
method and just by that all the code will start using this new method,
instead of the old deprecated one.  This will be code change directly only
in one place and indirectly call changed in many places.

If there is a proper base class in the object hierarchy of NB objects where
we can add such method it will be easier.  Otherwise this method can be a
utility class utility method, but in that case it will still be a change of
code in many places.

with regards
    Tushar

Tushar Joshi, Nagpur: http://www.tusharjoshi.com

* MCSD_NET C#, SCJP, RHCE, ZCE, PMP, CSM, SAFe, PRINCE2

* Senior Architect @ Persistent Systems http://www.persistent.com
* LinkedIn: http://www.linkedin.com/in/tusharvjoshi



On Mon, Apr 1, 2019 at 1:14 AM Tim Boudreau <ni...@gmail.com> wrote:

> 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 <bw...@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
>

Re: ? about development

Posted by Tim Boudreau <ni...@gmail.com>.
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 <bw...@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

Re: ? about development

Posted by Matthias Bläsing <mb...@doppel-helix.eu>.
Hi Brad,

Am Freitag, den 29.03.2019, 13:43 -0600 schrieb Brad Walker:
> 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 think this is a worthwhile effort. Everybody will benefit from a
better signal-to-noise ration in compiler warnings.

Before going through the whole code-base, a prototype with one or two
modules would be good. As you've seen by the reply from Tim there can
be immediate feedback.

I would appreciate it.

Greetings

Matthias


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.incubator.apache.org
For additional commands, e-mail: dev-help@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists