NIO 1.4 RC Changes

# NIO APIs:
1.4 RC Changes

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
> - Channels (general)
> - File channels
> - Other

> Buffers

> - Revised the type-specific buffer classes (`ByteBuffer`, `CharBuffer`, etc.) to implement the `Comparable` interface. They already defined the necessary `compareTo` methods.

> - Revised the type-specific buffer classes to make it impossible to access the backing array of a non-direct heap buffer. Invoking the `hasArray` method of such a buffer will always return `false`. Invoking the `array` or `arrayOffset` methods of such a buffer will cause a `ReadOnlyBufferException` to be thrown.

> Channels (general)

> - Revised the `Channel` interface by moving the functionality of asynchronous closing and interruption to the new interface `InterruptibleChannel`, renamed the SPI class `AbstractChannel` to `AbstractInterruptibleChannel`, and revised that class to implement `InterruptibleChannel`. As a consequence of these changes all of the public channel classes now implement the new interface, while methods such as `Channels.newChannel` can return channels that are readable or writable but not necessarily interruptible.

> - Revised the `Pipe.SourceChannel` class to implement the `ScatteringByteChannel` interface, and revised the `Pipe.SinkChannel` class to implement the `GatheringByteChannel` interface.

> - Revised the `read` methods of the `GatheringByteChannel` interface and the `write` methods of the `ScatteringByteChannel` interface to return `long` rather than `int` byte counts. Corresponding changes were also made to the `DatagramChannel`, `FileChannel`, and `SocketChannel` classes.

> File channels

> - Revised the `transferTo` and `transferFrom` methods to take `long` rather than `int` `count` parameters, and to return `long` rather than `int` byte counts, so that they can be used to transfer large files. Revised the `map` method'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 `SecurityException` if 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 static` fields in `CodingErrorAction` to be `final`.

Copyright © 2002 Sun Microsystems, Inc. All Rights Reserved. Please send comments to: java-io@java.sun.com | Java Software