|
NIO APIs:
|
New I/O APIs |
This document describes how the NIO APIs in the RC release of J2SE v 1.4 differ from those in Beta 3. The changes are summarized by area:Buffers
Revised the type-specific buffer classes (
ByteBuffer,CharBuffer, etc.) to implement theComparableinterface. They already defined the necessarycompareTomethods.Revised the type-specific buffer classes to make it impossible to access the backing array of a non-direct heap buffer. Invoking the
hasArraymethod of such a buffer will always return false. Invoking thearrayorarrayOffsetmethods of such a buffer will cause aReadOnlyBufferExceptionto be thrown.Channels (general)
Revised the
Channelinterface by moving the functionality of asynchronous closing and interruption to the new interfaceInterruptibleChannel, renamed the SPI class AbstractChannel toAbstractInterruptibleChannel, and revised that class to implementInterruptibleChannel. As a consequence of these changes all of the public channel classes now implement the new interface, while methods such asChannels.newChannelcan return channels that are readable or writable but not necessarily interruptible.Revised the
Pipe.SourceChannelclass to implement theScatteringByteChannelinterface, and revised thePipe.SinkChannelclass to implement theGatheringByteChannelinterface.Revised the
readmethods of theGatheringByteChannelinterface and thewritemethods of theScatteringByteChannelinterface to returnlongrather thanintbyte counts. Corresponding changes were also made to theDatagramChannel,FileChannel, andSocketChannelclasses.File channels
Revised the
transferToandtransferFrommethods to take long rather than intcountparameters, and to return long rather than int byte counts, so that they can be used to transfer large files. Revised themapmethod's size parameter to be long rather than int for consistency.Other
The changes described in this section were made in the 1.4 RC release but not described in this document until the 1.4 FCS release. For further details, see the JSR-51 Change Log.
- Added a security check to the CharsetProvider constructor. We defined a new runtime security permission, charsetProvider, and revised the CharsetProvider constructor to throw a
SecurityExceptionif the security manager refuses permission.
- Replaced the insecure CharsetProvider method putCharsets with a new method named
charsets. The new method creates an iterator for the charsets supported by the provider.
- Added a security check to the SelectorProvider constructor.
- Removed the setProvider method of SelectorProvider. Trusted code can still declare its own selector provider as the system-wide default by setting a system property on the command line or making a provider available as a service. (The specification of the provider method describes the lookup algorithm in detail.)
- Declared
public staticfields in CodingErrorAction to befinal.
|
Copyright © 2002 Sun Microsystems, Inc. All Rights Reserved. Please send comments to: java-io@java.sun.com |
Java Software |