Enhancements in Packages java.lang.* and java.util.*

The following topics are covered:

Enhancements in Java SE 7

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: Language
Standard/Platform: JDK 7
Synopsis: The method Runtime.exec(String command, String[] envp, File dir) breaks the command string into tokens, consisting of the name of the executable and its arguments, by the invocation new StringTokenizer(command) with the default delimiter set (the space character, the tab character, the newline character, the carriage-return character, and the form-feed character). Essentially, this method splits the command string into tokens, using white space as the delimiter.

On Windows operating systems, splitting the command parameter by white spaces can lead to errors. In particular, if the command parameter contains an executable path with spaces, the invocation new StringTokenizer(command) extracts the wrong executable name. For example, the invocation Runtime.getRuntime().exec("C:\\My Programs\\foo.exe bar") attempts to launch the program C:\My with the arguments Programs\foo.exe and bar. This invocation is likely to fail with an exception to indicate that the executable C:\My cannot be found.

If your legacy application is not using a security manager (see the class SecurityManager), you can specify the system property jdk.lang.Process.allowAmbiguousCommands with any value other than false so that the method Runtime.exec correctly parses path names with spaces. (See System Properties in The Java Tutorials.) Alternatively, you can surround the path name with quotation marks. For example, the invocation Runtime.getRuntime().exec("\"C:\\My Programs\\foo.exe\" bar") attempts to launch C:\My Programs\foo.exe with the argument bar.

Note: For JDK 7u21 and 7u25, the name of the system property to allow ambiguous commands is jdk.lang.Process.allowAmbigousCommands.

However, you must enclose a path name in quotation marks if you are trying to execute a batch (.bat) or command (.cmd) file (on Windows operating systems) by invoking Runtime.getRuntime().exec(<path to batch or command file>), and the path to that file contains any of the following special characters:


You can do this as follows, where the variable f is an instance of the class File:

Process p = Runtime.getRuntime()
    .exec(new String[]{"\"" + f.getAbsolutePath() + "\""},
        null, f.getParentFile());

This is because the Win32 CreateProcess invocation redirects .bat and .cmd files to the cmd /C command processor, which executes them. The cmd /C command requires paths that contains any of the special characters mentioned previously be enclosed in quotation marks.

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

Enhancements in Java SE 6


Enhancements in J2SE 5.0




Enhancements in Java 2 SDK v1.4




Enhancements in Java 2 SDK 1.3




Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.