src/share/classes/sun/misc/Version.java.template
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/share/classes/sun/misc/Version.java.template	Sun Dec 23 06:00:52 2012
--- new/src/share/classes/sun/misc/Version.java.template	Sun Dec 23 06:00:51 2012

*** 1,7 **** --- 1,7 ---- /* ! * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. ! * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 36,45 **** --- 36,48 ---- "@@java_version@@"; private static final String java_runtime_name = "@@java_runtime_name@@"; + private static final String java_profile_name = + "@@java_profile_name@@"; + private static final String java_runtime_version = "@@java_runtime_version@@"; static { init();
*** 47,56 **** --- 50,61 ---- public static void init() { System.setProperty("java.version", java_version); System.setProperty("java.runtime.version", java_runtime_version); System.setProperty("java.runtime.name", java_runtime_name); + if (java_profile_name.length() > 0) + System.setProperty("java.runtime.profile", java_profile_name); } private static boolean versionsInitialized = false; private static int jvm_major_version = 0; private static int jvm_minor_version = 0;
*** 100,109 **** --- 105,119 ---- /* Second line: runtime version (ie, libraries). */ ps.print(java_runtime_name + " (build " + java_runtime_version); + if (java_profile_name.length() > 0) { + // profile name + ps.print(", profile " + java_profile_name); + } + if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) { // embedded builds report headless state ps.print(", headless"); } ps.println(')');
*** 330,339 **** --- 340,409 ---- // // Return false if not available which implies an old VM (Tiger or before). private static native boolean getJvmVersionInfo(); private static native void getJdkVersionInfo(); + // Possible runtime profiles, ordered from small to large + private final static String[] PROFILES = { "compact1", "compact2", "compact3" }; + + /** + * Returns the name of the profile that this runtime implements. The empty + * string is returned for the full Java Runtime. + */ + public static String profileName() { + return java_profile_name; + } + + /** + * Indicates if this runtime implements the full Java Runtime. + */ + public static boolean isFullJre() { + return java_profile_name.length() == 0; + } + + // cached index of this profile's name in PROFILES + private static int thisRuntimeIndex = -1; + + /** + * Indicates if this runtime supports the given profile. Profile names are + * compared without regard to case. Returns {@code false} if the given profile + * name is not a supported profile. + */ + public static boolean supportsProfile(String requiredProfile) { + int x = thisRuntimeIndex; + if (x < 0) { + String profile = profileName(); + if (profile.length() > 0) { + x = 0; + while (x < PROFILES.length) { + if (PROFILES[x].equalsIgnoreCase(profile)) + break; + x++; + } + if (x >= PROFILES.length) + throw new InternalError(profile + " not known to sun.misc.Version"); + + // okay if another thread has already set it + thisRuntimeIndex = x; + } + // else we are a full JRE + } + + int y = 0; + while (y < PROFILES.length) { + if (PROFILES[y].equalsIgnoreCase(requiredProfile)) + break; + y++; + } + if (y >= PROFILES.length) { + // profile not found so caller has requested something that is not defined + return false; + } + + return x < 0 || x >= y; + } + } // Help Emacs a little because this file doesn't end in .java. // // Local Variables: ***

src/share/classes/sun/misc/Version.java.template
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File