Collections Framework Enhancements
The purpose of changes in this API is to provide better bi-directional collection access.
These new collection interfaces are provided:
- Deque
- a double ended queue, supporting element insertion and
removal at both ends. Extends the Queue interface.
- BlockingDeque
- a Deque with operations that wait for the deque to
become non-empty when retrieving an element, and wait for space to
become available in the deque when storing an element. Extends both
the Deque
and BlockingQueue
interfaces. (This interface is part of java.util.concurrent.)
- NavigableSet -
a SortedSet extended with navigation methods reporting
closest matches for given search targets. A NavigableSet
may be accessed and traversed in either ascending or descending
order. This interface is intended to supersede the
SortedSet interface.
- NavigableMap -
a SortedMap extended with navigation methods returning the
closest matches for given search targets. A NavigableMap
may be accessed and traversed in either ascending or descending key
order. This interface is intended to supersede the
SortedMap interface.
- ConcurrentNavigableMap
- a ConcurrentMap that is also a NavigableMap.
(This interface is part of java.util.concurrent.)
The following concrete implementation classes have been
added:
These existing classes have been retrofitted to implement new
interfaces:
- LinkedList -
retrofitted to implement the Deque interface.
- TreeSet -
retrofitted to implement the NavigableSet interface.
- TreeMap -
retrofitted to implement the NavigableMap interface.
Two new methods were added to the
Collections utility
class:
The
Arrays utility class now has methods
copyOf
and
copyOfRange that can efficiently resize, truncate, or copy
subarrays for arrays of all types.
Before:
int[] newArray = new int[newLength];
System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
After:
int[] newArray = Arrays.copyOf(a, newLength);
2. Java Web Start and Java Plug-in Common
Enhancements
Cache
and System Format
The format of the cache is completely changed and should never
be assumed. Any existing code using the previous cache format for
Java Web Start or Java Plug-in will no longer work. Existing
applications in the Java Web Start cache will be upgraded and
converted to the new cache format the first time you run a Java Web
Start application, or if you launch the cache viewer using
javaws -viewer.
The system cache will be upgraded and converted to the new
format the first time you launch Java Web Start in system mode, or
if you just launch
javaws -system.
Download Engine and Cache
Consolidation
The caching mechanism and download engine are redesigned and
consolidated between Java Web Start and Java Plug-in. This brings
several new features to Java Web Start, previously available only
in Java Plug-in and vice versa. They are :
- Caching can be disabled using the Java Control Panel.
- Java Web Start honors the maximum cache size set using Java
Control Panel.
- Java Web Start can start a cleanup thread to remove Least
Recently Used(LRU) items from the cache when approaching the
maximum cache size.
- The
<no-cache>
directive is now supported.
When the no-cache directive is used , an update check is made to
make sure the cached contents are same as at the URL. The resource
is then downloaded into the cache and the expiration field is
ignored.
- The expiration-date is supported. If a downloaded resource
contains an expiration date, it will not be used after that
date.
Secure
Versioning
In Java SE 6 unsigned Java Web Start applications that specify a
version other than the latest one will trigger a security warning,
requiring explicit user permission before the application will run.
Signed Java Web Start applications are not affected.
Other
Enhancements
Java Web Start and Java Plug-in now support CRL (Certificate
Revocation Lists) and OCSP (Online Certificate Status Protocol) for
verifying the certificates.
Java Control Panel provides an option to select the default SSL
handshaking protocol. The default is set to SSLv3 and SSLv2. You
can also change it to TSL.
The Java Console is excluded from modality. By using the new
modality features of AWT in Java 6, you can interact with Java
Console even when your application is displaying a modal
dialog.
All dialogs and screens of Java Web Start and Java Plug-in are
redesigned to be more user friendly, intuitive, and accessible.
3. Internationalization Support
Internationalization is the process of designing an application
so that it can be adapted to various languages and regions without
engineering changes. Sometimes the term internationalization is
abbreviated as i18n, because there are 18 letters between the first
"i" and the last "n."
An internationalized program has the following
characteristics:
- With the addition of localization data, the same executable can
run worldwide.
- Textual elements, such as status messages and the GUI component
labels, are not hardcoded in the program. Instead they are stored
outside the source code and retrieved dynamically.
- Support for new languages does not require recompilation.
- Culturally-dependent data, such as dates and currencies, appear
in formats that conform to the end user's region and language.
- It can be localized quickly.
4. IO Support
java.io
One new class is provided:
Console
-
Contains methods to access a character-based console device. The
readPassword()
methods disable echoing thus they are
suitable for retrieval of sensitive data such as passwords. The
method System.console()
returns the unique console associated with the Java Virtual
Machine.
The following new methods were added to
File
:
- Methods to retrieve disk usage information:
getTotalSpace()
returns the size of the partition in bytes
getFreeSpace()
returns the number of unallocated bytes in the partition
getUsableSpace()
returns the number of bytes available on the partition and includes
checks for write permissions and other operating system
restrictions
- Methods to set or query file permissions:
Constructors were added to the following class:
The behavior of the following method was modified:
- The
File.isFile()
Windows implementation has been modified to always return
false
for reserved device names such as CON, NUL, AUX,
LPT, etc. Previously it returned true
, which customers
considered a bug because it was inconsistent with behavior for
devices on Unix.
java.nio
- A new
java.nio.channels.SelectorProvider
implementation that is based on the Linux epoll event notification
facility is included. The epoll facility is available in the Linux
2.6, and newer, kernels. The new epoll-based
SelectorProvider
implementation is more scalable than
the traditional poll-based SelectorProvider
implementation when there are thousands of SelectableChannel
s
registered with a Selector
.
The new SelectorProvider
implementation will be used
by default when the 2.6 kernel is detected. The poll-based
SelectorProvider
will be used when a pre-2.6 kernel is
detected.
- The system property
sun.nio.ch.disableSystemWideOverlappingFileLockCheck
controls whether java.nio.channels.FileChannel.lock()
checks whether regions are locked by other instances of
FileChannel
. Unless this system property is set to
true
, FileChannel.lock()
will throw an
OverlappingFileLockException
if an application attempts
to lock a region that overlaps one that is locked by another
instance of FileChannel
. The system property exists to
provide compatibility with previous releases which do not implement
the JVM-wide overlapping file lock check.