Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: the text said NCE but the e.g. has a CS color. I think this is a CS. See my comment.

...

Because, the field is nonvolatile and nonfinal, the statements within the constructor can be reordered by the compiler in such a way that the this reference is published before the initialization statements have executed.

...

Compliant Solution (volatile and publish after initialization)

This noncompliant code example declares the pub field as volatile and reduces the accessibility of the static class field to package-private so that untrusted callers beyond the current package cannot obtain the this reference.

...