80 likes | 259 Views
New I/O (JSR 51). Robert “Rock” Howard Chief Technology Officer Tower Technology. New Features. Scalable Network I/O High Performance File I/O Pluggable Characters Sets Character conversion Regular Expressions Features considered but not included: Formatting and scanning
E N D
New I/O (JSR 51) Robert “Rock” Howard Chief Technology Officer Tower Technology
New Features • Scalable Network I/O • High Performance File I/O • Pluggable Characters Sets • Character conversion • Regular Expressions • Features considered but not included: • Formatting and scanning • Improved filesystem interface
New Abstractions • Channels • Connections for I/O • Buffers • Containers for primitive data • Charsets (decoders, encoders) • Pattern Matchers • Selectors • Selectable channels
Channels • Defined by interface classes • Reading, writing • Inherit both for bi-directional I/O • Asynchronous Closing and Interruption Defined methods are a grab bag of utilities for buffer manipulation.
Buffers • Based on primitive types • For int, long, float, double, char, etc. • On Heap or else managed directly (not GC’d) • Memory mapped files are allowed • Indexes are managed wrt. # of primitives • Big or little endian hidden in implementation • Nice set of operators for manipulating buffers (reading, writing, managing indices, etc.)
Random Notes: New I/O • Buffer operations return the buffer so that they can be “chained”: • MyIntbuffer.clear().write(17); • Selector allows monitoring of many channels via a single thread • Old I/O unchanged and retained in entirety
Random Notes: JDK 1.4 • The thread stack size can be set via a new Thread constructor • JVMPI and JVMDI (profiling and debugging interfaces) are being replaced • See JSRs for debugging, profiling, monitoring • New “Assert” capability can be enabled • Usage: assert expression ; • Optional Usage: assert expression : error_message ; • Generates AssertionError if triggered • Make sure there are no side effects in assert expression!
Conclusion The new I/O mechanism is sufficiently powerful and scalable that I expect all major commercial Java frameworks to be rewritten for them within 6 to 12 months. The APIs are simple enough that you can pick them up in about one day of concentrated effort. Go For It!