OpenJDK plan would make Java coding easier

15.03.2016
A new plan proposed for OpenJDK would give Java a local-variable type inference capability so that it's easier to write code while continuing with static type safety.

The measure was proposed earlier this month in JEP (JDK Enhancement Proposal (JEP) 286. Documentation currently does not cite a version of Java where the improvement would be featured.

"We seek to improve the developer experience by reducing the ceremony associated with writing Java code while maintaining Java's commitment to static type safety by allowing developers to elide the often-unnecessary manifest declaration of local variable types," the proposal states. Other statically typed curly braced languages, such as C++, Scala, and Go, already support some variant of local-type inference. "Java is nearly the only popular statically typed language that has not embraced local-variable type inference," the JEP stresses. "At this point, this should no longer be a controversial feature."

Java developers frequently complain about the volume of boilerplate coding required, according to the JEP. "Manifest type declarations for locals are often perceived to be unnecessary or even in the way; given good variable naming, it is often perfectly clear what's going on," the JEP states. "The need to provide a manifest type for every variable also accidentally encourages developers toward overly complex expressions; with a lower-ceremony declaration syntax, there is less disincentive to break complex chained or nested expressions into simpler ones."

The plan would be restricted to local variables with initializers, indexes in the enhanced for-loop, and locals declared in a traditional for-loop. "Quantitatively, we want that a substantial percentage of local variable declarations in real code bases can be converted using this feature, inferring an appropriate type."

OpenJDK serves as an open source Java SE implementation and is backed by Oracle. Java SE 9, Oracle's official version of the next generation of the platform, is due in a year. The JEP has the endorsement of Oracle's Mark Reinhold, chief architect of the company's Java platform group.

(www.infoworld.com)

Paul Krill

Zur Startseite