Enhancements in
|
Contents |
J2SE Development Kit 5.0 has several enhancments in the
java.lang.*
and java.util.*
packages, including:
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).
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.
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.
java.util.concurrent
,
java.util.concurrent.atomic
,
and java.util.concurrent.locks
packages provide a extensible framework of high-performance, scalable, thread-safe building
blocks for developing concurrent classes and applications, including thread
pools, thread-safe collections, semaphores, a task scheduling framework,
task synchronization utilities, atomic variables, and locks. Additionally, these packages
provide low-level primitives for advanced concurrent programming which take
advantage of concurrency support provided by the processor, enabling
you to implement high-performance, highly scalable concurrent
algorithms in Java to a degree not previously possible without using native code.
For more information, refer to JSR 166 .
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.lang.Thread
class has the following enhancements:
Thread.State
enum class and the new
getState()
API are provided for querying the execution state of a thread.getStackTrace
and
getAllStackTraces
methods
in the Thread
class - provides
a programmatic way to obtain the stack trace of a thread or all threads.uncaughtExceptionHandler
mechanism, previously available only through the ThreadGroup
class, is now available directly through the Thread class.sleep()
method is provided which allows
for sleep times smaller than one millisecond.
Java 2 SDK v1.4 offered several significant enhancements to the
functionality in the java.lang.*
and java.util.*
packages, including
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.
java.util.regex
contains classes for matching character sequences against patterns
specified by regular expressions.
Version 1.3 of the Java 2 SDK includes the following enhancements:
The Java 2 Platform now contains two clases which provide API for performing general numeric operations.
Two new classes have been added to the Java 2 Platform 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.
Countdown.java is a simple demo application that uses the new Timer API.
The Collections Framework has these new convenience APIs:
The following special-purpose implementation has also been added:
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:
In addition, the Runtime.exit method has been revised. For more information, see Design of the Shutdown Hooks API.
The API of classes java.util.zip and java.util.jar have been enhanced with the addition of the following:
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-2004
Sun Microsystems, Inc.
All Rights Reserved.
|