RFR: 8000975: (process) Merge UNIXProcess.java.bsd & UNIXProcess.java.linux (& .solaris & .aix) (original) (raw)

Peter Levart peter.levart at gmail.com
Tue Apr 1 14:48:23 UTC 2014


On 04/01/2014 03:26 PM, Rob McKenna wrote:

Hi Peter,

Yup, I'll give this a whirl. -Rob

Thanks Rob.

On 01/04/14 14:16, Peter Levart wrote: Hi Alan, Volker,

Thanks for sharing the info and for testing on AIX. Here's the updated webrev that hopefully includes the correct "dispatch on os.name" logic. I included "Solaris" as an alternative to "SunOS" since I saw this in some documents on Internet. If this is superfluous, I can remove it:

I checked the code that obtains the value for os.name system property in current OpenJDK. Here's the relevant part of src/solaris/native/java/lang/java_props_md.c:

#ifdef MACOSX setOSNameAndVersion(&sprops); #else struct utsname name; uname(&name); sprops.os_name = strdup(name.sysname); sprops.os_version = strdup(name.release); #endif

The uname() system function is used to obtain the OS name on all UNIXes except MACOSX, where a constant "Mac OS X" is used in src/solaris/native/java/lang/java_props_macosx.c:

void setOSNameAndVersion(java_props_t sprops) { / Don't rely on JRSCopyOSName because there's no guarantee the value will * remain the same, or even if the JRS functions will continue to be part of * Mac OS X. So hardcode os_name, and fill in os_version if we can. */ sprops->os_name = strdup("Mac OS X");

 void *jrsFwk = getJRSFramework();
 if (jrsFwk != NULL) {
     char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
     if (copyOSVersion != NULL) {
         sprops->os_version = copyOSVersion();
         return;
     }
 }
 sprops->os_version = strdup("Unknown");

}

The value of os.name for Linux is, I belive, always "Linux". The value for AIX is "AIX" and for Mac OS X is fixed to "Max OS X" at compile time. But what about all Solaris(es)? Thinking about OpenSolaris and forks... Would their uname() return "SunOS" too?

Regards, Peter

http://cr.openjdk.java.net/~plevart/jdk9-dev/UNIXProcess/webrev.03/ I tested this on Linux and Solaris and the java/lang/ProcessBuilder jtreg tests pass. So with Volker's test on AIX, the only OS platform left for testing is Mac OS X. Would someone volunteer? Regards, Peter On 03/27/2014 11:18 AM, Volker Simonis wrote: Hi Peter,

thanks for applying these changes to the AIX files as well. With the additional line: if (osName.equals("AIX")) { return AIX; } in Os.get() your change compiles cleanly on AIX and runs the java/lang/ProcessBuilder tests without any errors. So from an AIX perspective, thumbs up. Regards, Volker

On Wed, Mar 26, 2014 at 5:18 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote: On 26/03/2014 15:19, Peter Levart wrote: I couldn't find any official document about possible os.name values for different supported OSes. Does anyone have a pointer? I don't know if there is a definite list but I assume we don't need to be concerned with anything beyond the 4 that we have in OpenJDK, which is "Linux", "SunOS", "AIX" and contains("OS X"). If we get to the point in JDK 9 where src/solaris is renamed to src/unix (or something equivalent) then it could mean that the Os enum can be replaced with an OS specific class in src/linux, src/solaris, ... and this would avoid the need for an os.name check at runtime. -Alan.



More information about the core-libs-dev mailing list