//java architect /
Project Coin: The Java Language
Has Evolved!
JULIEN PONGE
Java SE 7 offers several features for writing more-concise and safer code while not breaking backward
compatibility with existing Java code.
JAVA IN ACTION
Project Coin is an OpenJDK project that initiated the Java
language changes that were
standardized as part of Java
SE 7 under JSR 334 in the Java
Community Process (JCP). The
project is self-described
as follows:
“The goal of Project Coin is to
determine what set of small
language changes should be
added to JDK 7. That list is:
■ ■ Strings in switch
■ ■ Binary integral literals
and underscores in
numeric literals
■ ■ Multi-catch and more
precise rethrow
■ ■ Improved type inference
for generic instance
creation (diamond)
■ ■ try-with-resources
statement
■ ■ Simplified varargs
method invocation”
This article is the second part
of a series of two articles cover-
ing each item of Project Coin. The
goal is to present the immediate
usage of each feature, and also
to provide some background on
the implications in implementing
each of them, especially because
they all maintain backward
compatibility with prior versions
of Java SE. The impact of each
change was remarkably balanced
with a scientifically sound analy-
sis of millions of lines of existing
Java code.
cially useful when dealing with
collections, because the generic
type declaration clearly documents its intended usage and
removes unnecessary casts.
The implementation strategy
for generics is a compromise
between a complete type system
and the need for backward com-
patibility with existing code bases
at the time generics were intro-
duced. To accomplish that, the
compiler knows the parameter-
ized types and performs checks
based on them, but such infor-
mation is lost at runtime. This is
called type erasure.
ABOUT US
PHOTOGRAPH BY
MATT BOSTOCK/GETTY IMAGES
Simplified varargs Method
Invocation
Java SE 5 introduced generics.
They have since been widely
adopted because of the increased
safety that the compile-time type
checking offers. They are espe-
blog
Author Julien Ponge provides an introduction to
Part 2 of his Project Coin series.