Local Variable Type Inference - prototype
Remi Forax
forax at univ-mlv.fr
Thu Mar 10 22:21:49 UTC 2016
At least, jshell need some tweaks :)
$ /usr/jdk/jdk-9/bin/java -Xbootclasspath/p:langtools/dist/lib/jdk.compiler.jar:langtools/dist/lib/jdk.jshell.jar:langtools/dist/lib/jdk.internal.le.jar:langtools/dist/lib/jdk.jdi.jar jdk.internal.jshell.tool.JShellTool
| Welcome to JShell -- Version 9-internal
| Type /help for help
-> void m() {
>> var a = 3;
>> }
| Added method m()
-> m()
-> var a = 3;
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin -1, end -1, length 10
at java.lang.String.checkBoundsBeginEnd(String.java:3122)
at java.lang.String.substring(String.java:1910)
at jdk.jshell.Wrap$Range.part(Wrap.java:168)
at jdk.jshell.Wrap$RangeWrap.<init>(Wrap.java:350)
at jdk.jshell.Wrap.varWrap(Wrap.java:97)
at jdk.jshell.Eval.processVariables(Eval.java:227)
at jdk.jshell.Eval.eval(Eval.java:116)
at jdk.jshell.JShell.eval(JShell.java:355)
at jdk.internal.jshell.tool.JShellTool.processCompleteSource(JShellTool.java:1923)
at jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:1911)
at jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:652)
at jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:632)
at jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:427)
at jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:400)
at jdk.internal.jshell.tool.JShellTool.main(JShellTool.java:390)
Rémi
----- 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