Enum Class Snippet.Status
- All Implemented Interfaces:
Serializable, Comparable<Snippet.Status>, Constable
- Enclosing class:
Snippet
JShell
.
The Status
changes as the state changes.
For example, creation of another snippet with
eval
may resolve dependencies of this Snippet (or invalidate those dependencies), or
overwrite
this Snippet changing its
Status
.
Important properties associated with Status
are:
isDefined()
, if it is visible to other
existing and new snippets; and
isActive()
, if, as the
JShell state changes, the snippet will update, possibly
changing Status
.
An executable Snippet can only be executed if it is in the
VALID
Status
.
- Since:
- 9
- See Also:
-
Nested Class Summary
Nested classes/interfaces declared in class Enum
Enum.EnumDesc<E>
Modifier and TypeClassDescriptionstatic final class
Enum.EnumDesc<E extends Enum<E>>
A nominal descriptor for anenum
constant. -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe snippet is inactive because of an explicit call to theJShell.drop(Snippet)
.The snippet is inactive because it does not yet exist.The snippet is inactive because it has been replaced by a new snippet.The snippet is a declaration snippet with potentially recoverable unresolved references or other issues in its body (in the context of currentJShell
state).The snippet is a declaration snippet with potentially recoverable unresolved references or other issues (in the context of currentJShell
state).The snippet is inactive because it failed compilation on initial evaluation and it is not capable of becoming valid with further changes to the JShell state.The snippet is a valid snippet (in the context of currentJShell
state). -
Method Summary
Modifier and TypeMethodDescriptionboolean
isActive()
Indicates whether the Snippet is active, that is, will a persistent snippet be re-evaluated when a newJShell.eval(String)
orJShell.drop(Snippet)
that could change its status is invoked.boolean
Indicates whether the snippet is currently part of the defined state of the JShell.static Snippet.Status
Returns the enum constant of this class with the specified name.static Snippet.Status[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods declared in class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Modifier and TypeMethodDescriptionprotected final Object
clone()
Throws CloneNotSupportedException.final int
Compares this enum with the specified object for order.final Optional
<Enum.EnumDesc<Snippet.Status>> Returns an enum descriptorEnumDesc
for this instance, if one can be constructed, or an emptyOptional
if one cannot be.final boolean
Returns true if the specified object is equal to this enum constant.protected final void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization has been deprecated for removal.final Class
<Snippet.Status> Returns the Class object corresponding to this enum constant's enum type.final int
hashCode()
Returns a hash code for this enum constant.final String
name()
Returns the name of this enum constant, exactly as declared in its enum declaration.final int
ordinal()
Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).toString()
Returns the name of this enum constant, as contained in the declaration.static <T extends Enum<T>>
TReturns the enum constant of the specified enum class with the specified name.Methods declared in class Object
getClass, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionfinal Class
<?> getClass()
Returns the runtime class of thisObject
.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Enum Constant Details
-
VALID
The snippet is a valid snippet (in the context of currentJShell
state). Only snippets withVALID
Status
can be executed (though not allVALID
snippets have executable code).The snippet is defined (
isDefined() == true
). If the snippet is a declaration or import (Snippet.Kind.isPersistent()
), it is visible to other snippetsThe snippet will update as dependents change (
isActive() == true
), its status could becomeRECOVERABLE_DEFINED
,RECOVERABLE_NOT_DEFINED
,DROPPED
, orOVERWRITTEN
. -
RECOVERABLE_DEFINED
The snippet is a declaration snippet with potentially recoverable unresolved references or other issues in its body (in the context of currentJShell
state). Only aDeclarationSnippet
can have thisStatus
.The snippet has a valid signature and it is visible to other snippets (
isDefined() == true
) and thus can be referenced in existing or new snippets but the snippet cannot be executed. AnUnresolvedReferenceException
will be thrown on an attempt to execute it.The snippet will update as dependents change (
isActive() == true
), its status could becomeVALID
,RECOVERABLE_NOT_DEFINED
,DROPPED
, orOVERWRITTEN
.Note: both
RECOVERABLE_DEFINED
andRECOVERABLE_NOT_DEFINED
indicate potentially recoverable errors, they differ in that, forRECOVERABLE_DEFINED
, the snippet is defined. -
RECOVERABLE_NOT_DEFINED
The snippet is a declaration snippet with potentially recoverable unresolved references or other issues (in the context of currentJShell
state). Only aDeclarationSnippet
can have thisStatus
.The snippet has an invalid signature or the implementation is otherwise unable to define it. The snippet it is not visible to other snippets (
isDefined() == false
) and thus cannot be referenced or executed.The snippet will update as dependents change (
isActive() == true
), its status could becomeVALID
,RECOVERABLE_DEFINED
,DROPPED
, orOVERWRITTEN
.Note: both
RECOVERABLE_DEFINED
andRECOVERABLE_NOT_DEFINED
indicate potentially recoverable errors, they differ in that, forRECOVERABLE_DEFINED
, the snippet is defined. -
DROPPED
The snippet is inactive because of an explicit call to theJShell.drop(Snippet)
.The snippet is not visible to other snippets (
isDefined() == false
) and thus cannot be referenced or executed.The snippet will not update as dependents change (
isActive() == false
), itsStatus
will never change again. -
OVERWRITTEN
The snippet is inactive because it has been replaced by a new snippet. This occurs when the new snippet added witheval
matches a previous snippet. ATypeDeclSnippet
will match anotherTypeDeclSnippet
if the names match. For exampleclass X { }
will overwriteclass X { int ii; }
orinterface X { }
. AMethodSnippet
will match anotherMethodSnippet
if the names and parameter types match. For examplevoid m(int a) { }
will overwriteint m(int a) { return a+a; }
. AVarSnippet
will match anotherVarSnippet
if the names match. For exampledouble z;
will overwritelong z = 2L;
. Only aPersistentSnippet
can have thisStatus
.The snippet is not visible to other snippets (
isDefined() == false
) and thus cannot be referenced or executed.The snippet will not update as dependents change (
isActive() == false
), itsStatus
will never change again. -
REJECTED
The snippet is inactive because it failed compilation on initial evaluation and it is not capable of becoming valid with further changes to the JShell state.The snippet is not visible to other snippets (
isDefined() == false
) and thus cannot be referenced or executed.The snippet will not update as dependents change (
isActive() == false
), itsStatus
will never change again. -
NONEXISTENT
The snippet is inactive because it does not yet exist. Used only inSnippetEvent.previousStatus()
for new snippets.JShell.status(Snippet)
will never return thisStatus
.Vacuously,
isDefined()
andisActive()
are both definedfalse
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
isActive
public boolean isActive()Indicates whether the Snippet is active, that is, will a persistent snippet be re-evaluated when a newJShell.eval(String)
orJShell.drop(Snippet)
that could change its status is invoked. This is more broad thanisDefined()
since a Snippet which isRECOVERABLE_NOT_DEFINED
will be updated.- Returns:
true
if the Snippet is active; otherwisefalse
-
isDefined
public boolean isDefined()Indicates whether the snippet is currently part of the defined state of the JShell. Is it visible to compilation of other snippets?- Returns:
true
if the Snippet is defined; otherwisefalse
-