jshell --enable-preview --execution=local bug?

Max Rydahl Andersen manderse at redhat.com
Tue May 16 22:52:02 UTC 2023


Hi,

As part of adding `--enable-preview` support to [JBang 
0.107](https://github.com/jbangdev/jbang/releases/tag/v0.107.0) I 
spotted this discrepancy in jshell behaviour. Is this to be expected or 
a bug?

First what is expected right behaviour:

```bash
$ jshell --enable-preview
|  Welcome to JShell -- Version 21-ea
|  For an introduction type: /help intro

jshell> var name="test"; STR."\{name} test";
name ==> "test"
$2 ==> "test test"

jshell> $2.length();
$3 ==> 9
```

but now when running with `--execution=local`:

```bash
jshell --enable-preview --execution=local
|  Welcome to JShell -- Version 21-ea
|  For an introduction type: /help intro

jshell> var name="test"; STR."\{name} test";
name ==> "test"
$2 ==>

jshell> $2.length();
|  Exception java.lang.UnsupportedClassVersionError: Preview features 
are not enabled for REPL/$JShell$12 (class file version 65.65535). Try 
running with '--enable-preview'
|        at ClassLoader.defineClass1 (Native Method)
|        at ClassLoader.defineClass (ClassLoader.java:1018)
|        at SecureClassLoader.defineClass (SecureClassLoader.java:150)
|        at DefaultLoaderDelegate$RemoteClassLoader.findClass 
(DefaultLoaderDelegate.java:156)
|        at ClassLoader.loadClass (ClassLoader.java:593)
|        at ClassLoader.loadClass (ClassLoader.java:526)
|        at (#3:1)
```

I found that by duplicating `--enable-preview` in runtime options fixes 
things:

```
$ jshell --enable-preview --execution=local -J--enable-preview
|  Welcome to JShell -- Version 21-ea
|  For an introduction type: /help intro

jshell> var name="test"; STR."\{name} test";
name ==> "test"
$2 ==> "test test"

jshell> $2.length();
$3 ==> 9
```

Seems like a bug to me, wdyt? and where to open/report this best or is 
it enough here?

/max
https://xam.dk/about
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/kulla-dev/attachments/20230517/2481393a/attachment.htm>


More information about the kulla-dev mailing list