From 05ed5fb9e6f8d1611a04a6c42faeaf100508b6b6 Mon Sep 17 00:00:00 2001 From: bchristi Date: Fri, 16 Nov 2012 17:01:19 -0800 Subject: [PATCH] 7178922: (props) re-visit how os.name is determined on Mac Reviewed-by: alanb, mchung, skovatch, serb --- .../native/java/lang/java_props_macosx.c | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/solaris/native/java/lang/java_props_macosx.c b/src/solaris/native/java/lang/java_props_macosx.c index 4afca2a2a..c890ea8c5 100644 --- a/src/solaris/native/java/lang/java_props_macosx.c +++ b/src/solaris/native/java/lang/java_props_macosx.c @@ -145,27 +145,22 @@ PreferredToolkit getPreferredToolkit() { 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) { - void *jrsFwk = getJRSFramework(); - if (jrsFwk == NULL) { - setUnknownOSAndVersion(sprops); - return; - } + /* 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"); - char *(*copyOSName)() = dlsym(jrsFwk, "JRSCopyOSName"); - char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion"); - if (copyOSName == NULL || copyOSVersion == NULL) { - setUnknownOSAndVersion(sprops); - return; + void *jrsFwk = getJRSFramework(); + if (jrsFwk != NULL) { + char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion"); + if (copyOSVersion != NULL) { + sprops->os_version = copyOSVersion(); + return; + } } - - sprops->os_name = copyOSName(); - sprops->os_version = copyOSVersion(); + sprops->os_version = strdup("Unknown"); } -- GitLab