public static enum Snippet.Status extends Enum<Snippet.Status>
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 the
VALID
Status
.
JShell.status(jdk.jshell.Snippet)
Enum Constant and Description |
---|
DROPPED
The snippet is inactive because of an explicit call to
the
JShell.drop(PersistentSnippet) . |
NONEXISTENT
The snippet is inactive because it does not yet exist.
|
OVERWRITTEN
The snippet is inactive because it has been replaced by a new
snippet.
|
RECOVERABLE_DEFINED
The snippet is a declaration snippet with potentially recoverable
unresolved references or other issues in its body
(in the context of current
JShell state). |
RECOVERABLE_NOT_DEFINED
The snippet is a declaration snippet with potentially recoverable
unresolved references or other issues
(in the context of current
JShell state). |
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.
|
VALID
The snippet is a valid snippet
(in the context of current
JShell state). |
Modifier and Type | Method and Description |
---|---|
boolean |
isActive()
Indicates whether the Snippet is active, that is,
will the snippet be re-evaluated when a new
JShell.eval(String) or
JShell.drop(PersistentSnippet) that could change
its status is invoked. |
boolean |
isDefined()
Indicates whether the snippet is currently part of the defined state
of the JShell.
|
static Snippet.Status |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Snippet.Status[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Snippet.Status DROPPED
JShell.drop(PersistentSnippet)
.
Only a PersistentSnippet
can have this
Status
.
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
), its
Status
will never change again.
public static final Snippet.Status NONEXISTENT
SnippetEvent.previousStatus
for new
snippets.
JShell.status(Snippet)
will never return this Status
.
Vacuously, isDefined()
and
isActive()
are both defined false
.
public static final Snippet.Status OVERWRITTEN
JShell.eval
matches a previous snippet.
A TypeDeclSnippet
will match another
TypeDeclSnippet
if the names match.
For example class X { }
will overwrite
class X { int ii; }
or
interface X { }
.
A MethodSnippet
will match another
MethodSnippet
if the names and parameter types
match.
For example void m(int a) { }
will overwrite
int m(int a) { return a+a; }
.
A VarSnippet
will match another
VarSnippet
if the names match.
For example double z;
will overwrite
long z = 2L;
.
Only a PersistentSnippet
can have this
Status
.
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
), its
Status
will never change again.
public static final Snippet.Status RECOVERABLE_DEFINED
JShell
state).
Only a DeclarationSnippet
can have this
Status
.
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.
An UnresolvedReferenceException
will be thrown on an attempt
to execute it.
The snippet will update as dependents change
(isActive() == true
), its
status could become VALID
, RECOVERABLE_NOT_DEFINED
,
DROPPED
, or OVERWRITTEN
.
Note: both RECOVERABLE_DEFINED
and RECOVERABLE_NOT_DEFINED
indicate potentially recoverable errors, they differ in that, for
RECOVERABLE_DEFINED
, the snippet is
defined.
public static final Snippet.Status RECOVERABLE_NOT_DEFINED
JShell
state).
Only a DeclarationSnippet
can have this
Status
.
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 become VALID
, RECOVERABLE_DEFINED
,
DROPPED
, or OVERWRITTEN
.
Note: both RECOVERABLE_DEFINED
and RECOVERABLE_NOT_DEFINED
indicate potentially recoverable errors, they differ in that, for
RECOVERABLE_DEFINED
, the snippet is
defined.
public static final Snippet.Status REJECTED
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
), its
Status
will never change again.
public static final Snippet.Status VALID
JShell
state).
Only snippets with VALID
Status
can be executed (though not all
VALID
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 snippets
The snippet will update as dependents change
(isActive() == true
), its
status could become RECOVERABLE_DEFINED
, RECOVERABLE_NOT_DEFINED
,
DROPPED
, or OVERWRITTEN
.
public static Snippet.Status[] values()
for (Snippet.Status c : Snippet.Status.values()) System.out.println(c);
public static Snippet.Status valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic boolean isActive()
JShell.eval(String)
or
JShell.drop(PersistentSnippet)
that could change
its status is invoked. This is more broad than
isDefined()
since a Snippet which is
RECOVERABLE_NOT_DEFINED
will be updated.true
if the Snippet is active; otherwise false
public boolean isDefined()
true
if the Snippet is defined; otherwise
false
Copyright © 2015, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-07-11-224625.robert.dev