Local Variable Type Inference - prototype

Remi Forax forax at univ-mlv.fr
Thu Mar 10 16:35:36 UTC 2016

For those that find that the message of Maurizio was mysterious :)
here is a more detailed instructions
 1. you need to download a binary version of jdk9 from here

 2. you need a recent version of ant (that includes support of jdk9 perhaps ?, ant 1.9.5 works for me)

 3. clone the repository
    hg clone http://hg.openjdk.java.net/jdk9/sandbox/langtools

 4. switch to the branch "JEP-286-branch"
    hg update JEP-286-branch

 5. use ant to compile javac
    cd langtools/make
    export ANT_HOME=my_path_to_ant
    export JAVA_HOME=my_path_to_jkd9
    ant -Dboot.java.home=my_path_to_jdk9

 6. ant has generated a jar in langtools/dist name jdk.compiler.jar,
    to run javac
    path_to_jdk9/bin/java -Xbootclasspath/p:langtools/dist/lib/jdk.compiler.jar com.sun.tools.javac.Main VarTest.java

 6.bis. you can also ask javac which local variables can be declared using var with no compatibility issue
    path_to_jdk9/bin/java -Xbootclasspath/p:langtools/dist/lib/jdk.compiler.jar com.sun.tools.javac.Main -XDfind=local VarTest.java

happy testing,

----- Mail original -----
> De: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>
> À: platform-jep-discuss at openjdk.java.net
> Envoyé: Jeudi 10 Mars 2016 15:48:25
> Objet: Local Variable Type Inference - prototype
> Hi,
> I've pushed the first iteration of the local variable type inference
> prototype in the sandbox repository[1]. For those willing and brave
> enough to experiment, the branch name is "JEP-286-branch". We are also
> working to get some ready-made binary snapshots out of the door and hope
> to have an update on that soon.
> This first iteration supports the 'var-only' syntax style:
> var s = "Hello!";
> That is, the type of 's' is inferred from the initializer, and no
> special assumption is made about mutability.
> Please share your experience with the prototype. For comments on this
> feature please refer to the survey[2] that Brian posted few days ago.
> Maurizio
> [1] - http://cr.openjdk.java.net/~chegar/docs/sandbox.html
> [2] -
> http://mail.openjdk.java.net/pipermail/platform-jep-discuss/2016-March/000037.html

More information about the platform-jep-discuss mailing list