RFR: 8265418: Clean-up redundant null-checks of Class.getPackageName()
plevart at openjdk.java.net
Tue Apr 27 13:53:40 UTC 2021
On Tue, 27 Apr 2021 09:17:43 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:
> > Also be careful not to return a string which
> > is not interned (which would happen if you did what you are proposing
> > above).
> Ok, I'm probably missing something, but when we move `String.intern()` call to `this.packageName = pn.intern();` there is no case when non-interned String is returned: there's only one assignment to the field `packageName` and the value assigned is always interned, right?
...in code. The local var is returned. As said, string constants are already interned. Calling .intern() on them will mean unnecessary overhead.
More information about the core-libs-dev