|Written by Kay Ewbank|
|Tuesday, 05 August 2014|
Oracle has announced an experimental OpenJDK project for trialing new features for Java.
Project Valhalla for Java is in its early experimental stages, and it will be well into the future – past JDK in 2016 – before any changes to the language syntax will be incorporated into Java. The proposed initial enhancements are support for generics over primitives, and for value types.
In the announcement of the project Oracle’s Brian Goetz describes it as Oracle’s
“incubation grounds for advanced language-VM co-development projects such as Value Types (http://cr.openjdk.java.net/~jrose/values/values-0.html)
and Generic Specialization
Goetz says that it is likely that the first several rounds will not look anything like the final result, adding
“don't assume that just because the prototype operates by name mangling, or classfile mangling, or requires the operator to do the Chicken Dance, that this is the ultimate plan – it’s just an expedient way to get to the point where we can experiment with something tangible.”
One area Oracle is looking at changing is the way Java handles generic types. At the moment, generic type arguments are constrained to extend Object, meaning that they are not compatible with primitive instantiations unless boxing is used, which undermines performance. In other words you can't write a generic sort that works with integers or floats without wrapping them as objects.
The proposal is that Java will support specialization of generic classes and interfaces when instantiated with primitive type arguments. Generic specialization is a feature that many developers have requested and that has already been added to some other JVM languages.
The second major idea proposed for Valhalla is value types. Describing them on OpenJDK as “Codes like a class, works like an int,” the Valhalla team of John Rose, Brian Goetz, and Guy Steele say the idea is to add support for small, immutable, value types with no identity.
Developers would be able to use them as though they were a new user-defined primitive type added to the current list of eight hardwired primitive types: byte, short, int, long, float, double, char, and boolean. The Valhalla team expects to borrow most of the definition and encapsulation machinery from classes, allowing users to easily and safely build new value-based data structures. They say:
“in particular, we believe that it is useful, both at the JVM and language levels, to regard value type definitions as specially marked, specially restricted class definitions.”
If you’re interested in keeping track of Valhalla, you can subscribe to the valhalla-dev mailing list.
It is worth keeping in mind the Wikipedia entry on Valhalla:
"Valhalla (from Old Norse Valhöll "hall of the slain") ... half of those who die in combat travel to Valhalla upon death..."
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: email@example.com
|Last Updated ( Tuesday, 05 August 2014 )|