Tuesday Oct 18, 2011

The Heads and Tails of Project Coin

JavaOne 2011 - Joseph Darcy, Member of the Oracle Technical Staff, spoke to a very large,
packed conference room in his “The Heads and Tails of Project Coin” (22641) session Tuesday.
Project Coin, a central part of Java 7, was described by Darcy as “a suite of language and
library changes to make things programmers do everyday easier.”

Project Coin makes life easier by removing extra text to make programs more readable;  
encouraging the writing of programs that are more reliable; and by integrating well with past and future changes.
Darcy emphasized that these are small language changes related to specification, implementation and testing;
there are no JVM changes. Project Coin was written to coordinate with forthcoming larger language changes.

Project Coin has strong IDE support:
• IntelliJ IDEA 10.5 and later                                                                                                
• Eclipse 3.7.1 and later                                                                                                                  
• NetBeans 7.0 and later

The six Project Coin features are:  
• Binary literals and underscores in literals                                                                                
• Strings in switch                                                                                                                          
• Diamond                                                                                                                                     
• Multi-catch and more precise rethrow                                                                                
• try-with-resources                                                                                                               
• Varargs warnings

Diamond and varargs warnings enable easier-to-use generics. Multi-catch and try-with-resources allow for more concise error handling. Strings-in-switch and literal improvements result in greater consistency and clarity.

Darcy proceeded to demonstrate five of the six Project Coin features to a highly engaged audience.
Check out his session slides and you can also view this talk @ http://parleys.com/d/2663.

What’s ahead for Project Coin in Java 8? Look for very small language changes on the horizon.

Wednesday Sep 14, 2011

Working with Java SE 7 Exception Changes

A new article by systems architect Manfred Riem, now up on otn/java, titled “Working with Java SE 7 Exception Changes,” covers important developments in Java 7’s Project Coin, focusing on exception handling -- specifically multi-catch, rethrow, and try-with-resources. Project Coin consists of the following small language changes, which are intended to simplify common programming tasks: strings in switch statements; better integral literals; multi-catch exceptions; improved type inference for generic instance creation; try-with-resources; and simplified varargs method invocation.

From the article itself:

“The exception handling changes in Java SE 7 allow you not only to program more concisely, as demonstrated in the multi-catch examples, but they also allow you to partially handle an exception and then let it bubble up, as covered in the re-throw examples. Java SE 7 also facilitates less error-prone exception cleanup…”

Read the complete article here.

Thursday Jun 02, 2011

Managing Resources with Java 7

A very clear and detailed article by Julien Ponge, titled “Better Resource Management with Java SE 7: Beyond Syntactic Sugar,” presents the Java 7 answer to the automatic resource management problem in the form of a new language construct, proposed as part of Project Coin, called the try-with-resources statement.

Java applications frequently manipulate different types of resources such as files, streams, sockets, and database connections that require system resources for their operations. They must be managed with great care or risk having database connections and file descriptors remain open after an exception occurs elsewhere in the code. As a result, application servers may need frequent restarts due to resource exhaustion.

The article provides an overview of resource and exception management before explaining the essentials of try-with-resources statements. It then shows how a class can be made ready to support such statements, and concludes with a demystification of the syntactic sugar behind the language extension.

Ponge concludes that the try-with-resources construct “generates correct code on behalf of the developer, eliminating the need to write boilerplate code that is easy to get wrong. More importantly, this change has been accompanied with evolutions to attach one exception to another, thus providing an elegant solution to the well-known problem of exceptions masking each other.”

Read the rest of the article here.


Insider News from the Java Team at Oracle!

javeone logo


« April 2014