7178922: (props) re-visit how os.name is determined on Mac
authorbchristi
Fri, 16 Nov 2012 17:01:19 -0800
changeset 14513 f6dc8c52e275
parent 14512 4ec51f4254ab
child 14514 46a8ed03c7fc
7178922: (props) re-visit how os.name is determined on Mac Reviewed-by: alanb, mchung, skovatch, serb
jdk/src/solaris/native/java/lang/java_props_macosx.c
--- a/jdk/src/solaris/native/java/lang/java_props_macosx.c	Fri Nov 16 12:28:45 2012 -0800
+++ b/jdk/src/solaris/native/java/lang/java_props_macosx.c	Fri Nov 16 17:01:19 2012 -0800
@@ -145,27 +145,22 @@
     return pref = HToolkit;
 }
 
-void setUnknownOSAndVersion(java_props_t *sprops) {
-    sprops->os_name = strdup("Unknown");
-    sprops->os_version = 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 setOSNameAndVersion(java_props_t *sprops) {
     void *jrsFwk = getJRSFramework();
-    if (jrsFwk == NULL) {
-        setUnknownOSAndVersion(sprops);
-        return;
+    if (jrsFwk != NULL) {
+        char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
+        if (copyOSVersion != NULL) {
+            sprops->os_version = copyOSVersion();
+            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();
+    sprops->os_version = strdup("Unknown");
 }