On Tue, 27 Apr 2021 09:17:43 GMT, Сергей Цыпанов 
<github.com+10835776+stsypa...@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?

I see:

    return pn;
    
...in code. The local var is returned. As said, string constants are already 
interned. Calling .intern() on them will mean unnecessary overhead.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3571

Reply via email to