changeset 12401:fe2d711d85ae

8160370: System.getProperty("os.version") returns "Unknown" on Mac Summary: Read SystemVersion.plist on pre-10.9 Mac OS Reviewed-by: bpb, ddehaven, gziemski, rriggs
author bchristi
date Thu, 30 Jun 2016 10:13:30 -0700
parents 2a274c649572
children f2224562befb
files src/solaris/native/java/lang/java_props_macosx.c
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/lang/java_props_macosx.c	Tue Mar 21 15:03:26 2017 -0700
+++ b/src/solaris/native/java/lang/java_props_macosx.c	Thu Jun 30 10:13:30 2016 -0700
@@ -182,7 +182,17 @@
         // Copy out the char*
         osVersionCStr = strdup([nsVerStr UTF8String]);
     }
-
+    // Fallback if running on pre-10.9 Mac OS
+    if (osVersionCStr == NULL) {
+        NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
+                                 @"/System/Library/CoreServices/SystemVersion.plist"];
+        if (version != NULL) {
+            NSString *nsVerStr = [version objectForKey : @"ProductVersion"];
+            if (nsVerStr != NULL) {
+                osVersionCStr = strdup([nsVerStr UTF8String]);
+            }
+        }
+    }
     if (osVersionCStr == NULL) {
         osVersionCStr = strdup("Unknown");
     }
@@ -190,7 +200,9 @@
 }
 
 
-static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) {
+static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey,
+                                       CFStringRef inHostKey, CFStringRef inPortKey,
+                                       CFStringRef *outProxyHost, int *ioProxyPort) {
     /* See if the proxy is enabled. */
     CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey);
     if (cf_enabled == NULL) {