JShell (Java SE 15 & JDK 15) (original) (raw)

All Implemented Interfaces:

[AutoCloseable](../../../java.base/java/lang/AutoCloseable.html "interface in java.lang")


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 methodseval(String),drop(Snippet) andaddToClasspath(String). The majority of methods query the state. A JShell instance also allows registering for events withonSnippetEvent(Consumer) and onShutdown(Consumer), which are unregistered withunsubscribe(Subscription). Access to the source analysis utilities is viasourceCodeAnalysis(). When complete the instance should be closed to free resources --close().

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

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

Since:

9

Nested Classes

Modifier and Type Class Description
static class JShell.Builder Builder for JShell instances.
class JShell.Subscription Subscription is a token for referring to subscriptions so they can be unsubscribed.

Methods declared in class java.lang.Object

[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)