JDK 7 Released ... Finally!!!
A Detailed Overview Of New Features/Functionality in JDK7
Introduction
The following long-ish blog entry is a relatively detailed overview of information for the JDK 7 Release of 29th July 2011 by Oracle. Given the release has just occurred I have collected a large amount of relatively detailed information regarding the JDK7 release that developers looking to upgrade from Java 1.6.0_26 to JDK7 will find useful. This information includes a general overview of the entire release with access via links to the various documentation you may need, release notes, installation instructions, JavaDoc API's etc., as well as changes that have been included and whether they have caused compatability and generally known issues that you may encounter.
More importantly for most people that will find their way here Ive also included information about the Programming Language enhancements (these are the ones that if you've heard anything about Java 7 you would've heard about these) and include the various Project Coin upgrades, and new functionality like try-with-resources, multi-catch, Strings in switch statements, upgrades to numeric and binary literals, etc. Besides these Ive also included other enhancements that generally you are less likely to hear about as they arent discussed as often as they arent focussed at the programming language level per-se but can include things like JVM, Garbage Collector and various new Framework (fork./join, NIO2, etc) inclusions and improvements. If your primarily after this information which I think most people interested in Java 7 will be and you want to bypass the sections on JDK7 Release History, Release Notes and various JDK 7 Documentation, then simply skip ahead to the two sections on enhancements further down towards the end of this blog entry under the main title 'Overview of JDK 7 New Features' and each labelled with their respective titles:
- General Enhancements in the Java JDK 7
- Programming Language Enhancements in Java SE 7
Since a lot of this information is already accessible and has been provided by the implementers (Sun/Oracle) rather than copy/paste large slabs of text or re-write it myself with new examples etc., Ive focussed more on providing a brief introduction and over-view in all these cases and then providing a series of links to much more detailed information in the form of tutorials, explanations and specifications. The general idea of this blog entry is to provide a single point of entry for any and all information regarding Java 7 and to be able to get some initial info on what it is that your interested in before being re-directed to much more detailed information via outgoing links. Lets see how I do hey :-)!
Overview Of JDK7 Release History
So after almost 5 years (four years, seven months, and seventeen days) since JDK 6 and after 9,494 bug fixes, 1,966 enhancements, 9,018 changesets, 147 builds, and four JSRs, JDK 7 is done (Thanks Mark Reinhold for that info:
http://mreinhold.org/blog/jdk7-ga). Oracle announced the release of JDK 7 today (2011-07-29) which interestingly followed the scheduled release plan exactly which is reassuring to see for the future JDK8 release as it raises my level of trust that if they say they'll release JDK8 in 2012 that it'll actually happen unlike JDK7 which as we know see was delayed over and over for 5 years:
http://openjdk.java.net/projects/jdk7/
The plan above was made up of 147 builds as mentioned comprising a total of 13 Milestones. Information on each of the milestones with further detailed information aboutwhat a particular feature in a milestone entails, along with a detailed calendar of build dates and milestones (for those interested in such things) is provided in the following two links:
Overview Of Release Notes
The next link below is the main download page:
This page has downloads for both the previous version of JDK6 (1.6.0_26) as well as everything related to the new JDK7 release (ie: JDK7 with EE, JDK7 with Netbeans 7.0). Incidentally Netbeans 7.0 is a version of Netbeans that is already built to work with JDK7.0 so you can start using JDK7 with the Netbeans IDE straight away and get access to the cool features within the IDE (ie: the Project Coin features are useable and visible in the IDE and it gives correct information and code-completion for them already, which as I say is nifty and great that its available so early on the same day as the JDK 7 release itself).
The index page for the Release Notes of JDK7 are at:
These are detailed and include various documents. The first of these Ill look at is the Java SE 7 Features and Enhancments page located at:
Since this is a major feature release this link includes information on the various features and enhancements in Java SE 7 and JDK 7. The beginning of the document above has a number of sections that highlight the Technology Changes as well as the various RFE (Requests For Enhancements) that were addressed. You can follow these links for more detailed information and I suggest doing so. Furthermore one of the last sections is a list of the known issues which Im linking to below as this is an important section of information. Skimming through this section there are a number of known issues in this release which its important to be aware of. One are where there seems to be a number of issues in is the use of Genereics and how Re-ification of Generics affects the type of code that can and can't be written. I found these useful to skim through simply to be aware of what can occur and when writing code I'll now be aware of what to look out for. See link for known issues:
The Release Notes also provide info on compatability. Much like the known issues section this is also useful to read through to be aware of problems that may arise during upgrade from JDK6 to JDK7. Although in general and despite the introduction of a number of new features (which JDK6 didnt have compared to JDK5) the upgrade from 6 to 7 is actually quite painless. The list of compatability issues in the link below is quite small and limited to very specific cases. Though still usefull to read through I would recommend upgrade to 7 as soon as possible as these few very specific cases can a) be dealt with should they arise and b) the benefits from the new features more than out weigh any very minor upgrade problems.
http://www.oracle.com/technetwork/java/javase/compatibility-417013.html
Again the page above is very well written and the sections on incompatabilities are very detailed indicating which sections of the language are affected (eg: NIO, API, Language, etc):
http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#incompatibilities
The final parts of the Release Notes are info on a number of sections. These are listed along with their associated links and some short info below along with links to a variety of other docs and information links that are important for the JDK 7 release.
Overview Of JDK 7 Important Documentation and Links
- Version Numbering and Naming Information - This is information on the various numbering and naming standards used within this release of the JDK. Useful information since Java has an unusual set of naming standards. ie: the version string for the product is reported as "java version 1.7.0_3", the product will be called JDK 7u3, JDK 7 update 3 or, when the update version is not important, JDK 7. http://www.oracle.com/technetwork/java/javase/jdk7-naming-418744.html
- JDK and JRE 7 Installation Guide - Provides information on performing an installation of each of the modules. If you've ever done a previous install of the Java Platform this is all old hat and Im providing it mainly for completeness sake: http://download.oracle.com/javase/7/docs/webnotes/install/index.html
- JDK and JRE 7 README Files - High level README files which provide information on libraries, packages, endorsed override methods, the location of jars and libraries and packages within those libraries etc.
- JDK7 Specifications - This page contains links to the Java SE 7 Edition Language and Virtual Machine specifications. It also has archival links to previous specification versions. The specifications are important as they are the final word on how things SHOULD work and I have often turnesd to them in the past when new versions have come out to see why and how an implementation has been done (ie: previous Java Versions introduced the Integer/Char/Short/Byte internal caches and the specifications provided the final word on initial cache sizes etc). http://download.oracle.com/javase/cmn/spec_index.html
- JDK7 API Docs - This is one of the critical links and also one of the pieces of documentation any developer will return to time and again. The link is to the root of the java API doco (with new doco for new functionality added in JDK7 labelled using: since 1.7 in the JavaDocs as is standard). http://download.oracle.com/javase/7/docs/api/
- JDK 7 Tutorials - A set of brand new tutorials has been created with the new functionality added in JDK 7 as a basis and added to the complete existing set of tutorials. All of the tutorials have been updated on the basis of the new release. The new tutorials based on the newly introduced JDK7 functionality are grouped at the start of the page and cover Project Coin functionality amongst other things and so are useful even for experienced Java developers to get a feel for the correct use of new functionality. http://download.oracle.com/javase/tutorial/
- JDK 7 Trouble Shooting Guide - This Java 7 Trouble Shooting Guide contains numerous links to various trouble shooting blogs. Although many of the performance links are JDK6 (since JDK7 has minimal performance features as these are saved for multi-core processing imlementations in JDK8) they ar still valid in the context of this JDK 7 release. http://download.oracle.com/javase/7/docs/webnotes/tsg/index.html
- JDK7 Documentation Index - This page contains the high-level overview index for all of the API's and various JDK 7 components as well as a section on 'Whats New in JDK7 Documentation' which covers the new features and components which were implemented in this JDK. The first section is a series of tech notes for each section (such as JDBC, JNDI, AWT, Java2D etc.) while the 2nd section gives a good indication of what was added in this JDK release (ie: changes made to the garbage collector, the API's, NIO packages and usage, etc).
Ive list the changes mentioned in the second section in the final point above in more detail in the following section as these are a good way of seeing whats changed in the JDK for this version.
Overview Of JDK 7 New Features
A good source of an overview for fetaures included in this release is the wiki page (at:
http://en.wikipedia.org/wiki/Java_version_history#Java_SE_7_.28July_28.2C_2011.29) and this provides not just the main features but also info on things less well publicised as they are not code features but underlying functionality (such as the info on the XRenderer etc). Another good source of detailed information discussing the various Project Coin features in detail is Oracle's page located at:
The enhancements listed here cover the entire JDK 7 release. Actual code/coding enhancements will be listed in the section 'Programming Language Enhancements in Java SE 7' below while here I'll list things like changes to API's, the garbage collector, the JVM, etc. While the programming language changes have been discussed at length in the leadup to the release of Java 7 the following set of updates and new functionality have in general received less coverage and so are covered at some length here.
- Swing Enhancements in JDK 7 - Include a number of features that make the use of Swing and AWT easier to implement as well as the implementation of a number of cool features. The Nimbus Look and Feel has been moved from the sun.* packages to within javax.*, and features such as the ability to now create translucent and shaped (ie: non-rectangular) windows which is cool and to use JLayer to draw on top of any components without actually changing the underlying components (also cool) have been provided. http://download.oracle.com/javase/7/docs/technotes/guides/swing/7.0/index.html
- Networking Enhancments in JDK 7 -The
URLClassLoader.close
method has been added; see Closing a URLClassLoader. The Sockets Direct Protocol (SDP) provides access to high performance network connections; see Understanding the Sockets Direct Protocol. http://download.oracle.com/javase/7/docs/technotes/guides/net/enhancements-7.0.html
- Collection Enhancments in JDK 7 - The
TransferQueue
interface has been added, which is a refinement of the BlockingQueue interface in which producers can wait for consumers to receive elements. The new class LinkedTransferQueue
implements the TransferQueue
interface which is a new implementation included for the first time in JDK 7. http://download.oracle.com/javase/7/docs/technotes/guides/collections/changes7.html
- Java I/O Enhancements in JDK 7 - This release includes the addition of a new method UrlClassLoader.close(), the addition of Sockets Direct Protocol concepts as well as the general introduction of NIO2 in JDK7 (see the java.nio.file API JavaDoc that was introduced for Java 7 for an overview of the new Files and FileSystem methods available within this package: http://download.oracle.com/javase/7/docs/api/java/nio/file/package-summary.html) and the ability to create custom file providers as well as an implemented Custom File Provider in the form of the Zip File System Provider. http://download.oracle.com/javase/7/docs/technotes/guides/io/enhancements.html#javase7
- Java SE 7 Security Enhancements - Include the ability to switch of weak crypto algorithms, the addittion of a new native provider that contains several implementations of Elliptic Curve Cryptography (ECC) algorithms, and the inclusion of 10 various major level improvements to SSL/TLS which are detailed in the link below. http://download.oracle.com/javase/7/docs/technotes/guides/security/enhancements7.html
- Concurrency Utilities Enhancements in Java SE 7 - The fork/join framework was a major introduction in JDK 7. Along with this the ThreadLocalRandom and Phaser classes have been added. http://download.oracle.com/javase/7/docs/technotes/guides/concurrency/changes7.html
- The fork/join framework, which is based on the
ForkJoinPool
class, is an implementation of the Executor
interface. It is designed to efficiently run a large number of tasks using a pool of worker threads. A work-stealing technique is used to keep all the worker threads busy, to take full advantage of multiple processors. See Fork/Join in The Java Tutorials. - The directory
/sample/forkjoin/
contains samples that demonstrate the fork/join framework.
- The
ThreadLocalRandom
class eliminates contention among threads using pseudo-random numbers; see Concurrent Random Numbers.
- The
Phaser
class is a new synchronization barrier, similar to CyclicBarrier
.
- Client JRE Enhancements (ie: RIA) in Java SE 7 - Java Rich Internet Applications are becoming increasingly sophisticated with each release of the JRE and JRE7 continues this trend with a number of new features added. http://download.oracle.com/javase/7/docs/technotes/guides/jweb/clientJRECapabilitiesCheatSheet.html
- Java 2D Enhancments in Java SE 7 - Contains a number of different enhancements. http://download.oracle.com/javase/7/docs/technotes/guides/2d/enhancements70.html
- Java XML Technologies Enhancements in Java SE 7 - This release contains Java API for XML Processing (JAXP) 1.4.5, supports Java Architecture for XML Binding (JAXB) 2.2.3, and supports Java API for XML Web Services (JAX-WS) 2.2.4. Further information on each of these changes is found at with the following changes to each of (JAXP, JAXB, JAX-WS): http://download.oracle.com/javase/7/docs/technotes/guides/xml/enhancements.html
The following programming language enhancements and new functionality (as mentioned earlier) have been discussed at some length on blogs etc., prior to the Java 7 release and so here I will cover the new features and aprt from a breif overview provide links to further information.
- Binary Literals - In Java SE 7, the integral types (
byte
, short
, int
, and long
) can also be expressed using the binary number system. To specify a binary literal, add the prefix 0b
or 0B
to the number.
- Underscores in Numeric Literals - Any number of underscore characters (
_
) can appear anywhere between digits in a numerical literal. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your code.
- Strings in switch Statements - You can use the
String
class in the expression of a switch
statement.
- Type Inference for Generic Instance Creation - You can replace the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (
<>
) as long as the compiler can infer the type arguments from the context. This pair of angle brackets is informally called the diamond.
- Improved Compiler Warnings and Errors When Using Non-Reifiable Formal Parameters with Varargs Methods - The Java SE 7 complier generates a warning at the declaration site of a varargs method or constructor with a non-reifiable varargs formal parameter. Java SE 7 introduces the compiler option
-Xlint:varargs
and the annotations @SafeVarargs
and @SuppressWarnings({"unchecked", "varargs"})
to supress these warnings.
- The try-with-resources Statement - The
try
-with-resources statement is a try
statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try
-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements the new java.lang.AutoCloseable
interface or the java.io.Closeable
interface can be used as a resource. The classes java.io.InputStream
, OutputStream
, Reader
, Writer
, java.sql.Connection
, Statement
, and ResultSet
have been retrofitted to implement the AutoCloseable
interface and can all be used as resources in a try
-with-resources statement.
- Catching Multiple Exception Types and Rethrowing Exceptions with Improved Type Checking - A single
catch
block can handle more than one type of exception. In addition, the compiler performs more precise analysis of rethrown exceptions than earlier releases of Java SE. This enables you to specify more specific exception types in the throws
clause of a method declaration.
The Future .... JDK 8
Although Java 7 has only just been released today the future is coming (some might say its already here), since Java 7 was part of a two pronged strategy undertaken late last year (2010) to ensure a JDK release in 2011 (given that it had been 5 years since releases). With the takeover of Sun by Oracle last year and the Java release having been pushed back several times a proposal was made by Mark Reinhold on his blog (http://blogs.sun.com/mr/entry/rethinking_jdk7) for one of two options. Push ahead with the current plans for Java and take another 2 or 3 years to the release or trim down the functionality set and aim for a mid-2011 followed by a late-2012 release with the remaining functionality initially proposed for Java 7 to be released in Java 8. The descision to go with the second option can be seen on Marks blog:
Labelled Plan B it looked roughly like:
- JDK 7 (minus Lambda, Jigsaw, and part of Project Coin) Mid 2011
- JDK 8 (Lambda, Jigsaw, the rest of Project Coin, ++) Late 2012
A detailed list of functionality for the two JDK's followed:
Along with both a JSR for JDK 8:
And a set of project pages for each of the JDK 8 features to be implemented still:
- JSR 294: Language and VM support for modular programming - Enhancements to the Java language and virtual-machine specifications to support modular programming, at both compile time and run time
- JSR 308: Annotations on Java types - An extension to the Java annotation syntax to permit annotations on any occurrence of a type
- JSR 344: Project Coin - Language support for collections - Literal expressions for immutable lists, sets, and maps, and indexing-access syntax for lists and maps, plus unsigned literals
- JSR 335: Project Lambda - Lambda expressions (informally, "closures") and defender methods for the Java programming language
- JSR 294: Modularization (Project Jigsaw) - A simple, low-level module system focused upon the goal of modularizing the JDK, and the application of that system to the JDK itself
- JSR 296: Swing application framework - An API to define the basic structure of a typical Swing application, thereby eliminating lots of boilerplate code and providing a much improved initial developer experience.
- Swing JDatePicker component - Add the SwingLabs JXDatePicker component to the platform
So there you have it....JDK 8 and definately stuff to look forward to in that lot, not too mention that there will be multi-core performance improvements made as part of JDK 8 on the non-programming side of things amongst other changes.
Keep watching this space!!!