提交 c2f8cbe1 编写于 作者: B bchristi

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
上级 1f3787f6
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册