Am 25.05.2012 01:11, schrieb Mike Duigou:
On May 24 2012, at 15:56 , Ulf Zibis wrote:
Am 24.05.2012 22:45, schrieb Mike Duigou:
A patch of the changes to java.lang.String for JDK 8 are
at<http://cr.openjdk.java.net/~mduigou/6924259/0/webrev/>. The changes for JDK
7 have only superficial differences (line offsets in the patch).
Correct Copyright date.
157 public String(String original) {
158 this.value = (original.value.length> 0)
159 ? original.value
160 : EMPTY_STRING_VALUE;
161 }
Does the last case ever occur?, if you have:
It can occur in cases where original is
- a deserialized string
If not interned yes.
But stop, see argumentation for StringBuilder below...
- a string from a class file constant pool
I think, they become interned, so all should be identical.
- the string constant ""
same
- (new StringBuilder()).toString() and other empty string generators.
Hm, StringBuilder uses one of the constructors from String, so if we guarantee by all String
constructors to refer to interned EMPTY_STRING_VALUE, then this should not occur
-Ulf