http://www.developer.com/http://www.developer.com/java/5-more-project-coin-java-7-changes.html
Continuing the exploration of Java language features in JDK7 which I began in my previous installment on Project Coin, I will discuss the following Java 7 enhancements: This list is by no means complete; it serves only as a compilation of the features I find most notable. This is a tiny change when compared with other, exhaustive Java 7 language changes. Having said that, improved type interface for generic instance creation makes a big difference in the way Java code will be written. For example, consider the following declaration for a regionMap data structure, which dictates that the structure hold a key value pair with key as Integer and value as a List of String type. Java code can look complex unless you are comfortable using generics. Generics have been considered a solution for most of the data integrity issues that developers come across typically during deployment rather than during development. Generics promote type-safety and eliminates unnecessary runtime issues by ensuring the appropriate data type in compilation. Using JDK 7, the above line of code can be written in a simpler form. The compiler has enough information about the declaration of the variable regionMap to interpret the specific data-types on the right side. This will be used to map the correct data-types, thus making the code more readable and less error prone. This is an enhancement to the way generics are used to some extent. Simplified varargs method invocation presents a workable solution to the generics limitation of not being able to create arrays that are generic in nature, as shown in the following example: There has been a change request that adds more clarity on this. Developers who use NIO can now use NIO.2 to access the file system. NIO.2 is enhanced with the java.nio.file package and its related package java.nio.file.attribute, which make it easy to work across operating systems or multi-file systems. A detailed tutorial is available on oracle.com. The java.nio.file package has many classes and interfaces such as Path, Paths, FileSystem, FileSystems, and so on. Utility methods such as delete (e.g. However, existing code needs an overhaul to adapt to NIO.2. Developers will have to weigh the effort against the benefits of adopting NIO.2 for future portability and easy developmental support. Those using Java Web Start for application launches can employ JDK 7 enhancements in the JNLP file syntax. A new class, JLayer, also has been added to enhance the capabilities of Java Swing. JLayer is used primarily to decorate Swing components. Oracle.com has a detailed JLayer tutorial for reference. Other Swing changes include support for non-rectangular shapes and transparent windows, which make GUIs richer and more intuitive for end users. The Sockets Direct Protocol (SDP) provides access to high performance network connections, such as that provided by InfiniBand. Transferring data across networks quickly and efficiently is a requirement in high performance computing systems, where the conventional approach of transferring data using sockets is of little or no help. SDP is ideal in such environments and the throughput can be real-time. Used effectively, these and all the other Java 7 changes/enhancements will make Java developers more productive.
5 More Notable Java 7 Changes
December 19, 2011
Improved Type Interface for Generic Instance Creation
Map<Integer, List<String>> regionMap = new HashMap<Integer, List<String>>();Map<Integer, List<String>> regionMap = new HashMap<>();Simplified Varargs Method Invocation
public static List<String>[] getSingleList() {
List<String> firstList = Arrays.asList("one", "two", "three");
List<String> secondList = Arrays.asList("four", "five", "six");
return new List<String>[]{firstList, secondList};
//The above line will fail during compilation.
}NIO.2 Improvements Over NIO
delete(argPath) and deleteIfExists(argPath) in the Files class) were also added to avoid unnecessary problems.Rich GUI Deployment in Java 7
Sockets Direct Protocol (SDP)