InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Java SE 7 Released: First Major Update Since December 2006

Posted by Charles Humble on Jul 28, 2011

Sections
Architecture & Design,
Development
Topics
Java SE ,
Java ,
Languages ,
Websphere ,
IBM ,
Programming ,
Application Servers ,
Agile in the Enterprise ,
Companies ,
Agile ,
JDK 7

Java 7 is generally available from today, the first release of the Java platform since Oracle's acquisition of Sun. The release includes a number of small but welcome changes to the language, incorporates a new file API and the Fork/Join Framework, and improves dynamic language support on the JVM.

For Java 7 language changes have been managed as part of Project Coin (JSR 334), a successor to JSR 201, designed to enhance the Java language with an assortment of small changes to improve productivity. Of particular note is the introduction of "try-with-resources". This is analogous to C#'s using statement but based on a form of the try statement. As a result, whilst the using statement only takes a single resource, try-with-resources is able to handle multiple resources within the scope of a given block.

Two changes have been made to exception handling. First, multiple exception types can be named as being handled by a single catch block. The grammar of a catch clause of a try statement is extended to allow a series of exception types, separated by the "OR" operator symbol, "|", to be used in the declaration of the exception parameter. Second, if an exception parameter is not modified and if it is rethrown inside the catch block, you don't now have to add the exception to the method signature.

Other language changes include:

  1. Augmenting the switch statement to include Strings.
  2. Support for binary literals and underscore separators in numbers to aid readability - for example long creditCardNumber = 1234_5678_9012_3456L
  3. Simplified Varargs method invocation: A compiler change for warnings which are issued when a method combines varargs with non-reifiable array types. The change moves the warning from the call site to the method declaration.
  4. Improved type inference for generic instance creation (< > or diamond): Uses limited type inference for class instance creation so that where parameter types need to be explicitly declared for a constructor, but they could be ascertained from the context, then they can be replaced with an empty set of type parameters. Thus instead of writing:
    Map<String, List<String>> anagrams = new HashMap<String, List<String>>();
    You can write:
    Map<String, List<String>> anagrams = new HashMap<>();

Two major new APIs have been introduced. The first is JSR 203, which adds new APIs for file system access, scalable asynchronous I/O operations, socket-channel binding and configuration, and multicast datagrams. Of particular interest to enterprise developers is the addition of a true asynchronous IO API, important for high-end server applications that need low latency and high throughput across many connections. 203 also finally adds a real file system API to Java, providing support for some OS specific functions. You can, for example, create symbolic links on systems that support them. As such, it can be argued, 203 isn't strictly "write-once-run-anywhere", although it does provide a common API that works on all platforms, as well as the platform specific features.

The second new API is the Fork/Join Framework (part of JSR 166), originally planned for Java 5. This provides a mechanism for developers to decompose problems into tasks that can then be executed in parallel across arbitrary numbers of processor cores.

Elsewhere the platform sees new networking and security features, and expanded support for internationalisation including Unicode 6.0 support.

Finally, Java SE 7 marks the first new bytecode instruction since the beginning of Java, with the InvokeDynamic keyword. InvokeDynamic adds one more invocation mode, and one more linking mode, which can be programmed to user-definable specifications. It is specifically intended to support efficient and flexible execution of method invocations in the absence of static type information, which results in substantial performance improvements for dynamic languages, such as JRuby and Jython, which target the JVM.

Whilst the new features are welcome, in many ways the most important thing about this release is that fact that it has been shipped at all. The long-running disagreement between Sun and the Apache Software Foundation, as well perhaps as leadership and resourcing problems in the final days of Sun, resulted in an unusually long hiatus between releases. As Mark Reinhold remarked in a recent interview

... for both business and political reasons Java kind of went into hibernation mode for a little while there. But we're back, and we're going to ship 7. It's not a revolutionary release, it's an evolutionary release, but it's got some really good stuff in it.

Developers interested in getting started with the Java SE 7 release can leverage the NetBeans IDE 7.0, or IntelliJ IDEA 10.5, which support the latest features of the Java SE 7 platform. Eclipse Indigo also has beta level support for Java 7 available, and Oracle JDeveloper support for JDK 7 is intended for a release later this year.

  • This article is part of a featured topic series on Agile
Awesome! by Cameron Purdy Posted
  1. Back to top

    Awesome!

    by Cameron Purdy

    I was out to Santa Clara a week ago for the JVM language summit, and there's a great deal of excitement around the improvements both in Java 7 and coming in Java 8 and beyond. Oracle has been heavily investing in Java, and the results are just now starting to appear.

    BTW - from our benchmarking, Java 7 is showing a 1-6% performance gain vis-a-vis Java 6 on our application server benchmarks with GlassFish.

    Peace,

    Cameron Purdy | Oracle

Educational Content

Evolution in Data Integration From EII to Big Data

Approaches to integrating data are changing with emergence of cloud computing.

Winning Hearts and Minds: How to Embed UX from Scratch in a Large Organization

Michele Ide-Smith presents the lessons learned in the process of introducing UX principles and techniques into a large organization through a series of small steps.

LMAX Disruptor: 100K TPS at Less than 1ms Latency

Dave Farley and Martin Thompson discuss solutions for doing low-latency high throughput transactions based on the Disruptor concurrency pattern.

Thoughts on Test Automation in Agile

Rajneesh Namta shares his thoughts, experiences, and some of the critical lessons learned while implementing software test automation on a recent Agile project.

Actor Interaction Patterns

Dale Schumacher presents several patterns of actor interaction that can be used in collaborative programs written in any language.

Scalaz: Functional Programming in Scala

Rúnar Bjarnason discusses Scalaz, a Scala library of pure data structures, type classes, highly generalized functions, and concurrency abstractions to perform functional programming in Scala.

Faster, Better, Higher – But How?

One of the main challenges when designing software architecture is considering quality attributes. Not only their design turns out to be difficult, but also the specification of these attributes.

Software Naturalism - Embracing the Real Behind the Ideal

Michael Feathers analyzes real code bases concluding that code is not nearly as beautiful as designers aspire to, discussing the everyday decisions that alter the code bit by bit.