CSR :
|
|
Relates :
|
|
Relates :
|
Summary ------- Update the jshell tool to support the use of "preview" features. Problem ------- JEP 12 [1] describes JDK support for "preview" language and VM features.The jshell tool should support this as a documented flag. Solution -------- JEP 12 [1] describes how the compiler, VM and related toolchain might support preview features. A preview feature is, as per JEP description "a new feature of the Java SE Platform that is fully specified, fully implemented, and yet impermanent". In the jshell tool, support for preview features is enabled via a new command-line option, namely --enable-preview. This option effectively unlocks a new source level in which all preview features defined for a given Java SE release are enabled. Specification ------------- As part of this change, we plan to add a new jshell command-line flag, namely `--enable-preview`. If the `--enable-preview` flag is present, jshell will pass the `--enable-preview` and `-source N` (or equivalent) options to javac (via the compiler API) when compiling any snippets, where N is the current language version. And pass on the `--enable-preview` option on to the JVM for snippet execution. As always, errors and warnings from the compiler and JVM are forwarded to the user. See CSRs for preview in javac and the JVM: JDK-8200312 and JDK-8200440. If the `--enable-preview` flag is not present, jshell should continue to behave normally - e.g. as if preview features did not exist. As a result, any reference to preview features, either direct (e.g. directly in entered snippets) or indirect (e.g. through dependency on external classfiles) should result in an error. To help the user, jshell where possible (via the compiler) will signal that a preview feature was found but no corresponding `--enable-preview` flag was supplied. This change does not alter any of the public JShell API or SPI: `jdk.jshell`, `jdk.jshell.spi`, `jdk.jshell.execution`, or `jdk.jshell.tool`. Though `jdk.jshell.tool.JavaShellToolBuilder.run(String... arguments)` will successfully take the new option (the options accepted are not specified in this method/interface/package). --- [1] http://openjdk.java.net/jeps/12
|