Snippet (Java SE 15 & JDK 15) (original) (raw)
Direct Known Subclasses:
[ErroneousSnippet](ErroneousSnippet.html "class in jdk.jshell")
, [ExpressionSnippet](ExpressionSnippet.html "class in jdk.jshell")
, [PersistentSnippet](PersistentSnippet.html "class in jdk.jshell")
, [StatementSnippet](StatementSnippet.html "class in jdk.jshell")
public abstract class Snippet extends Object
A Snippet represents a snippet of Java source code as passed toJShell.eval(java.lang.String). It is associated only with theJShell instance that created it. An instance of Snippet (including its subclasses) is immutable: an access to any of its methods will always return the same result. For information about the current state of the snippet within the JShell state engine, query JShell
passing the Snippet.
Because it is immutable, Snippet
(and subclasses) is thread-safe.
Since:
9
See Also:
JShell.status(jdk.jshell.Snippet)
Nested Class Summary
Nested Classes
Modifier and Type | Class | Description |
---|---|---|
static class | Snippet.Kind | Describes the general kind of snippet. |
static class | Snippet.Status | Describes the current state of a Snippet. |
static class | Snippet.SubKind | The detailed variety of a snippet. |
Method Summary
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)
Method Details
id
The unique identifier for the snippet. No two active snippets will have the same id(). Value of id has no prescribed meaning. The details of how the id is generated and the mechanism to change it is documented inJShell.Builder.idGenerator(BiFunction).
Returns:
the snippet id string.kind
The Snippet.Kind for the snippet. Indicates the subclass of Snippet.
Returns:
the Kind of the snippet
See Also:
Snippet.KindsubKind
Return the Snippet.SubKind of snippet. The SubKind is useful for feedback to users.
Returns:
the SubKind corresponding to this snippetsource
Return the source code of the snippet.
Returns:
the source code corresponding to this snippet