JDK-8160370 : System.getProperty("os.version") returns "Unknown" on Mac
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2016-06-27
  • Updated: 2017-07-05
  • Resolved: 2016-06-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u152Resolved 9 b126Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
java.lang.Error: Unknown != 10.8.5
	at OsVersionTest.main(OsVersionTest.java:52)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-internal/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-internal/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-internal/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9-internal/Method.java:533)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
	at java.lang.Thread.run(java.base@9-internal/Thread.java:843)

JavaTest Message: Test threw exception: java.lang.Error: Unknown != 10.8.5
JavaTest Message: shutting down test

Comments
RULE "java/lang/System/OsVersionTest.java" Exception java.lang.Error: ... != ...
2016-07-04

http://cr.openjdk.java.net/~bchristi/8160370/webrev.00/
2016-06-29

Sounds like a plan, then.
2016-06-29

+1 Gerard's suggestion. That's probably the cleanest solution without dragging JRS back in.
2016-06-29

We could add: if (osVersionCStr == NULL) { NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; NSString *nsVerStr = [version objectForKey:@"ProductVersion"]; osVersionCStr = strdup([nsVerStr UTF8String]); } to the code in question, which would keep it backwards compatible and testing going.
2016-06-29

While 10.8.5 is not on the supported platform list for 9, the supported platform JEP and all its related JEPs and subtasks have not yet been completed. In particular JDK-8156132 is still open and seem directly relevant here. The use of code that only works on 10.9+ seems a little premature in that regard.
2016-06-28

Going to keep this bug (JDK-8160370) open so that DKFL can match any failures until we stop using the older MacOS X releases...
2016-06-28

Done. See the linked "INTJDK" issue.
2016-06-28

I don't mind keeping this open if it will prevent wasted time. Can someone file the infra bug?
2016-06-28

JDK-7131356 uses functionality available in Mac OS 10.9 and newer. Mac OS 10.8.5 ("Mountain Lion") has been unsupported by Apple since late summer 2015, per https://en.wikipedia.org/wiki/OS_X_Mountain_Lion. The last Mountain Lion security update listed on https://support.apple.com/en-gb/HT201222 was Aug, 2015. 10.8.5 is also is not supported by JDK 9 (per the previous link I posted) . As such, I'm inclined to close this as, "Won't Fix."
2016-06-28

We need a new infra bug that changes JDK9 testing to stop using older MacOS X versions. If you close this bug as "won't fix" and we get another failure like this, then we're wasting time trying to figure out the failure.
2016-06-28

Note that the minimum supported Mac OS version for JDK 9 is 10.10, per https://jdk9.java.net/jdk9_supported_platforms.html.
2016-06-28

On Mac OS X 10.11.5 the following code returns "osVersionCStr: 10.11.5", but what happens when it's ran on Mac OS X 10.8.5 ? (ie. does [NSProcessInfo operatingSystemVersion] work?) #include <stdio.h> #include <stdlib.h> #include <string.h> #import <CoreFoundation/CoreFoundation.h> #import <objc/objc-runtime.h> @import Foundation; typedef struct { NSInteger majorVersion; NSInteger minorVersion; NSInteger patchVersion; } OSVerStruct; void setOSNameAndVersion(void) { char* osVersionCStr = NULL; // Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, // but it's not in the 10.9 SDK. So, call it via objc_msgSend_stret. if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { OSVerStruct (*procInfoFn)(id rec, SEL sel) = (OSVerStruct(*)(id, SEL))objc_msgSend_stret; OSVerStruct osVer = procInfoFn([NSProcessInfo processInfo], @selector(operatingSystemVersion)); NSString *nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld", (long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion]; // Copy out the char* osVersionCStr = strdup([nsVerStr UTF8String]); } if (osVersionCStr == NULL) { osVersionCStr = strdup("Unknown"); } printf("osVersionCStr: %s\n", osVersionCStr); } int main(void) { setOSNameAndVersion(); return 0; }
2016-06-28

The "/jdk/test/java/lang/System/OsVersionTest.java" test compares java's "System.getProperty("os.version")" with Mac's "sw_vers -productVersion". In this particular case it seems to fail when ran on Mac OS X version 10.8.5
2016-06-28

The code for this comes from the JDK not hotspot. jdk/src/java.base/macosx/native/libjava/java_props_macosx.c void setOSNameAndVersion(java_props_t *sprops) { // Hardcode os_name, and fill in os_version sprops->os_name = strdup("Mac OS X"); char* osVersionCStr = NULL; // Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, // but it's not in the 10.9 SDK. So, call it via objc_msgSend_stret. if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { OSVerStruct (*procInfoFn)(id rec, SEL sel) = (OSVerStruct(*)(id, SEL))objc_msgSend_stret; OSVerStruct osVer = procInfoFn([NSProcessInfo processInfo], @selector(operatingSystemVersion)); NSString *nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld", (long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion]; // Copy out the char* osVersionCStr = strdup([nsVerStr UTF8String]); } if (osVersionCStr == NULL) { osVersionCStr = strdup("Unknown"); } sprops->os_version = osVersionCStr; } This is new code introduced by JDK-7131356
2016-06-28