Java 7

This page lists the proposed features in Java 7 and information about them. At this point, no Java 7 JSR has been created (although Danny Coward apparently is working on it). So, consider this a list of possible features and libraries, not the actual future contents of Java 7. I formerly published a weekly roundup of discussion on what’s been added to this page. I now publish all new links on a separate Java 7 link blog (RSS) if you want to subscribe.

Note: I have absolutely no inside information on any of this and you should treat it all as unofficial. I’m merely scraping info off the web and collecting it here. If you have updates or corrections, please feel free to send it to me at contact:at:puredanger.com!

The official JDK 7 Development Home page has mailing lists, downloads, source, and more.

My most recent summary article on Java 7 can be found on JavaWorld. And this presentation covers a lot of the same territory: Java 7 Preview [pdf].

Features

Modularity

Libraries

Swing

JMX

Tools

Types and Generics

Language Proposals

Miscellaneous Language

JVM

Java 7 Discussion

Details


Project Jigsaw

Project

Description: This project is intended to modularize the JDK itself by breaking it into .

Blogs:


JSR 294 Improved Modularity Support (superpackages)

JSR | Early Draft Review | Mailing list

Description: This JSR is related to JSR 277. 277 deals with deployment and packaging. 294 focuses more on API modularity at development time.

Example:

superpackage example.bar.lib {

// member packages
member package example.bar.lib;

// member superpackages
member superpackage example.bar.lib.net, example.bar.lib.xml;

// list of exported types
export example.bar.lib.Table;

export superpackage example.bar.lib.net;
}

Blogs:


JSR 277 Java Module System

JSR | Proposal | Project | Mailing list

Description: The specification defines a distribution format and a repository for collections of Java code and related resources. It also defines the discovery, loading, and integrity mechanisms at runtime. Defines a new deployment archive called a JAM (Java Module). The Java Module is a JAR file that contains other JARs, resources, and metadata. JAMs can specify which portions of the module are public and which are hidden. JAMs can specify dependencies on other modules.

Blogs:


Java Kernel

Description: Implement Java as a small kernel, then load the rest of the platform and libraries as needed, with the goal of reducing startup time, memory footprint, installation, etc. In the past this has also been referred to as “Java Browser Edition”.

Note: It was announced at JavaOne 2007 that the Java Kernel work will be released as the “Consumer JRE” in a Java 6 update, likely in early 2008. So, this work is going to be released prior to Java 7 and will no longer be tracked on this page. 5/21/2007

Blogs:


JSR 203 NIO2

JSR | Project | Mailing list

Description: APIs for filesystem access, scalable asynchronous I/O operations, socket-channel binding and configuration, and multicast datagrams.

The proposed specification will continue the work of defining a set of new and improved I/O APIs that was started in of JSR-51: New I/O APIs for the Java Platform. Its major components will be:

  1. A new filesystem interface that supports bulk access to file attributes, change notification, escape to filesystem-specific APIs, and a service-provider interface for pluggable filesystem implementations;
  2. An API for asynchronous (as opposed to polled, non-blocking) I/O operations on both sockets and files; and
  3. The completion of the socket-channel functionality defined in JSR-51, including the addition of support for binding, option configuration, and multicast datagrams.

Blogs:


JSR 310 Date and Time API

JSR | Project | Spec | Wiki | Javadoc

Description: This JSR will provide a new and improved date and time API for Java. The main goal is to build upon the lessons learned from the first two APIs (Date and Calendar) in Java SE, providing a more advanced and comprehensive model for date and time manipulation.

The new API will be targeted at all applications needing a data model for dates and times. This model will go beyond classes to replace Date and Calendar, to include representations of date without time, time without date, durations and intervals. This will raise the quality of application code. For example, instead of using an int to store a duration, and javadoc to describe it as being a number of days, the date and time model will provide a class defining it unambiguously.

The API will be based on Joda-Time but will be updated based on JDK 5 features and other community input.

Blogs:


JSR 275 Units and Quantities

JSR | Project | RI

Description: This JSR specifies one or more Java packages for the programmatic handling of physical quantities and their expression as numbers of units. The specification includes:

  • Checking of unit compatibility
  • Expression of a quantity in various units
  • Arithmetic operations on units
  • Concrete classes implementing the standard types of units (such as base, supplementary, and derived) and unit conversions.
  • Classes for parsing unit specifications in string form and for formatting string representations of quantities.
  • A database of predefined units.

Blogs:


JSR 107 JCache API

JSR | Project

Description: The JCACHE specification standardizes in process caching of Java objects in a way that allows an efficient implementation, and removes from the programmer the burden of implementing cache expiration, mutual exclusion, spooling, and cache consistency.

Blogs:


JSR 166 Concurrency Utilities

JSR | Project | Mailing list

Description: This JSR originally introduced the concurrency libraries in Java 5 and has since produced enhancements for Java 6. For Java 7, the JSR 166 group will be adding a new kind of BlockingQueue called TransferQueue and a fine-grained parallel computation framework based on divide-and-conquer and work-stealing.

Blogs:


JSR 225 XQuery API for Java

JSR

Description: This JSR defines an API for executing XQuery calls and working with results. XQJ is to XQuery what JDBC is to SQL. At a glance, the XQJ API intentionally shares many high-level concepts from JDBC (DataSource, Connection, etc) but supports XQuery specific concepts such as static and dynamic phases, XML-oriented retrieval, etc.

Blogs:


JSR 284 Resource Consumption Management API

JSR

Description: The API will allow for partitioning resources (constraints, reservations) among Java applications and for querying about resource availability (notifications). It will also provide means of exposing various kinds of resources. Example resources are heap memory size, CPU time, open JDBC connections, etc. The goal is to allow resources to be managed so that multiple applications might run simultaneously in a JVM and be given finite amounts of memory, cpu, etc. This JSR will build on top of JSR 121 Isolates.

Blogs:


Miscellaneous Library Changes

Blogs:


JSR 296 Swing Application Framework

JSR | Project

Description: This JSR will provide a simple application framework for Swing applications. It will define infrastructure common to most desktop applications. In so doing, Swing applications will be easier to create.

Blogs:


JSR 295 Beans Binding

JSR | Project

Description: Provide an API that allows two properties of two beans to stay in sync. Formalizes an API for connecting JavaBeans.

Blogs:


JSR 303 Beans Validation

JSR | Public Review

Description: This JSR will define a meta-data model and API for JavaBeanTM validation based on annotations, with overrides and extended meta-data through the use of XML validation descriptors.

Blogs:


Java Media Components

Description: Java Media Components will finally add support for video to Java. It will initially address playback and ultimately will also cover capture and streaming. Video playback will provide support for both native players and a pure Java player.

Blogs:


JSR 255 JMX 2.0

JSR

Description: This JSR updates the JMX and JMX Remote APIs to improve usability of existing features and add new functionality such as annotations for ease of development, federated JMX servers, etc.

Blogs:


JSR 262 Web Services Connector for JMX

JSR | Proposal | RI

Description: Defines a connector for the JMX Remote API that uses Web Services to make JMX instrumentation available remotely. Clients do not have to be Java applications, but can be.

Blogs:


JSR 326 Post mortem JVM Diagnostics API

JSR

Description: A standard Java API designed to support the generation and consumption of post mortem or snapshot Java diagnostic artifacts, such as heap and CPU dumps.

Blogs:


JSR 260 Javadoc Technology Update

Javadoc Update Project | JSR | Project

Description: Defines new tags and generated Javadoc document representation aimed to increase readability, information richness, and make the Javadoc more approachable to developers learning and using the APIs.

This JSR will investigate various improvements to javadoc tags, including for example:

  • categorization of methods and fields by their target use
  • semantical index of classes and packages
  • distinction of static, factory, deprecated methods from ordinary methods
  • distinction of property accessors from ordinary methods
  • combining and splitting information into views
  • embedding of examples, common use-cases along with Javadoc

While the JSR looks to be fairly dormant, there is a project (first link above) to update Javadoc in JDK 7.

Blogs:


Reified Generics

Currently, generics are implemented using erasure, which means that the generic type information is not available at runtime, which makes some kind of code hard to write. Generics were implemented this way to support backwards compatibility with older non-generic code. Reified generics would make the generic type information available at runtime, which would break legacy non-generic code. However, Neal Gafter has proposed making types reifiable only if specified, so as to not break backward compatibility.

Blogs:


Type Literals

Description: A proposal to retrofit Type with generics.

Example:

Type<List<String>> x = List<String>.class;

Blogs:

JSR 308 Annotations on Java Types

JSR | Project | Early Draft Review | Proposal | Mailing list archive | Prototype

Description: JSR 308, “Annotations on Java Types”, enriches the Java annotation system. For example, it permits annotations to appear in more places than Java 6 permits; one example is generic type arguments (List<@NonNull Object>). These enhancements to the annotation system require minor, backward-compatible changes to the Java language and classfile format.

JSR 305 is a related JSR concerned with specifying a standard set of annotations for defect detection, which (with JSR 308) can be applied in more places. Project Home

Blogs:


Type inference

Proposal | Background

Description: Use compiler type inference to clean up some cruft in constructor invocation and remove the need for explicit type specification in some generic cases.

Constructor invocation can be changed from:

Map<String, List<String>> anagrams = new HashMap<String, List<String>>();
to
Map<String, List<String>> anagrams = new HashMap<>();

and explicit type references can now be inferred changing:

timeWaitsFor(Collections.<Man>emptySet());
to
timeWaitsFor(Collections.emptySet());

Blogs:


Closures

JSR Proposal | BGGA Proposal | CICE Proposal | FCM Proposal | C3S Proposal

BGGA Prototype | CICE Prototype | FCM Prototype

Description: A closure is a function that captures the bindings of free variables in its lexical context. Closures support passing functions around and make many anonymous inner class use cases easier to use. In addition, they support additional high-level programming abstractions.

Blogs:


Automatic Resource Block Management

Proposal | ARM Prototype

Description: A proposal to support scoping of resource usage in a block with automatic resource cleanup. This addresses the common and messy problem of correctly closing or releasing resources in a finally block, particularly when needing to close multiple resources in the same block.

Example:

// Start a block using two resources, which will automatically
// be cleaned up when the block exits scope
do (BufferedInputStream bis = …; BufferedOutputStream bos = …) {
… // Perform action with bis and bos
}

Blogs:


Language level XML support

Description: Add support for multi-line XML (or possibly other languages or kinds of text) to be embedded within code.

Example:

elt.appendChild(
&lt;muppet&gt;
&lt;name&gt;Kermit&lt;/name&gt;
&lt;/muppet&gt;);

Blogs:


JavaBean property support

Wiki

Description: Support properties (and possibly events) as features of the language, with a special syntax for defining and possibly calling them.

Example:

public property String foo;
a->Foo = b->Foo;

Blogs:


BigDecimal operator support

Description: Add support for manipulating BigDecimal objects with arithmetic operators (just like other numeric primitives) instead of via method calls.

Blogs:


Strings in switch statements

Proposal

Description: Allow switch statements to use strings in the case blocks.

Example:

static boolean booleanFromString(String s) {
switch(s) {
case "true":
return true;
case "false":
return false;
}
throw new IllegalArgumentException(s);
}

Blogs:


Comparisons for Enums

Proposal

Description: Allow enum values to work with range operators (<, >, etc)

Example:

boolean isRoyalty(Rank r) {
return rank >= Rank.JACK && rank != Rank.ACE;
}


Chained invocation

Proposal

Description: Allow easy chaining of method calls by allowing void methods to implicitly return this. This allows easy creation of fluent APIs that can chain together method calls.

Example:

class Factory {
void setSomething(Something something) { … }
void setOther(Other other) { … }
Thing result() { … }
}

Thing thing = new Factory()
.setSomething(something)
.setOther(other)
.result();

Blogs:


Extension methods

Proposal

Description: Allow clients to designate static utility methods to act as if they were part of an interface via static import in the interface.

Example:

import static java.util.Collections.sort;
List<String> list = …;
list.sort(); // looks like call to List.sort(), but really call to static Collections.sort().

Blogs:


Enhanced null handling

Proposals for Enhanced null handling

Description: Null-ignore invocation is concerned with dealing with possible null values in calling one or especially a chain of methods.

For example, instead of

public String getPostcode(Person person) {
if (person != null) {
Address address = person.getAddress();
if (address != null) {
return address.getPostcode();
}
}
return null;
}

you could instead call:

public String getPostcode(Person person) {
return person?.getAddress()?.getPostcode();
}

Another issue concerns how to handle common if-null scenarios with a shortened form of the ternary operator specific to nulls. So rather than:

String str = getStringMayBeNull();
str = (str == null ? "" : str);

you might do:

String str = getStringMayBeNull() ?: "";

Null safe types is another proposal similar in some ways to the JSR 305/308 annotation proposal for annotating whether parameters may or may not be null.

Blogs:


Improved catch clause

Proposals Multicatch and Rethrown

Description: First, allow catch to catch multiple exceptions and handle them identically using the “|” operator in the catch block:

try {
return klass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new AssertionError(e);
}

Second, allow better ways to rethrow exceptions. Generally, programmers often catch a broader exception, handle (for example, via logging), then rethrow. When they rethrow, they must indicate what is being thrown on the method often causing them to either broaden the scope of the thrown exception to a common parent OR wrap the exception. This enhancement allows you to add final to the catch block indicating that a throw will happen on only the thrown checked exceptions within the try block:

try {
doable.doIt();
} catch (final Throwable ex) {
logger.log(ex);

// surrounding method can declare only checked thrown by doIt()
throw ex;
}

Blogs:


Language Suggestions

Project Coin Wiki


invokedynamic

JSR 292 | DaVinci Machine Projects

Description: Introduces a new bytecode invokedynamic for support of dynamic languages.

Blogs:


Tiered Compilation

Description: Tiered compilation uses a mix of the client (JIT) and server hot spot compilers – the client engine improves startup time by using JIT over interpreted and the server hot spot compiler gives better optimization for hot spots over time.

Blogs:


G1 Garbage Collector

Paper

Description: The G1 (for “garbage first”) is a single collector that divides the entire space into regions and allows a set of regions to be collected, rather than split the space into an arbitrary young and old generation. Sun intends to make this new collector the default in Java 7. (This applies only to the Sun JDK.)

Blogs:


More Script Engines

Description: Add additional language interpreters to JSE. The JavaScript Rhino engine was added in Java 6. Leading candidates for Java 7 are: JRuby, Jython, and Beanshell.

Blogs:

Weekly Roundup

2008

2007