changeset 6127:6f20caa6e1e9

7178922: (props) re-visit how os.name is determined on Mac Reviewed-by: alanb, mchung, skovatch, serb
author bchristi
date Fri, 16 Nov 2012 17:01:19 -0800
parents 0ee09f17361e
children 25e5df117021
files src/solaris/native/java/lang/java_props_macosx.c
diffstat 1 files changed, 15 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/lang/java_props_macosx.c	Fri Nov 16 12:28:45 2012 -0800
+++ b/src/solaris/native/java/lang/java_props_macosx.c	Fri Nov 16 17:01:19 2012 -0800
@@ -145,29 +145,24 @@
     return pref = HToolkit;
 }
 
-void setUnknownOSAndVersion(java_props_t *sprops) {
-    sprops->os_name = strdup("Unknown");
+void setOSNameAndVersion(java_props_t *sprops) {
+    /* Don't rely on JRSCopyOSName because there's no guarantee the value will
+     * remain the same, or even if the JRS functions will continue to be part of
+     * Mac OS X.  So hardcode os_name, and fill in os_version if we can.
+     */
+    sprops->os_name = strdup("Mac OS X");
+
+    void *jrsFwk = getJRSFramework();
+    if (jrsFwk != NULL) {
+        char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
+        if (copyOSVersion != NULL) {
+            sprops->os_version = copyOSVersion();
+            return;
+        }
+    }
     sprops->os_version = strdup("Unknown");
 }
 
-void setOSNameAndVersion(java_props_t *sprops) {
-    void *jrsFwk = getJRSFramework();
-    if (jrsFwk == NULL) {
-        setUnknownOSAndVersion(sprops);
-        return;
-    }
-
-    char *(*copyOSName)() = dlsym(jrsFwk, "JRSCopyOSName");
-    char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
-    if (copyOSName == NULL || copyOSVersion == NULL) {
-        setUnknownOSAndVersion(sprops);
-        return;
-    }
-
-    sprops->os_name = copyOSName();
-    sprops->os_version = copyOSVersion();
-}
-
 
 static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) {
     /* See if the proxy is enabled. */