It could, but as far as I know it then isn't a compliant JIT any more. That is, it's either a bug or a deliberate deviation from the specification.
This doesn't make sense to me. Am I thinking wrong? Can you point me to documentation/reference that states that the JIT isn't allowed to do this?
Note that a String's value field is final.
An object is considered to be completely initialized when its constructor finishes.
A thread that can only see a reference to an object after that object has been completely
initialized is guaranteed to see the correctly initialized values for that object's final fields.So to recap: this shouldn't be possible for Strings, since the value field in the String class is final and therefore has a memory barrier. But it could happen for other classes with non-final fields.