RFR: 8264032: Improve thread safety of Runtime.version()
liach
github.com+7806504+liach at openjdk.java.net
Tue Mar 23 12:25:54 UTC 2021
On Tue, 23 Feb 2021 13:23:44 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
> Avoid double-read non volatile static field
This shouldn't be a problem. Version is a pojo and value based, and the computed result may be different instances but would return `true` for `equals` and should have no problems
src/java.base/share/classes/java/lang/Runtime.java line 824:
> 822: VersionProps.pre(), VersionProps.build(),
> 823: VersionProps.optional());
> 824: version = v;
Can't this just be `return version = new Version(...` than reassigning to a local variable for no good?
-------------
PR: https://git.openjdk.java.net/jdk/pull/2691
More information about the core-libs-dev
mailing list