switch (ver.dwPlatformId) {
case VER_PLATFORM_WIN32s:
sprops.os_name = "Windows 3.1";
break;
case VER_PLATFORM_WIN32_WINDOWS:
if (ver.dwMajorVersion == 4) {
switch (ver.dwMinorVersion) {
case 0: sprops.os_name = "Windows 95"; break;
case 10: sprops.os_name = "Windows 98"; break;
case 90: sprops.os_name = "Windows Me"; break;
default: sprops.os_name = "Windows 9X (unknown)"; break;
}
} else {
sprops.os_name = "Windows 9X (unknown)";
}
break;
case VER_PLATFORM_WIN32_NT:
if (ver.dwMajorVersion <= 4) {
sprops.os_name = "Windows NT";
} else if (ver.dwMajorVersion == 5) {
switch (ver.dwMinorVersion) {
case 0: sprops.os_name = "Windows 2000"; break;
case 1: sprops.os_name = "Windows XP"; break;
case 2:
/*
* From MSDN OSVERSIONINFOEX and SYSTEM_INFO documentation:
*
* "Because the version numbers for Windows Server 2003
* and Windows XP 6u4 bit are identical, you must also test
* whether the wProductType member is VER_NT_WORKSTATION.
* and si.wProcessorArchitecture is
* PROCESSOR_ARCHITECTURE_AMD64 (which is 9)
* If it is, the operating system is Windows XP 64 bit;
* otherwise, it is Windows Server 2003."
*/
if(ver.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
sprops.os_name = "Windows XP"; /* 64 bit */
} else {
sprops.os_name = "Windows 2003";
}
break;
default: sprops.os_name = "Windows NT (unknown)"; break;
}
} else if (ver.dwMajorVersion == 6) {
/*
* See table in MSDN OSVERSIONINFOEX documentation.
*/
if (ver.wProductType == VER_NT_WORKSTATION) {
switch (ver.dwMinorVersion) {
case 0: sprops.os_name = "Windows Vista"; break;
case 1: sprops.os_name = "Windows 7"; break;
default: sprops.os_name = "Windows NT (unknown)";
}
} else {
switch (ver.dwMinorVersion) {
case 0: sprops.os_name = "Windows Server 2008"; break;
case 1: sprops.os_name = "Windows Server 2008 R2"; break;
default: sprops.os_name = "Windows NT (unknown)";
}
}
} else {
sprops.os_name = "Windows NT (unknown)";
}
break;
default:
sprops.os_name = "Windows (unknown)";
break;
}
In any case, nobody's arguing that os.name in Java is set incorrectly. The argument is that Java programs are using os.name incorrectly to make decisions. If this version of Windows was to be called Windows 9, that function would be (correctly) updated to return "Windows 9" and every Java program that did startsWith("Windows 9") would start misbehaving.
Which is awesome, but highlights another problem: even if MS inserted a special character between "Windows" and "9", it needs to count on all intermediate libraries/platforms to do the same.
What I mean is, for a user-land program to break, all it needs is that the platform underneath it identifies "Windows(r) 9", whose version is 6.3 as "Windows 9". Maybe they also thought it was too much to count on everyone reporting it as "Windows(r) 9"?
For something as big as Java I'm sure that's easily communicable. Maybe less so with the breadth of libraries and platforms available..
http://jonisalonen.com/2013/where-java-system-properties-com...
And this code:
http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/tip/src/share/...
Java asks for number and derives OS name from it.