1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
46 "@@RUNTIME_NAME@@";
47
48 private static final String java_runtime_version =
49 "@@VERSION_STRING@@";
50
51 private static final String VERSION_NUMBER =
52 "@@VERSION_NUMBER@@";
53
54 private static final String VERSION_BUILD =
55 "@@VERSION_BUILD@@";
56
57 private static final String VERSION_PRE =
58 "@@VERSION_PRE@@";
59
60 private static final String VERSION_OPT =
61 "@@VERSION_OPT@@";
62
63 private static final boolean isLTS =
64 "@@VERSION_OPT@@".startsWith("LTS");
65
66 private static final String VENDOR_VERSION_STRING =
67 "@@VENDOR_VERSION_STRING@@";
68
69 private static final String vendor_version =
70 (VENDOR_VERSION_STRING.length() > 0
71 ? " " + VENDOR_VERSION_STRING : "");
72
73 public static void init(Properties props) {
74 props.setProperty("java.version", java_version);
75 props.setProperty("java.version.date", java_version_date);
76 props.setProperty("java.runtime.version", java_runtime_version);
77 props.setProperty("java.runtime.name", java_runtime_name);
78 if (VENDOR_VERSION_STRING.length() > 0)
79 props.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
80 }
81
82 private static int parseVersionNumber(String version, int prevIndex, int index) {
83 if (index - prevIndex > 1 &&
84 Character.digit(version.charAt(prevIndex), 10) <= 0)
85 throw new IllegalArgumentException("Leading zeros not supported (" +
86 version.substring(prevIndex, index) + ")");
87 return Integer.parseInt(version, prevIndex, index, 10);
88 }
89
90 // This method is reflectively used by regression tests.
91 static List<Integer> parseVersionNumbers(String version) {
92 // Let's find the size of an array required to hold $VNUM components
93 int size = 0;
94 int prevIndex = 0;
95 do {
96 prevIndex = version.indexOf('.', prevIndex) + 1;
97 size++;
98 } while (prevIndex > 0);
99 Integer[] verNumbers = new Integer[size];
|
1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
46 "@@RUNTIME_NAME@@";
47
48 private static final String java_runtime_version =
49 "@@VERSION_STRING@@";
50
51 private static final String VERSION_NUMBER =
52 "@@VERSION_NUMBER@@";
53
54 private static final String VERSION_BUILD =
55 "@@VERSION_BUILD@@";
56
57 private static final String VERSION_PRE =
58 "@@VERSION_PRE@@";
59
60 private static final String VERSION_OPT =
61 "@@VERSION_OPT@@";
62
63 private static final boolean isLTS =
64 "@@VERSION_OPT@@".startsWith("LTS");
65
66 private static final String CLASSFILE_MAJOR_MINOR =
67 "@@VERSION_CLASSFILE_MAJOR@@.@@VERSION_CLASSFILE_MINOR@@";
68
69 private static final String VENDOR_VERSION_STRING =
70 "@@VENDOR_VERSION_STRING@@";
71
72 private static final String vendor_version =
73 (VENDOR_VERSION_STRING.length() > 0
74 ? " " + VENDOR_VERSION_STRING : "");
75
76 private static final String VENDOR =
77 "@@VENDOR@@";
78
79 private static final String VENDOR_URL =
80 "@@VENDOR_URL@@";
81
82 private static final String VENDOR_URL_BUG =
83 "@@VENDOR_URL_BUG@@";
84
85 /**
86 * Initialize system properties using build provided values.
87 *
88 * @param props Properties instance in which to insert the properties
89 */
90 public static void init(Properties props) {
91 props.setProperty("java.version", java_version);
92 props.setProperty("java.version.date", java_version_date);
93 props.setProperty("java.runtime.version", java_runtime_version);
94 props.setProperty("java.runtime.name", java_runtime_name);
95 if (VENDOR_VERSION_STRING.length() > 0)
96 props.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
97
98 props.setProperty("java.class.version", CLASSFILE_MAJOR_MINOR);
99
100 props.setProperty("java.specification.version", VERSION_NUMBER);
101 props.setProperty("java.specification.name", "Java Platform API Specification");
102 props.setProperty("java.specification.vendor", "Oracle Corporation");
103
104 if (!VENDOR.isEmpty()) {
105 props.setProperty("java.vendor", VENDOR);
106 }
107 if (!VENDOR_URL.isEmpty()) {
108 props.setProperty("java.vendor.url", VENDOR_URL);
109 }
110 if (!VENDOR_URL_BUG.isEmpty()) {
111 props.setProperty("java.vendor.url.bug", VENDOR_URL_BUG);
112 }
113 }
114
115 private static int parseVersionNumber(String version, int prevIndex, int index) {
116 if (index - prevIndex > 1 &&
117 Character.digit(version.charAt(prevIndex), 10) <= 0)
118 throw new IllegalArgumentException("Leading zeros not supported (" +
119 version.substring(prevIndex, index) + ")");
120 return Integer.parseInt(version, prevIndex, index, 10);
121 }
122
123 // This method is reflectively used by regression tests.
124 static List<Integer> parseVersionNumbers(String version) {
125 // Let's find the size of an array required to hold $VNUM components
126 int size = 0;
127 int prevIndex = 0;
128 do {
129 prevIndex = version.indexOf('.', prevIndex) + 1;
130 size++;
131 } while (prevIndex > 0);
132 Integer[] verNumbers = new Integer[size];
|