BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Project Coin Announces Final List of Small Language Changes

Project Coin Announces Final List of Small Language Changes

This item in japanese

Bookmarks

Joseph Darcy has published Project Coin's final list of approved changes to the Java language for the forthcoming version 7 release. They are:

  1. Automatic Resource Management: Provides a mechanism for resource clean-up. An ARM block 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, ARM is able to handle multiple resources within the scope of a given block.
  2. Better Integer Literals: Adds support for binary literals and underscore separators in numbers to aid readability - for example
    long creditCardNumber = 1234_5678_9012_3456L.
    May also include improvements to the handling of unsigned literals if a solution can be found in time.
  3. Collection Literals: Adds support for immutable list, set and map literals with a syntax similar to that of array initialisers, and may also add support for indexing access to lists and maps.
  4. Improved Type Inference for Generic Instance Creation (< > or diamond): Uses limited type inference for class instance creation so that where parameterise 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 could write:
    Map<String, List<String>> anagrams = new HashMap<>();
  5. Language support for JSR 292 including invokeDynamic instructions, method handle invocation, certain relaxed conversions and exotic identifiers.
  6. 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.
  7. Support for Strings in Switch Statements.

The majority of these proposals are expected to be in JDK 7's development Mercurial repositories by the end of October 2009.

Three short-listed proposals that haven't made the final cut are Improved Exception Handling for Java, Elvis and Other Null-Safe Operators and Large arrays.

Joseph Darcy commented:

“Improved exception handling would be a fine change for the language, but it ventures near the type system and we do not estimate we have resources to fully develop the feature within JDK 7. I would like to see improved exception handling reconsidered in subsequent efforts to evolve the language. While the Elvis operator and related operators are helpful in Groovy, differences between Groovy and Java, such as the presence of primitive types and interactions with boxing/unboxing render the operators less useful in Java. JDK 7 will support other ways to ease the pain of null-handling, such as the null checking enabled by JSR 308. Aggregates natively supporting more than 32-bits worth of entries will no doubt be increasingly needed over time. Language support for collections may allow such facilities to be developed as libraries until the platform directly handles large data structures.”

Rate this Article

Adoption
Style

BT