RFR(M): 8031997: PPC64: Make the various POLL constants system dependant

Volker Simonis volker.simonis at gmail.com
Fri Jan 17 11:25:24 UTC 2014


Hi,

could you please review the following change which makes the various
POLL constants used in sun.nio.ch platform dependant:

http://cr.openjdk.java.net/~simonis/webrevs/8031997/

These changes are currently targeted for the ppc-aix-port/stage-9
repository but it is planned to merge them soon into jdk9 and
jdk8u-dev (for 8u20).

Currently, various constants used for the poll/epoll/pollset system
calls are defined multiple times as public static final short
constants in various Java files:

src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java
src/solaris/classes/sun/nio/ch/Port.java

Until now, this has not been a problem because on Linux, Solaris and
MacOSX these constants have the same values. However on Windows and
AIX they are different. While this hasn't been a problem on Windows
either, because as far as I can see, we don't directly use WSAPoll()
until now and the POLL constants are only used 'symbolically' on
Windows, it became a real problem for the AIX port.

To avoid a mapping of the Java constants to the native ones every time
we go from Java to Native and back, this change replaces the currently
used constants with a single instance of constants which is placed in
src/share/classes/sun/nio/ch/Net.java and which are dynamically
initialized from native methods with the correct, platfrom-specific
values.

So this change replaces every occurrence of POLL*, Port.POLL* or
AbstractPollArrayWrapper.POLL* in Java code with the corresponding
Net.POLL* constants. However, there's one exception to this rule: I
haven't changed the POLL constants in
src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java. That is not
only because DevPollArrayWrapper is Solaris-specific and only used
there, but mainly because it uses several, non-standard POLL constants
which are only available and meaningful on Solaris and I didn't wanted
to bloat the amount of generic constants defined in Net.java. I also
didn't updated the constants under src/solaris/demo/jni/Poller because
that's a Solaris-specific demo anyway.

With Windows, I was a little confused in the beginning. I think until
now we don't really use the WSAPoll() functionality there. That's
probably because it is only available since Windows Vista / Windows
Server 2008 (see
http://msdn.microsoft.com/en-us/library/windows/desktop/ms741669%28v=vs.85%29.aspx).
As far as I understand, the constants are only used "symbolically", to
drive the underlying, select() based implementation.

I've therefore decided to use the "true" POLL constants on Windows if
they are available. Otherwise I'll use the hard-wired (Solaris-based)
values. Another Windows peculiarity is the fact that POLLCONN is
defined with a value different to all other constants while it equals
to POLLOUT on the Unix platforms. I don't know if this is really
necessary, but I kept this behaviour in my change. Notice that his
change will allow us to directly used the WSAPoll() functionality on
Windows in the future.

I've compiled and smoke-tested the changes on Linux/x86_64/PPC64,
Windows/x86_64, Solaris/SPARC, MacOS X and AIX. On all these platforms
they pass all the java/nio JTREG tests in the same way like without
this change. This means that on Linux/MacOS they pass all 261/256
tests, on Windows, they pass 258 tests while the following two tests
fail:

java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
java/nio/channels/DatagramChannel/Promiscuous.java

But as I wrote before, these two test also fail without my changes
applied, so I'm confident that the failures aren't related to this
change. On Solaris, 258 test pass and only the
java/nio/charset/Charset/default.sh test fails which isn't related to
these changes either.

Thank you and best regards,
Volker



More information about the core-libs-dev mailing list