Module jdk.jshell
Package jdk.jshell

Class JShell

java.lang.Object
jdk.jshell.JShell
All Implemented Interfaces:
AutoCloseable

public class JShell extends Object implements AutoCloseable
The JShell evaluation state engine. This is the central class in the JShell API. A JShell instance holds the evolving compilation and execution state. The state is changed with the instance methods eval(String), drop(Snippet) and addToClasspath(String). The majority of methods query the state. A JShell instance also allows registering for events with onSnippetEvent(Consumer) and onShutdown(Consumer), which are unregistered with unsubscribe(Subscription). Access to the source analysis utilities is via sourceCodeAnalysis(). When complete the instance should be closed to free resources -- close().

An instance of JShell is created with JShell.create().

This class is not thread safe, except as noted, all access should be through a single thread.

Since:
9