RFR(S): 8067471: Use private static final char[0] for empty Strings
Claes Redestad
claes.redestad at oracle.com
Wed Dec 17 15:58:15 UTC 2014
On 2014-12-17 11:22, Lev Priima wrote:
> Hi,
>
> Please review space optimization in no args String constructor.
> Originally, it was already rejected once by suggestion in
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010300.html
> w/o formal justification of pros and contras. And enhancement was
> requested again by Nathan Reynolds.
>
> Issue: https://bugs.openjdk.java.net/browse/JDK-8067471
> Patch: http://cr.openjdk.java.net/~lpriima/8067471/webrev.00/
>
Could this have some obscure security implications, such as the ability
to lock up some subsystem via retrieving and synchronizing on the shared
new String().value? I guess not, for practical purposes.
I guess it could also be written:
public String() {
this.value = "".value;
}
... which would saves some byte code and should avoid having to allocate
a distinct object for this.
/Claes
More information about the core-libs-dev
mailing list