3 ms·
I don't understand something: > stringCache = sc = layoutChars(true); How does this assign an uninitialized String to stringCache? I thought String is immutab
by gwbas1c 9y ago
I don't understand something:
> stringCache = sc = layoutChars(true);
How does this assign an uninitialized String to stringCache? I thought String is immutable and the String object is fully calculated at assignment? Where is the StringBuilder used when stringCache and sc are objects of type "String?"
Shouldn't the "problem" be that two threads might call layoutChars at the same time, leading to some extra CPU cycles wasted and some extra garbage?
I suspect that the real source code is different, or the real problem that leads to the NRE is different.
- mmastrac 9y agoYou are correct that this is allowed by the Java spec (1). Final fields are guaranteed to happen before reference assignment, and strings are explicitly mentioned. It appears to be an ARM JVM bug. 1. https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.5 https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.htm...