LW2 is an iteration of a previous prototype, adding further language support and JDK API support for "inline types" (formerly referred to as "value types"). There are also subtle type system, runtime and JIT changes

Javac source support:

Java APIs:

Runtime:

Limitations for LW2

This is still a prototype with a lot of components ignored.

Future Possibilities

How to Try L-World Inline Types

Target Audience

Early Access Binaries

http://jdk.java.net/valhalla/

Change log:

Repository and Build Instructions

To create a new local repository, based on "lworld" branch:

hg clone http://hg.openjdk.java.net/valhalla/valhalla valhalla-lworld

cd valhalla-lworld

hg defpath du <openjdkname> 

hg update -r lw2 // name of branch

To update repository: 

cd valhalla-lworld

hg pull

hg update -r lw2  // name of branch

To build repository

bash configure

make images


Instructions for working with branch repositories: http://cr.openjdk.java.net/~chegar/docs/sandbox.html

Note: Valhalla is a child of the jdk/jdk repository, to keep current with latest OpenJDK development.

Programming Model

public inline class InlineType implements Comparable<InlineType?> {
 
    int someValue;
 
    public InlineType(int value) {
        this.someValue = value;
        /*
          implicitly generates "defaultvalue" followed by "withfield" bytecodes
 
          cannot pass "this" from here
         */
    }
 
    // Since existing API can accept "null", we use the indirect projection
    public int compareTo(InlineType? other) {
        if (other == null) {
            return -1;
        }
        return someValue - other.someValue;
    }
 
    public static void main(String[] args) throws Throwable {
        InlineType def = InlineType.default;
        assert(def == new InlineType(0));
 
        InlineType[] inlineTypeArray = new InlineType[1];
        // Inline type array cannot store null
        assert(inlineTypeArray[0] == def);
 
        InlineType?[] indirectTypeArray = new InlineType?[1];
        // Indirect projection of Inline type array can store null
        assert(indirectTypeArray[0] == null);
    }
}

A note on "?" operator and indirect projections

This is really only the beginning of a compatibility story, there is more to come (e.g. "null-default inline types"). Today it is a stop gap measure to enable use of current generics, until we get real generic specialization in place. New code should avoid indirect "?" like the plague and only use it for interfacing with code that must deal with "null" (e.g. current generics with type erasure). A good performance story does not exist for indirect, and it is not likely to improve too much in the future.

Run Experimental L-World

Helpful Feedback Please

This is intended as an early prototype to give you a chance to experiment and provide feedback on the currently supported features.

Please ensure you are on the latest EA binaries before reporting a problem.

Bugs are tracked in JIRA: Start summary with /[lworld/] and label "lworld". You can search for known problems or already reported bugs.

Send email to valhalla-dev@openjdk.java.net 

Too Early for Feedback

This is intended as an early prototype to give you a chance to experiment and provide feedback on the currently supported features.

At this time it would premature to provide feedback on

References