Original Java Specification Request (JSR)
Identification | Request | Contributions
Section 1. Identification
Submitting Participant: Sun Microsystems, Inc.
Name of Contact Person: Mark Reinhold
E-Mail Address: mr@eng.sun.com
Telephone Number: 408-343-1830
Fax Number: 408-343-1797
Section 2: Request
The proposed specification will define a set of new and improved I/O APIs for the Java Platform. Its major components will be:
For ease of use the new APIs will leverage the patterns of the existing I/O APIs when appropriate. Full interoperability with the current base stream classes will be supported.
In order to be efficient the new classes will be minimally synchronized, leaving it in nearly all cases for the caller to synchronize when necessary. To make this easy, synchronization "wrappers" similar to those in the Java platform's collections framework may be provided.
Efficiency will also be achieved by introducing a simple buffer-oriented I/O model consisting of basic streams of bytes and characters together with monolithic, highly-tuned classes that combine support for buffering, formatting, and parsing.
These APIs are intended to become part of the Java 2 Platform, Standard Edition.
The proposed specification will satisfy several long-standing needs of the Java community.
Some of the above needs can be met by using existing APIs together with a significant amount of custom code. It is possible, for example, to write a class that implements the DataInput interface and runs about eight times faster than the built-in DataInputStream class. The Java community would be better served if the Java platform made this sort of work unnecessary.
Some of the above needs can be met by using existing APIs in fragile, implementation-specific ways. To recover from specific types of I/O errors, for example, developers sometimes write code that dissects the message strings of generic IOException objects. This technique may work with a particular implementation of Java on a particular operating system, but it is not very portable. A different implementation on a different operating system may, in a given situation, throw an IOException object with a completely different message string.
Finally, most of the above needs cannot be met simply because the required functionality is not provided by the current I/O APIs.
The scalable I/O API, the binary I/O API, and the new filesystem interface will rely heavily upon services provided by the underlying operating system and hardware platform. To implement these components will require writing native code to interface to such services. We hope to keep the amount of native code to a minimum.
Aside from these components, we expect the bulk of an implementation will be pure Java code. Some of this code will of necessity be platform-specific, but most of it will be completely portable.
We propose to create one new package, java.nio, with additional subpackages as needed. Platform-specific APIs, if any, will be placed in com.sun.java.nio and subpackages thereof. These names are subject to change as the work progresses. A few classes and methods may be added to the existing java.io, java.lang, java.net, java.text, and java.util packages as appropriate.
The design of the new I/O APIs will be heavily influenced by the capabilities of the native APIs of a wide variety of systems. The resulting APIs are, however, intended to be completely platform independent.
No. Some new permissions will be defined, but the current security model is more than adequate.
The proposed character-set converter API will improve the Java platform's suitability for developing internationalized applications and will fulfill a long-standing need of the internationalization community.
The proposed parsing and formatting APIs present internationalization issues that have not yet been fully investigated.
We are not proposing to deprecate the current java.io APIs, but we do hope that most developers will eventually migrate to the new APIs.
The proposed parsing and formatting APIs will duplicate some of the functionality already provided by the java.text package. This duplication is acceptable because the new APIs are intended to be efficient and easy to use for common, simple situations, while the java.text APIs were designed for maximal generality and flexibility.
Section 3: Contributions
Sun has been working on an internal draft specification for several months now. This specification is not yet publicly available.
The draft specification can serve as a starting point for the work of the Expert Group. We expect to complete the draft by the time the Expert Group is formed.