8264032: Improve thread safety of Runtime.version()

Reviewed-by: shade, alanb
This commit is contained in:
Andrey Turbanov 2021-03-23 13:21:44 +00:00 committed by Aleksey Shipilev
parent 8c1ab38ee2
commit 233536263e

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, Azul Systems, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -816,12 +816,14 @@ public class Runtime {
* @since 9
*/
public static Version version() {
if (version == null) {
version = new Version(VersionProps.versionNumbers(),
var v = version;
if (v == null) {
v = new Version(VersionProps.versionNumbers(),
VersionProps.pre(), VersionProps.build(),
VersionProps.optional());
version = v;
}
return version;
return v;
}
/**