On Mon, 4 Jan 2021 17:45:25 GMT, Mandy Chung <mch...@openjdk.org> wrote:
>> Peter Levart has updated the pull request incrementally with one additional >> commit since the last revision: >> >> revert the unrelated change > > Marked as reviewed by mchung (Reviewer). > > > _Mailing list message from [Hans Boehm](mailto:hbo...@google.com) on > [core-libs-dev](mailto:core-libs-...@openjdk.java.net):_ > > On Mon, Jan 4, 2021 at 8:34 AM Peter Levart <plevart at openjdk.java.net> > wrote: > > > On Mon, 4 Jan 2021 15:57:33 GMT, Richard Reingruber <rrich at openjdk.org> > > wrote: > > > > > The bug title and the PR title need to be the same. > > > > Editing either one is fine. > > > > > > > > > But wouldn't it be legal for a compiler (java to bytecode or bytecode to > > > machinecode) to replace references of my_local_copy with references to > > > static_field? > > > Foo my_local_copy = static_field; > > > if (my_copy == null) { > > > initialize(); > > > my_local_copy = static_field; > > > } > > > return my_local_copy; > > > Only if static_field was volatile this would be illegal, wouldn't it? > > > > > > @reinrich I don't think Java compilers may do that. If this was allowed, > > such variables would not be called "local". > > > > > Indeed. Such transformations are allowed in C and C++ (since data races > result in undefined behavior, and thus the > compiler is allowed to assume there are no concurrent writes), but not in > Java. Thanks for the explanation. ------------- PR: https://git.openjdk.java.net/jdk/pull/1914