Public Repository

Last pushed: 2 years ago
Short Description
An image for testing JEP 286: Local-Variable Type Inference for Java
Full Description

JEP 286 enhances the Java Language to extend type inference to declarations of local variables with initializers. See more about it:

How it works

You can simply run the command below to see the version of javac:

$ docker run --rm kodcu/jep286
javac 9-internal

Let's say in your current directory you have a .java file called Example containing the following structure:

import java.util.ArrayList;

public class Example {
    public static void main(String...args) {    
        var messages = Stream.of(new Message("Hello"), new Message("world"));
                .forEach(System.out::println); // Hello World

        var answer = 40;        
        System.out.println(answer + 2); // prints 42

        var list = new ArrayList<String>();

        System.out.println(list.getClass()); // class java.util.ArrayList
        System.out.println(list); // [Hello, Duke]

    static class Message {
        private String content;
        public Message(String content) {
            this.content = content;
        public String getContent() {
            return this.content;

You can compile and run this class in order to see how JEP 286 interprets those statements. Mount your current directory into a directory in your container's file system (let's say src) to copy into the container, go into this directory, compile and run the code as follows:

$ docker run --rm -v $(PWD):/src -w /src kodcu/jep286 /bin/bash -c "javac && java Example"
class java.util.ArrayList
[Hello, Duke]
Docker Pull Command