author | redestad |
Wed, 12 Dec 2018 13:28:50 +0100 | |
changeset 52978 | 95efb32d390b |
parent 52824 | 52a692760109 |
child 53018 | 8bf9268df0e2 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
36225
6ae0eebc46e9
8150162: Move sun.misc.Version to a truly internal package
chegar
parents:
34011
diff
changeset
|
26 |
package java.lang; |
6ae0eebc46e9
8150162: Move sun.misc.Version to a truly internal package
chegar
parents:
34011
diff
changeset
|
27 |
|
2 | 28 |
import java.io.PrintStream; |
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
29 |
import java.util.Arrays; |
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
30 |
import java.util.List; |
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
31 |
import java.util.Map; |
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
32 |
import java.util.Optional; |
2 | 33 |
|
36225
6ae0eebc46e9
8150162: Move sun.misc.Version to a truly internal package
chegar
parents:
34011
diff
changeset
|
34 |
class VersionProps { |
2 | 35 |
|
36 |
private static final String launcher_name = |
|
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
27565
diff
changeset
|
37 |
"@@LAUNCHER_NAME@@"; |
2 | 38 |
|
39 |
private static final String java_version = |
|
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
27565
diff
changeset
|
40 |
"@@VERSION_SHORT@@"; |
2 | 41 |
|
48327 | 42 |
private static final String java_version_date = |
43 |
"@@VERSION_DATE@@"; |
|
44 |
||
2 | 45 |
private static final String java_runtime_name = |
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
27565
diff
changeset
|
46 |
"@@RUNTIME_NAME@@"; |
15683
3acd10709925
8003256: (profiles) Add support for profile identification
alanb
parents:
8993
diff
changeset
|
47 |
|
2 | 48 |
private static final String java_runtime_version = |
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
27565
diff
changeset
|
49 |
"@@VERSION_STRING@@"; |
2 | 50 |
|
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
51 |
private static final String VERSION_NUMBER = |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
52 |
"@@VERSION_NUMBER@@"; |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
53 |
|
52824
52a692760109
8214794: java.specification.version should be only the major version number
rriggs
parents:
52724
diff
changeset
|
54 |
private static final String VERSION_SPECIFICATION = |
52a692760109
8214794: java.specification.version should be only the major version number
rriggs
parents:
52724
diff
changeset
|
55 |
"@@VERSION_SPECIFICATION@@"; |
52a692760109
8214794: java.specification.version should be only the major version number
rriggs
parents:
52724
diff
changeset
|
56 |
|
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
57 |
private static final String VERSION_BUILD = |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
58 |
"@@VERSION_BUILD@@"; |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
59 |
|
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
60 |
private static final String VERSION_PRE = |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
61 |
"@@VERSION_PRE@@"; |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
62 |
|
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
63 |
private static final String VERSION_OPT = |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
64 |
"@@VERSION_OPT@@"; |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
65 |
|
48327 | 66 |
private static final boolean isLTS = |
67 |
"@@VERSION_OPT@@".startsWith("LTS"); |
|
68 |
||
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
69 |
private static final String CLASSFILE_MAJOR_MINOR = |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
70 |
"@@VERSION_CLASSFILE_MAJOR@@.@@VERSION_CLASSFILE_MINOR@@"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
71 |
|
48327 | 72 |
private static final String VENDOR_VERSION_STRING = |
73 |
"@@VENDOR_VERSION_STRING@@"; |
|
74 |
||
75 |
private static final String vendor_version = |
|
76 |
(VENDOR_VERSION_STRING.length() > 0 |
|
77 |
? " " + VENDOR_VERSION_STRING : ""); |
|
78 |
||
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
79 |
private static final String VENDOR = |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
80 |
"@@VENDOR@@"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
81 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
82 |
private static final String VENDOR_URL = |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
83 |
"@@VENDOR_URL@@"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
84 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
85 |
private static final String VENDOR_URL_BUG = |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
86 |
"@@VENDOR_URL_BUG@@"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
87 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
88 |
/** |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
89 |
* Initialize system properties using build provided values. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
90 |
* |
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
91 |
* @param props Map instance in which to insert the properties |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
92 |
*/ |
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
93 |
public static void init(Map<String, String> props) { |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
94 |
props.put("java.version", java_version); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
95 |
props.put("java.version.date", java_version_date); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
96 |
props.put("java.runtime.version", java_runtime_version); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
97 |
props.put("java.runtime.name", java_runtime_name); |
48327 | 98 |
if (VENDOR_VERSION_STRING.length() > 0) |
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
99 |
props.put("java.vendor.version", VENDOR_VERSION_STRING); |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
100 |
|
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
101 |
props.put("java.class.version", CLASSFILE_MAJOR_MINOR); |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
102 |
|
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
103 |
props.put("java.specification.version", VERSION_SPECIFICATION); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
104 |
props.put("java.specification.name", "Java Platform API Specification"); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
105 |
props.put("java.specification.vendor", "Oracle Corporation"); |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
106 |
|
52978
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
107 |
props.put("java.vendor", VENDOR); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
108 |
props.put("java.vendor.url", VENDOR_URL); |
95efb32d390b
8215159: Improve initial setup of system Properties
redestad
parents:
52824
diff
changeset
|
109 |
props.put("java.vendor.url.bug", VENDOR_URL_BUG); |
2 | 110 |
} |
111 |
||
39648
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
112 |
private static int parseVersionNumber(String version, int prevIndex, int index) { |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
113 |
if (index - prevIndex > 1 && |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
114 |
Character.digit(version.charAt(prevIndex), 10) <= 0) |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
115 |
throw new IllegalArgumentException("Leading zeros not supported (" + |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
116 |
version.substring(prevIndex, index) + ")"); |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
117 |
return Integer.parseInt(version, prevIndex, index, 10); |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
118 |
} |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
119 |
|
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
120 |
// This method is reflectively used by regression tests. |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
121 |
static List<Integer> parseVersionNumbers(String version) { |
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
122 |
// Let's find the size of an array required to hold $VNUM components |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
123 |
int size = 0; |
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
124 |
int prevIndex = 0; |
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
125 |
do { |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
126 |
prevIndex = version.indexOf('.', prevIndex) + 1; |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
127 |
size++; |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
128 |
} while (prevIndex > 0); |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
129 |
Integer[] verNumbers = new Integer[size]; |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
130 |
|
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
131 |
// Fill in the array with $VNUM components |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
132 |
int n = 0; |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
133 |
prevIndex = 0; |
39648
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
134 |
int index = version.indexOf('.'); |
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
135 |
while (index > -1) { |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
136 |
verNumbers[n] = parseVersionNumber(version, prevIndex, index); |
39314 | 137 |
prevIndex = index + 1; // Skip the period |
39648
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
138 |
index = version.indexOf('.', prevIndex); |
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
139 |
n++; |
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
140 |
} |
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
141 |
verNumbers[n] = parseVersionNumber(version, prevIndex, version.length()); |
39648
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
142 |
|
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
143 |
if (verNumbers[0] == 0 || verNumbers[n] == 0) |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
144 |
throw new IllegalArgumentException("Leading/trailing zeros not allowed (" + |
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
145 |
Arrays.toString(verNumbers) + ")"); |
39648
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
146 |
|
44785
62a18e20f5c1
8177738: Runtime.Version must be a value-based class
prappo
parents:
42338
diff
changeset
|
147 |
return List.of(verNumbers); |
39648
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
148 |
} |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
149 |
|
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
150 |
static List<Integer> versionNumbers() { |
9bbd1300c256
8160564: TEST: Add a test to check the implementation of VersionProps.versionNumbers()
simonis
parents:
39314
diff
changeset
|
151 |
return parseVersionNumbers(VERSION_NUMBER); |
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
152 |
} |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
153 |
|
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
154 |
static Optional<String> pre() { |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
155 |
return optionalOf(VERSION_PRE); |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
156 |
} |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
157 |
|
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
158 |
static Optional<Integer> build() { |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
159 |
return VERSION_BUILD.isEmpty() ? |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
160 |
Optional.empty() : |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
161 |
Optional.of(Integer.parseInt(VERSION_BUILD)); |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
162 |
} |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
163 |
|
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
164 |
static Optional<String> optional() { |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
165 |
return optionalOf(VERSION_OPT); |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
166 |
} |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
167 |
|
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
168 |
// Treat empty strings as value not being present |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
169 |
private static Optional<String> optionalOf(String value) { |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
170 |
if (!value.isEmpty()) { |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
171 |
return Optional.of(value); |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
172 |
} else { |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
173 |
return Optional.empty(); |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
174 |
} |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
175 |
} |
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
176 |
|
2 | 177 |
/** |
178 |
* In case you were wondering this method is called by java -version. |
|
179 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
180 |
public static void print(boolean err) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
181 |
print(err, false); |
2 | 182 |
} |
183 |
||
184 |
/** |
|
185 |
* This is the same as print except that it adds an extra line-feed |
|
186 |
* at the end, typically used by the -showversion in the launcher |
|
187 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
188 |
public static void println(boolean err) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
189 |
print(err, true); |
2 | 190 |
} |
191 |
||
192 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
193 |
* Print version info. |
2 | 194 |
*/ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
195 |
private static void print(boolean err, boolean newln) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
196 |
PrintStream ps = err ? System.err : System.out; |
8993
9076d969ffdf
7025066: Build systems changes to support SE Embedded Integration
dholmes
parents:
5506
diff
changeset
|
197 |
|
2 | 198 |
/* First line: platform version. */ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
199 |
if (err) { |
48327 | 200 |
ps.println(launcher_name + " version \"" + java_version + "\"" |
201 |
+ " " + java_version_date |
|
202 |
+ (isLTS ? " LTS" : "")); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
203 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
204 |
/* Use a format more in line with GNU conventions */ |
48327 | 205 |
ps.println(launcher_name + " " + java_version |
206 |
+ " " + java_version_date |
|
207 |
+ (isLTS ? " LTS" : "")); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40192
diff
changeset
|
208 |
} |
2 | 209 |
|
210 |
/* Second line: runtime version (ie, libraries). */ |
|
34011
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
211 |
String jdk_debug_level = System.getProperty("jdk.debug", "release"); |
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
212 |
if ("release".equals(jdk_debug_level)) { |
48327 | 213 |
/* Do not show debug level "release" builds */ |
34011
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
214 |
jdk_debug_level = ""; |
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
215 |
} else { |
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
216 |
jdk_debug_level = jdk_debug_level + " "; |
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
217 |
} |
b1ce08dd7f17
8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents:
34003
diff
changeset
|
218 |
|
48327 | 219 |
ps.println(java_runtime_name + vendor_version |
220 |
+ " (" + jdk_debug_level + "build " + java_runtime_version + ")"); |
|
2 | 221 |
|
222 |
/* Third line: JVM information. */ |
|
223 |
String java_vm_name = System.getProperty("java.vm.name"); |
|
224 |
String java_vm_version = System.getProperty("java.vm.version"); |
|
225 |
String java_vm_info = System.getProperty("java.vm.info"); |
|
48327 | 226 |
ps.println(java_vm_name + vendor_version |
227 |
+ " (" + jdk_debug_level + "build " + java_vm_version + ", " |
|
228 |
+ java_vm_info + ")"); |
|
229 |
||
2 | 230 |
} |
231 |
||
39302
aa8d0bc2a6d2
8160000: Runtime.version() cause startup regressions in 9+119
redestad
parents:
36225
diff
changeset
|
232 |
} |