There has been significant public-facing progress in the past few weeks (June/July 2019) for
originally proposed in October 2018. In this post, I briefly summarize some of the messages, documents, and Valhalla Early Access Builds that have been released recently. LW2 is described in the
Valhalla Wiki page as an early prototype that "[moves] inline types into the existing type system."
Draft LW2 (JVM) Spec
Dan Smith announced "a first look at a preview-feature-quality spec for values/inline classes" on the
valhalla-spec-experts mailing list in a message titled "
Draft LW2 spec." That message sought feedback on the initial specification and
has been updated based on that feedback. This is a work-in-progress, but the URL
http://cr.openjdk.java.net/~dlsmith/inline-classes is currently setup to redirect to the current version of the draft specification.
Everything related to Valhalla is a work-in-progress and might change at some point, but it is interesting to read in
this draft spec the direction Valhalla is currently headed from the JVM specification perspective. Here is a sample of some of the document's more interesting points (that are subject to change):
- "This document describes changes to the Java Virtual Machine Specification, as modified by
Improved Treatment of JVM Types, to support inline classes."
- "There are five kinds of
referencetypes: identity class types, inline class types, array types, interface types, and the Object type. Their values are references to objects."
- "Most reference types are nullable, meaning the special null reference (representing the absence of an object) is a value of the type. Some reference types are null-free, meaning that null is not a value of the type."
- "An identity class type names a non-inline, non-interface class defined in a class file (excluding the special class Object). Identity class types are nullable."
- "An inline class type names an inline class defined in a
classfile. For each inline class, there is a nullable and a null-free inline class type; these types share the same set of values, with the exception of
- "An array type consists of a component type with a single dimension (whose length is not given by the type). The component type of an array type may be
boolean, any numeric type, or any reference type. Array types are nullable."
- "An interface type names an interface defined in a
classfile. Interface types are nullable."
Objecttype names the
Objecttype is nullable. ... Instances of the
Objectclass have identity but no fields, and behave like identity class instances."
- "The default value of a nullable reference type is null. The default value of a null-free inline class type is a reference to a class instance whose fields all have the default value for their type."
OpenJDK Valhalla Wiki: L-World
OpenJDK Valhalla Wiki page "
L-World" asks and answers the questions "
What Are Inline Types?" and "
What is the L-World Project?" In answering those questions, the page currently describes Inline Types as "small, immutable, identity-less types" that were "
formerly known as 'Value Types'" and are
now known as "inline-types." The current page describes the "L-World Project" as "a series of early
prototypes for bring[ing] Inline Types to the language and JDK" that "builds on work of the previous
Minimal Values Types prototype (MVT)."
OpenJDK Valhalla Wiki: LW2
OpenJDK Valhalla Wiki page "
LW2" describes the LW2 prototype as "an iteration of a previous prototype, adding further language support and JDK API support for 'inline types' (formerly referred to as 'value types')." The page indicates that the LW2 prototype is based on the
branch and the page includes several current characteristics of "inline types," some of which I list here:
- "Inline Types may not declare an explicit super class (except Object)."
- "All instance fields of a inline class are implicitly final."
- "'Indirect' projections of inline types via the '?' operator."
- "javac automatically generates
toStringcomputed solely from the instance's state and not from its identity"
- "javac allows comparison of inline type using
- "Inline Types can not be assigned null, null can not be cast to or compared with inline types With the exception of an 'indirect' reference using the '?' operator."
- New methods to potentially be added to
- Inline types cannot be
synchronized on, cannot be
serialized, cannot reference themselves as direct fields, and cannot be assigned
Valhalla Early Access Builds
As of this writing, the
Valhalla Early Access Builds page (now renamed "Project Valhalla 'L-World Inline Types' Early-Access Builds") features "Build jdk-14-valhalla+1-8 (2019/7/4)." The page opens with the paragraph, "This is an early access build, from
Project Valhalla, aimed at testing a prototype implementation of
L-World Inline Types." The page also mentions, "This build is based on an incomplete version of JDK 14." As is typical for early access builds, there are limitations and disclaimers regarding use of an early access build. It
sounds like there are plans to periodically update these builds "with bug fixes and performance updates."
OpenJDK Valhalla Wiki: LW2 Command Line Options/p>
For developers wanting to test out the LW2 prototype, command-line options are listed in the
OpenJDK Valhalla Wiki page "
LW2 Command Line Options." As stated on the page itself, it "describes the command line for the experimental Java compiler, the Java launcher and HotSpot JVM for the support of L-World LW2 Inline Types in the Valhalla project."
Meeting Minutes from 19 June 2019 Valhalla Expert Group Meeting
Karen Kinnear has provided
meeting minutes from the 19 June 2019 Valhalla Expert Group Meeting that provide insight into design topics on the minds of the expert group ("nullable", "flattenable", "inlinability", "specialized generics"). The notes indicate that the LW2 specification draft discussion is not intended to finalize all design decisions.
There's still quite a bit of work required for "inline types" (formerly "values types") to be fully introduced to Java. However, the current focus on "inline types" and the artifacts and builds associated with this concept are evidence that progress is being made in a concrete direction.