From c2f8cbe19bd988998702725a513780de270f7b00 Mon Sep 17 00:00:00 2001 From: bchristi Date: Thu, 30 Jun 2016 10:13:30 -0700 Subject: [PATCH] 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 --- src/solaris/native/java/lang/java_props_macosx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/solaris/native/java/lang/java_props_macosx.c b/src/solaris/native/java/lang/java_props_macosx.c index cbbfde4c2..ea3dc25c6 100644 --- a/src/solaris/native/java/lang/java_props_macosx.c +++ b/src/solaris/native/java/lang/java_props_macosx.c @@ -182,7 +182,17 @@ void setOSNameAndVersion(java_props_t *sprops) { // 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 @@ void setOSNameAndVersion(java_props_t *sprops) { } -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) { -- GitLab