Performance / JShell lightweight
Robert Field
robert.field at oracle.com
Mon Aug 14 21:27:05 UTC 2017
Yes, most of the time is spent in launching/setting-up the remote VM.
You can get local execution with:
jshell --execution local
This has downsides, for example if the executed code crashes/exits, so
does the shell.
This is kinda documented in:
jshell -X
and the SPI/API:
http://download.java.net/java/jdk9/docs/api/jdk/jshell/spi/package-summary.html
http://download.java.net/java/jdk9/docs/api/jdk/jshell/execution/package-summary.html
As to exiting a script, in general, simply use the "exit" command.
-Robert
On 08/14/17 13:33, Remi Forax wrote:
> Hi Robert,
>
> It's due to the fact that by default JShell starts a new VM (the remote VM) that will execute the code,
> if you just want to run the code, i think there is a way to run the script inside the same VM.
>
> I will let the other Robert (Field) or anyone on this list explain how to do this,
> i'm also interested by the answer (and the auto-exit at the end).
>
> cheers,
> Rémi
>
> ----- Mail original -----
>> De: "Robert Scholte" <rfscholte at apache.org>
>> À: kulla-dev at openjdk.java.net
>> Envoyé: Lundi 14 Août 2017 22:24:25
>> Objet: Performance / JShell lightweight
>> Hi,
>>
>> I've started a library which has the ability to divide a set of jars and
>> output directories over the classpath and modulepath. In order to get the
>> modulename it calls the Java 9 code for retrieving that name, i.e. via
>> ModuleFinder.
>> In case the library runs on Java 9, it can call the ModuleFinder directly.
>> But in case the library runs on Java 7 or Java 8, it requires a reference
>> to the Java 9 home.
>> With JShell it has become very easy to execute this code, otherwise I need
>> to have an executable-jar at runtime, put is somewhere where I can call it.
>>
>> However, this call to JShell takes several seconds to resolve, which feels
>> quite long. I'm looking for a way to reduce this time.
>>
>> I'm not interested in interaction with JShell, only interested in the
>> output. (in the end it is almost as simple as a main method with
>> System.out.println("Hello World"); )
>>
>> If the startup overhead is caused by building up the shell, can there be
>> an option introduced to just execute code without interactive shell (and
>> auto-exit at the end)?
>>
>> thanks,
>> Robert
More information about the kulla-dev
mailing list