The following topics are covered:
In addition, the following enhancements are introduced:
Area: API: Language
Standard/Platform: Java SE 7
Synopsis: Class loading can be prone to deadlocks if custom
class loaders do not adhere to an acyclic class loader delegation
model. New APIs have been added to the
java.lang.ClassLoader class to support parallel loading of
classes and finer-grained locking mechanism for class loading
operations. Custom class loaders which would like to leverage this
functionality must refer to the
Class Loader API Modifications for Deadlock Fix documentation
for the suggested model and requirements and be implemented
accordingly.
Area: API: Language
Standard/Platform: JDK 7
Synopsis: Previously, the two exception types in the
javax.lang.model.type package,
MirroredTypeException and MirroredTypesException,
were unrelated. In the javac implementation,
MirroredTypeException was thrown where
MirroredTypesException should have been thrown. In part to
address this problem, MirroredTypeException was made a
subclass of MirroredTypesException. This change is binary
compatible and generally preserves the behavior of existing
annotation processors. However, it is possible this change may
cause source incompatibilities for client programs; in those cases,
changing the order of catch clauses should allow the programs to
compile again.
Area: API: Language
Standard/Platform: JDK 7
Synopsis: To model the language changes in this release,
several updates were made to javax.lang.model.* including
adding a method to the javax.lang.model.type.TypeVisitor
interface. Such an addition is source incompatible with libraries
that have directly implemented the TypeVisitor interface.
However, such additions were foreseen as part of this API's
evolution and libraries were explicitly cautioned to extend one of
the utility visitors instead of directly implementing such an
interface.
RFE: 6933147
Area: API: Utilities
Standard/Platform: JDK 7
Synopsis: Due to an error in java.util.TreeMap, it
was previously possible to insert invalid null elements and
elements not implementing Comparable into empty
TreeMaps and TreeSets. Only a single invalid
element could be inserted into the empty TreeMaps or
TreeSets; additional elements would cause the expected
NullPointerException or ClassCastException. Most
other operations upon the collection would also fail. As of JDK 7,
inserting an invalid null element or an element not implementing
Comparable into an empty TreeMap or
TreeSet throws a NullPointerException.
RFE: 5045147
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).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.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.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.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
.subSequence
method has been added, as required
by the CharSequence
interface that
StringBuffer
now implements.interrupt
method has been revised to interrupt
threads blocked in channel-I/O operations.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.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.Countdown.java
is a
simple demo application that uses the Timer API.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.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)
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.