jdk/src/java.base/share/classes/sun/misc/Version.java.template
author amurillo
Wed, 04 Nov 2015 16:02:53 -0800
changeset 34011 b1ce08dd7f17
parent 34003 3c4ba277fdb6
permissions -rw-r--r--
8139986: Store debug level in java.vm.debug and conditionally print in "java -version" Reviewed-by: ihse, dcubed, ksrini, dholmes Contributed-by: alejandro.murillo@oracle.com, kumar.x.srinivasan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
     2
 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.misc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.PrintStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
public class Version {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
    private static final String launcher_name =
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
    33
        "@@LAUNCHER_NAME@@";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    private static final String java_version =
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
    36
        "@@VERSION_SHORT@@";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private static final String java_runtime_name =
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
    39
        "@@RUNTIME_NAME@@";
15683
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private static final String java_runtime_version =
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
    42
        "@@VERSION_STRING@@";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public static void init() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        System.setProperty("java.version", java_version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        System.setProperty("java.runtime.version", java_runtime_version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        System.setProperty("java.runtime.name", java_runtime_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static boolean versionsInitialized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static int jvm_major_version = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static int jvm_minor_version = 0;
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
    57
    private static int jvm_security_version = 0;
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
    58
    private static int jvm_patch_version = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static int jvm_build_number = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static int jdk_major_version = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static int jdk_minor_version = 0;
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
    62
    private static int jdk_security_version = 0;
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
    63
    private static int jdk_patch_version = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static int jdk_build_number = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * In case you were wondering this method is called by java -version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Sad that it prints to stderr; would be nicer if default printed on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * stdout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public static void print() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        print(System.err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * This is the same as print except that it adds an extra line-feed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * at the end, typically used by the -showversion in the launcher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static void println() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        print(System.err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        System.err.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Give a stream, it will print version info on it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public static void print(PrintStream ps) {
8993
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
    88
        boolean isHeadless = false;
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
    89
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
    90
        /* Report that we're running headless if the property is true */
15683
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
    91
        String headless = System.getProperty("java.awt.headless");
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
    92
        if ( (headless != null) && (headless.equalsIgnoreCase("true")) ) {
8993
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
    93
            isHeadless = true;
15683
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
    94
        }
8993
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
    95
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        /* First line: platform version. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        ps.println(launcher_name + " version \"" + java_version + "\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        /* Second line: runtime version (ie, libraries). */
8993
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
   100
34011
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   101
        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
   102
        /* Debug level is not printed for "release" builds */
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   103
        if ("release".equals(jdk_debug_level)) {
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   104
            jdk_debug_level = "";
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   105
        } else {
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   106
            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
   107
        }
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   108
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   109
        ps.print(java_runtime_name + " (" + jdk_debug_level + "build " + java_runtime_version);
8993
9076d969ffdf 7025066: Build systems changes to support SE Embedded Integration
dholmes
parents: 5506
diff changeset
   110
15683
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
   111
        if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) {
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
   112
            // embedded builds report headless state
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
   113
            ps.print(", headless");
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
   114
        }
3acd10709925 8003256: (profiles) Add support for profile identification
alanb
parents: 8993
diff changeset
   115
        ps.println(')');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        /* Third line: JVM information. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        String java_vm_name    = System.getProperty("java.vm.name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        String java_vm_version = System.getProperty("java.vm.version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        String java_vm_info    = System.getProperty("java.vm.info");
34011
b1ce08dd7f17 8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
amurillo
parents: 34003
diff changeset
   121
        ps.println(java_vm_name + " (" + jdk_debug_level + "build " + java_vm_version + ", " +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                   java_vm_info + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   127
     * Returns the major version of the running JVM.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   128
     * @return the major version of the running JVM
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public static synchronized int jvmMajorVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        return jvm_major_version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   139
     * Returns the minor version of the running JVM.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   140
     * @return the minor version of the running JVM
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public static synchronized int jvmMinorVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        return jvm_minor_version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   152
     * Returns the security version of the running JVM.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   153
     * @return the security version of the running JVM
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   154
     * @since 9
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
   156
    public static synchronized int jvmSecurityVersion() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
   160
        return jvm_security_version;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   164
     * Returns the patch release version of the running JVM.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   165
     * @return the patch release version of the running JVM
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   166
     * @since 9
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   168
    public static synchronized int jvmPatchVersion() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   172
        return jvm_patch_version;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   176
     * Returns the build number of the running JVM.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   177
     * @return the build number of the running JVM
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public static synchronized int jvmBuildNumber() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        return jvm_build_number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Returns the major version of the running JDK.
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   189
     * @return the major version of the running JDK
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public static synchronized int jdkMajorVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        return jdk_major_version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Returns the minor version of the running JDK.
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   201
     * @return the minor version of the running JDK
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public static synchronized int jdkMinorVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return jdk_minor_version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
   212
     * Returns the security version of the running JDK.
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   213
     * @return the security version of the running JDK
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   214
     * @since 9
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
   216
    public static synchronized int jdkSecurityVersion() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 27565
diff changeset
   220
        return jdk_security_version;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   224
     * Returns the patch release version of the running JDK.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   225
     * @return the patch release version of the running JDK
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   226
     * @since 9
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     */
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   228
    public static synchronized int jdkPatchVersion() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   232
        return jdk_patch_version;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
34003
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   236
     * Returns the build number of the running JDK.
3c4ba277fdb6 8087203: Adapt Version.java.template to the JEP-223 new version string format
amurillo
parents: 33986
diff changeset
   237
     * @return the build number of the running JDK
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public static synchronized int jdkBuildNumber() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (!versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            initVersions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return jdk_build_number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    private static synchronized void initVersions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        if (versionsInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
33986
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   251
        if (!getJvmVersionInfo()) {
5cbe9cd17789 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 33984
diff changeset
   252
            throw new InternalError("Unable to obtain JVM version info");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        getJdkVersionInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        versionsInitialized = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    // Gets the JVM version info if available and sets the jvm_*_version fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    // and its capabilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    private static native boolean getJvmVersionInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    private static native void getJdkVersionInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
// Help Emacs a little because this file doesn't end in .java.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
// Local Variables: ***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
// mode: java ***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
// End: ***