2 min read

Last week, the early access builds for OpenJDK Project Valhalla’s LW2 phase was released, which was first proposed in October last year. LW2 is the next iteration of the L-World series that brings further language and JDK API support for inline types.

Proposed in 2014, Project Valhalla is an experimental OpenJDK project under which the team is working on major new language features and enhancements for Java 10 and beyond.

The new features and enhancements are being done in the following focus areas:

  • Value Types
  • Generic Specialization
  • Reified Generics
  • Improved ‘volatile’ support

The LW2 specifications

Javac source support

  • Starting from LW2, the prototype is based on mainline JDK (currently version 14). That is why it requires source-level >= JDK14.
  • To make a class declaration of inline type it uses the “inline class’ modifier or ‘@__inline__’ annotation.
  • Interfaces, annotation types, or enums cannot be declared as inline types. The top-level, inner, or local classes may be inline types.
  • As inline types are implicitly final, they cannot be abstract. Also, all instance fields of an inline class are implicitly final.
  • Inline types implicitly extend ‘java.lang.Object’ similar to enums, annotation types, and interfaces.
  • Supports “Indirect” projections of inline types via the “?” operator.
  • javac now allows using ‘==’ and ‘!=’ operators to compare inline type.

Java APIs

  • Among the new or modified APIs include ‘isInlineClass()’, ‘asPrimaryType()’, ‘asIndirectType()’, ‘isIndirectType()’, ‘asNullableType()’, and ‘isNullableType()’.
  • Now the ‘getName()’ method reflects the Q or L type signatures for arrays of inline types.
  • Using ‘newInstance()’ on an inline type will throw ‘NoSuchMethodException’ and ‘setAccessible()’ will throw ‘InaccessibleObjectException’.
  • With LW2, initial core Reflection and VarHandles support are in place.


  • When attempting to synchronize or call wait(*) or notify*() on an inline type IllegalMonitorException will be thrown.
  • ‘ClassCircularityError’ is thrown if loading an instance field of an inline type which declares its own type either directly
  • ‘NotSerializableException’ will be thrown if you are attempting to serialize an inline type.
  • If you are casting from indirect type to inline type, it may result in ‘NullPointerException’.

Download the early access binaries to test this prototype.

These were some of the specifications of LW2 iteration. Check out the full list of specification at OpenJDK’s official website. Also, stay tuned with the current happenings in Project Valhalla.

Read Next

Getting started with Z Garbage Collector(ZGC) in Java 11 [Tutorial]

Storm 2.0.0 releases with Java enabled architecture, new core and streams API, and more

Firefox 67 will come with faster and reliable JavaScript debugging tools