| # Enhancements in Packages java.lang.* and java.util.* | Contents

- Enhancements in Java SE 6
- Enhancements in J2SE 5.0
- Enhancements in J2SDK 1.4
- Enhancements in J2SDK 1.3

## Enhancements in Java SE 6

### java.util

- ServiceLoader - A facility to load a specific implementation of a service.
- Collections Framework Enhancements - There are many enhancements to the Collections framework.

## Enhancements in J2SE 5.0

### java.lang

- ProcessBuilder - The new `ProcessBuilder` class provides a more convenient way to invoke subprocesses than does Runtime.exec. In particular, ProcessBuilder makes it easy to start a subprocess with a modified process environment (that is, one based on the parent's process environment, but with a few changes).
- Threads - The `java.lang.Thread` class has the following enhancements:
  - Thread priority handling has changed.
  - `Thread.State` enum class and the new `getState()` API are provided for querying the execution state of a thread.
  - The new thread dump API - The `getStackTrace` and `getAllStackTraces` methods in the `Thread` class - provides a programmatic way to obtain the stack trace of a thread or all threads.
  - The `uncaughtExceptionHandler` mechanism, previously available only through the ThreadGroup class, is now available directly through the Thread class.
  - A new form of the `sleep()` method is provided which allows for sleep times smaller than one millisecond.

### java.lang.instrument

- Instrumentation - The new `java.lang.instrument` package provides services that allow Java programming agents to instrument programs running on the Java virtual machine by modifying methods' bytecodes at runtime.

### java.util

- Formatter - An interpreter for printf-style format strings, the `Formatter` class provides support for layout justification and alignment, common formats for numeric, string, and date/time data, and locale-specific output. Common Java types such as `byte`, `java.math.BigDecimal` , and `java.util.Calendar` are supported. Limited formatting customization for arbitrary user types is provided through the `java.util.Formattable` interface.
- Scanner - The `java.util.Scanner` class can be used to convert text into primitives or `String`s. Since it is based on the `java.util.regex` package, it also offers a way to conduct regular expression based searches on streams, file data, strings, or implementors of the `Readable` interface.
- Collections Framework Enhancements - There are many enhancements to the Collections framework.

## Enhancements in Java 2 SDK v1.4

### java.lang

- Chained Exception Facility - This is a new facility that provides a common API to record the fact that one exception caused another, to access causative exceptions, and to acess the entire "causal chain" as part of the standard stack backtrace, ensuring that preexisting programs will provide this information with no additional effort on the part of their authors.
- String - Two `split` methods are new. The `subSequence` method has been added, as required by the `CharSequence` interface that `String` now implements. Three additional methods have been added: `matches`, `replaceAll`, and `replaceFirst`.
- StringBuffer - The `subSequence` method has been added, as required by the `CharSequence` interface that `StringBuffer` now implements.
- Thread - The `interrupt` method has been revised to interrupt threads blocked in channel-I/O operations.

### java.util.logging

- Logging API - The Java Logging API facilitates software servicing and maintenance at customer sites by producing log reports suitable for analysis by end users, system administrators, field service engineers, and software development teams. The Logging APIs capture information such as security failures, configuration errors, performance bottlenecks, and/or bugs in the application or platform. The core package includes support for delivering plain text or XML formatted log records to memory, output streams, consoles, files, and sockets. In addition, the logging APIs are capable of interacting with logging services that already exist on the host operating system.

### java.util.prefs

- Preferences API - The preferences API, implemented by package `java.util.prefs`, allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store. The Preferences API is intended to replace most common uses of class `java.util.Properties`, rectifying many of its deficiencies, while retaining its light weight.

## Enhancements in Java 2 SDK 1.3

### java.lang

- java.lang.Math and java.lang.StrictMath - Two new classes which provide APIs for performing general numeric operations.
  - `java.lang.StrictMath` - Class `java.lang.StrictMath` has the same API as old class `java.lang.Math`, which was present in previous versions of the Java platform. Unlike class `Math`, however, `StrictMath` is defined to return bit-for-bit reproducible results in all implementations.
  - `java.lang.Math` - Class `java.lang.Math` provides the same set of API as does class `StrictMath`. However, unlike some of the numeric functions of class `StrictMath`, all implementations of the equivalent functions of class `Math` are not defined to return the bit-for-bit same results, but can vary within specified constraints. This permits better-performing implementations where strict reproducibility is not required.
- Timer API - Two new classes to provide an API for a timer facility which can be used for purposes such as animations, human interaction timeouts, on-screen clocks and calendars, work-scheduling routines, reminder facilities, and more.
  - `java.util.Timer`
  - `java.util.TimerTask`
  `Countdown.java` is a simple demo application that uses the Timer API.
- Virtual Machine Shutdown Hooks Sophisticated applications often require the ability to perform specific actions when the virtual machine shuts down, whether due to voluntary exit or involuntary termination. Typical actions include cleanly closing down network connections, saving session state, and deleting temporary files. Every major operating system provides the means for native applications to do this, though of course the details vary from platform to platform. Three methods have been added to `java.lang.Runtime` to provide a simple and portable interface to these facitilies. The new methods are:
  - `addShutdownHook`
  - `removeShutdownHook`
  - `halt`
  In addition, the `Runtime.exit` method has been revised. For more information, see Design of the Shutdown Hooks API.

### java.util

- Enhanced Collections Framework - The Collections Framework has these new convenience APIs:
  - Added Collections.singletonList and Collections.singletonMap. Previously, there was a convenience implementation for singleton Set, but no corresponding implementation for List and Map. Both of these implementations proved desirable in practice.
  - Added Collections.EMPTY_MAP. Previously, there were constant convenience implementations for the empty Set and List, but no corresponding implementation for Map.
  The following special-purpose implementation has also been added:
  - Added Map constuctor for WeakHashMap. The Map interface dictates that most Map implementations should have a "copy constructor" that takes a Map argument. WeakHashMap lacked such a constructor in the 1.2 release.

### java.util.jar
java.util.zip

- New URL JAR File Caching - The API of classes `java.util.zip` and `java.util.jar` have been enhanced with the addition of the following:
  - `java.util.zip.OPEN_READ`
  - `java.util.zip.OPEN_DELETE`
  - `java.util.zip.ZipFile(File file, int mode)`
  - `java.util.jar.JarFile(File file, boolean verify, int mode)`
  The previous implementation of caching downloaded Jar files created problems for long-running server application and for RMI. Each open `JarURLConnection` creates a temporary local file that holds Jar-file date, and a JarFile object is created on top of the temporary file. Because the open file handle/descriptor on each temporary file was never closed, the files could quickly take up disk space for long-running server applications. The new API provides a solution for this problem by supporting a new "delete-on-close" mode for opening Zip and Jar files.

Copyright © 1999-2006 Sun Microsystems, Inc. All Rights Reserved. |