There are several improvements to the standard
java.nio.charset.Charset) and extended charset
implementations. They include:
SelectorProvider implementation for Solaris based on the Solaris event port mechanism. This
SelectorProvider may improve performance or scalability for some server workloads. The
/dev/poll SelectorProvider continues to be the default. To use the Solaris event port mechanism, run with the system property
java.nio.channels.spi.Selector set to the value
Decrease in the size of <JDK_HOME>/jre/lib/charsets.jar file
Performance improvement for the
*) constructor and the
package and its related package,
provide comprehensive support for file I/O and for accessing the
file system. A zip file system provider is also available in JDK 7.
The following resources provide more information:
<Java home>/sample/nio/chatserver/contains samples that demonstrate the new APIs contained in the
<Java home>/demo/nio/zipfs/contains samples that demonstrate the NIO.2 NFS (Network File System) file system
In addition, the following enhancement is introduced:
Standard/Platform: JDK 7
Synopsis: Prior to the JDK 7 release, direct buffers allocated using java.nio.ByteBuffer.allocateDirect(int) were aligned on a page boundary. In JDK 7, the implementation has changed so that direct buffers are no longer page aligned. This should reduce the memory requirements of applications that create lots of small buffers.
One new class is provided:
Console- Contains methods to access a character-based console device. The
readPassword()methods disable echoing thus they are suitable for retrieval of sensitive data such as passwords. The method
System.console()returns the unique console associated with the Java Virtual Machine.
The following new methods were added to
setWritable(boolean writable, boolean ownerOnly)and
setWritable(boolean writable)set the owner's or everybody's write permission
setReadable(boolean readable, boolean ownerOnly)and
setReadable(boolean readable)set the owner's or everybody's read permission
setExecutable(boolean executable, boolean ownerOnly)and
setExecutable(boolean executable)set the owner's or everybody's execute permission
canExecute()tests the value of the execute permission
Constructors were added to the following class:
IOExceptionsupports exception chaining via the addition of the new constructors
The behavior of the following method was modified:
File.isFile()Windows implementation has been modified to always return
falsefor reserved device names such as CON, NUL, AUX, LPT, etc. Previously it returned
true, which customers considered a bug because it was inconsistent with behavior for devices on UNIX.
java.nio.channels.SelectorProviderimplementation that is based on the Linux epoll event notification facility is included. The epoll facility is available in the Linux 2.6, and newer, kernels. The new epoll-based
SelectorProviderimplementation is more scalable than the traditional poll-based
SelectorProviderimplementation when there are thousands of
SelectableChannels registered with a
Selector. The new
SelectorProviderimplementation will be used by default when the 2.6 kernel is detected. The poll-based
SelectorProviderwill be used when a pre-2.6 kernel is detected.
java.nio.channels.FileChannel.lock()checks whether regions are locked by other instances of
FileChannel. Unless this system property is set to
FileChannel.lock()will throw an
OverlappingFileLockExceptionif an application attempts to lock a region that overlaps one that is locked by another instance of
FileChannel. The system property exists to provide compatibility with previous releases which do not implement the JVM-wide overlapping file lock check.
javax.net.ssl.SSLEnginewas added. The existing J2SDK 1.4.0 secure communication infrastructure,
javax.net.ssl.SSLSocket, was based on the I/O model of java.net.Socket. The
SSLEngineclass abstracts away the I/O model, and leaves developers free to secure communication pathways using alternate types of I/O.
SSLEnginecan be combined with the New I/O APIs to create implementations such as secure blocking or non-blocking
SocketChannels. For details see the JSSE Reference Guide.
getChannelmethods have been added to return the underlying
FileChannelobject, and the
closemethods have been revised to close the underlying channel.
getChannelmethod has been added and the
closemethod has been revised to close the underlying channel. The
RandomAccessFileconstructors now support the mode characters "s" and "d" to allow the specification, at file-open time, of synchronous writes or synchronous-data writes.
OutputStreamWriterclasses, constructors have been added that take a stream and a
Charsetobject, and the
getEncodingmethods have been revised to return the historical name of the encoding being used. Constructors to
OutputStreamWriterhave been added that take existing