Code Review for jdk

Prepared by:simonis on Tue Jan 14 09:29:48 CET 2014
Workspace:/net/usr.work/d046063/OpenJDK/ppc-aix-port/stage-9/jdk
Compare against: http://hg.openjdk.java.net/ppc-aix-port/stage-9/jdk
Compare against version:8974
Summary of changes: 450 lines changed: 406 ins; 15 del; 29 mod; 12054 unchg
Changeset: jdk.changeset
Bug id: JDK-8031581 : PPC64: Addons and fixes for AIX to pass the jdk regression tests
Author comments:

src/share/native/java/util/zip/zip_util.c
src/share/native/sun/management/DiagnosticCommandImpl.c

  • According to ISO C it is perfectly legel for malloc to return zero if called with a zero argument. Fix various places where malloc can potentially correctly return zero because it was called with a zero argument.
  • Also fixed DiagnosticCommandImpl.c to include stdlib.h. This only fixes a compiler warning on Linux, but on AIX it prevents a VM crash later on because the return value of malloc() will be casted to int which is espacially bad if that pointer was bigger than 32-bit.

make/CompileJavaClasses.gmk

  • Also use PollingWatchService on AIX.

make/lib/NioLibraries.gmk
src/aix/native/sun/nio/ch/AixNativeThread.c

  • Put the implementation for the native methods of NativeThread into AixNativeThread.c on AIX.

src/solaris/native/sun/nio/ch/PollArrayWrapper.c
src/solaris/native/sun/nio/ch/Net.c
src/aix/classes/sun/nio/ch/AixPollPort.java
src/aix/native/sun/nio/ch/AixPollPort.c
src/aix/native/java/net/aix_close.c

  • On AIX, the constants used for the polling events (i.e. POLLIN, POLLOUT, ...) are defined to different values than on other operating systems. The problem is however, that these constants are hardcoded as public final static members of various, shared Java classes. We therefore have to map them from Java to native everytime before calling one of the native poll functions and back to Java after the call on AIX in order to get the right semantics.

src/share/classes/java/nio/file/CopyMoveHelper.java

  • As discussed on the core-libs mailing list (see http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-December/024119.html) it is not necessary to call Files.getFileAttributeView() with any linkOptions because at that place we've already checked that the target file can not be a symbolic link. This change makes the implementation more robust on platforms which support symbolic links but do not support the O_NOFOLLOW flag to the open system call. It also makes the JDK pass the demo/zipfs/basic.sh test on AIX.

src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java

  • Support "compound text" on AIX in the same way like on other Unix platforms.

src/share/classes/sun/tools/attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider

  • Define the correct attach provider for AIX.

src/solaris/native/java/net/net_util_md.h
src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c

  • AIX needs a workaround for I/O cancellation (see: http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm). "..The close() subroutine is blocked until all subroutines which use the file descriptor return to usr space. For example, when a thread is calling close and another thread is calling select with the same file descriptor, the close subroutine does not return until the select call returns...". To fix this problem, we have to use the various NET_ wrappers which are declared in net_util_md.h and defined in aix_close.c and we also need some additional wrappers for fcntl(), read() and write() on AIX.
    While the current solution isn't really nice because it introduces some more AIX-specifc sections in shared code, I think it is the best way to go for JDK 8 because it imposes the smallest possible changes and riscs for the existing platfroms. I'm ready to change the code to unconditionally use the wrappers for all platfroms and implement the wrappers empty on platfroms which don't need any wrapping. I think it would also be nice to clean up the names (e.g. NET_Read() is currently a wrapper for recv() and the NET_ prefix is probably not appropriate anymore so maybe change it to something like IO_). But again, I'll prefer to keep that as a follow up change for JDK9.
  • Calling fsync() on a "read-only" file descriptor on AIX will result in an error (i.e. "EBADF: The FileDescriptor parameter is not a valid file descriptor open for writing."). To prevent this error we have to query if the corresponding file descriptor is writable. Notice that at that point we can not access the writable attribute of the corresponding file channel so we have to use fcntl().

src/solaris/classes/java/lang/UNIXProcess.java.aix

  • On AIX the implementation is especially tricky, because the close() system call will block if another thread is at the same time blocked in a file operation (e.g. 'read()') on the same file descriptor. We therefore combine the AIX ProcessPipeInputStream implemenatation with the DeferredCloseInputStream approach used on Solaris (see UNIXProcess.java.solaris). This means that every potentially blocking operation on the file descriptor increments a counter before it is executed and decrements it once it finishes. The 'close()' operation will only be executed if there are no pending operations. Otherwise it is deferred after the last pending operation has finished.

src/share/transport/socket/socketTransport.c

  • On AIX we have to call shutdown() on a socket descriptor before closing it, otherwise the close() call may be blocked. This is the same problem as described before. Unfortunately the JDI framework doesn't use the same IO wrappers like other class library components so we can not easily use the NET_ abstractions from aix_close.c here.
  • Without this small change all JDI regression tests will fail on AIX because of the way how the tests act as a "debugger" which launches another VM (the "debugge") which connects itself back to the debugger. In this scenario the "debugge" can not shut down itself because one thread will always be blocked in the close() call on one of the communication sockets.

src/solaris/native/java/net/NetworkInterface.c

  • Set the scope identifier for IPv6 addresses on AIX.

src/solaris/native/java/net/net_util_md.c

  • It turns out that we do not always have to replace SO_REUSEADDR on AIX by SO_REUSEPORT. Instead we can simply use the same approch like BSD and only use SO_REUSEPORT additionally, if several datagramm sockets try to bind to the same port.
  • Also fixed a comment and removed unused local variables.
  • Fixed the obviously inverted assignement newTime = prevTime; which should read prevTime = newTime;. Otherwise prevTime will never change and the timout will be potentiall reached too fast.

src/solaris/native/sun/management/OperatingSystemImpl.c

  • AIX does not understand /proc/self so we have to query the real process ID to access the proc file system.

src/solaris/native/sun/nio/ch/DatagramChannelImpl.c

  • On AIX, connect() may legally return EAFNOSUPPORT if called on a socket with the address family set to AF_UNSPEC.
Legend: Modified file
Deleted file
New file

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw make/CompileJavaClasses.gmk

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
2 lines changed: 0 ins; 0 del; 2 mod; 453 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw make/lib/NioLibraries.gmk

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
1 line changed: 0 ins; 0 del; 1 mod; 204 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/aix/classes/sun/nio/ch/AixPollPort.java

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
31 lines changed: 28 ins; 0 del; 3 mod; 533 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/aix/native/java/net/aix_close.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
74 lines changed: 63 ins; 6 del; 5 mod; 416 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/aix/native/sun/nio/ch/AixPollPort.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
2 lines changed: 0 ins; 0 del; 2 mod; 173 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/share/classes/java/nio/file/CopyMoveHelper.java

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
1 line changed: 0 ins; 0 del; 1 mod; 159 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
1 line changed: 0 ins; 0 del; 1 mod; 1316 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/share/classes/sun/tools/attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
1 line changed: 1 ins; 0 del; 0 mod; 33 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/share/native/java/util/zip/zip_util.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
4 lines changed: 3 ins; 0 del; 1 mod; 1461 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/share/native/sun/management/DiagnosticCommandImpl.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
6 lines changed: 2 ins; 0 del; 4 mod; 165 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/share/transport/socket/socketTransport.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
13 lines changed: 13 ins; 0 del; 0 mod; 744 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/classes/java/lang/UNIXProcess.java.aix

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
86 lines changed: 85 ins; 0 del; 1 mod; 418 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/java/net/NetworkInterface.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
6 lines changed: 5 ins; 0 del; 1 mod; 2167 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/java/net/net_util_md.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
15 lines changed: 3 ins; 9 del; 3 mod; 1671 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/java/net/net_util_md.h

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
13 lines changed: 12 ins; 0 del; 1 mod; 163 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/sun/management/OperatingSystemImpl.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
10 lines changed: 9 ins; 0 del; 1 mod; 466 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/sun/nio/ch/DatagramChannelImpl.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
9 lines changed: 8 ins; 0 del; 1 mod; 242 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/sun/nio/ch/FileDispatcherImpl.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
48 lines changed: 48 ins; 0 del; 0 mod; 265 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/sun/nio/ch/Net.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
22 lines changed: 21 ins; 0 del; 1 mod; 786 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/sun/nio/ch/PollArrayWrapper.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
21 lines changed: 21 ins; 0 del; 0 mod; 102 unchg

Cdiffs Udiffs Sdiffs Frames Old New ----- Raw src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
8 lines changed: 8 ins; 0 del; 0 mod; 117 unchg

------ ------ ------ ------ --- New ----- Raw src/aix/native/sun/nio/ch/AixNativeThread.c

rev 8975 : 8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
76 lines changed: 76 ins; 0 del; 0 mod; 0 unchg

This code review page was prepared using /net/usr.work/d046063/OpenJDK/ppc-aix-port/stage-9/make/scripts/webrev.ksh (vers 25.1-hg+openjdk.java.net).