Interface ExecutionControl
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
-
DirectExecutionControl
,JdiDefaultExecutionControl
,JdiExecutionControl
,LocalExecutionControl
,RemoteExecutionControl
,StreamingExecutionControl
public interface ExecutionControl extends AutoCloseable
The audience for this Service Provider Interface is engineers wishing to implement their own version of the execution engine in support of the JShell API.
A Snippet is compiled into code wrapped in a 'wrapper class'. The execution engine is used by the core JShell implementation to load and, for executable Snippets, execute the Snippet.
Methods defined in this interface should only be called by the core JShell implementation.
- Since:
- 9
Nested Class Summary
Modifier and Type | Interface | Description |
---|---|---|
static final class |
ExecutionControl.ClassBytecodes |
Bundles class name with class bytecodes. |
static class |
ExecutionControl.ClassInstallException |
A class install (load or redefine) encountered a problem. |
static class |
ExecutionControl.EngineTerminationException |
Unbidden execution engine termination has occurred. |
static class |
ExecutionControl.ExecutionControlException |
The abstract base of all ExecutionControl exceptions. |
static class |
ExecutionControl.InternalException |
An internal problem has occurred. |
static class |
ExecutionControl.NotImplementedException |
The command is not implemented. |
static class |
ExecutionControl.ResolutionException |
An exception indicating that a DeclarationSnippet with unresolved references has been encountered. |
static class |
ExecutionControl.RunException |
The abstract base of of exceptions specific to running user code. |
static class |
ExecutionControl.StoppedException |
An exception indicating that an invoke(java.lang.String, java.lang.String) (or theoretically a varValue(java.lang.String, java.lang.String) ) has been interrupted by a stop() . |
static class |
ExecutionControl.UserException |
A 'normal' user exception occurred. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void |
addToClasspath |
Adds the path to the execution class path. |
void |
close() |
Shuts down this execution engine. |
Object |
extensionCommand |
Run a non-standard command (or a standard command from a newer version). |
static ExecutionControl |
generate |
Search for a provider, then create and return the ExecutionControl instance. |
static ExecutionControl |
generate |
Search for a provider, then create and return the ExecutionControl instance. |
String |
invoke |
Invokes an executable Snippet by calling a method on the specified wrapper class. |
void |
load |
Attempts to load new classes. |
void |
redefine |
Attempts to redefine previously loaded classes. |
void |
stop() |
Interrupts a running invoke. |
String |
varValue |
Returns the value of a variable. |
Method Details
load
void load(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
- Parameters:
-
cbcs
- the class name and bytecodes to load - Throws:
-
ExecutionControl.ClassInstallException
- exception occurred loading the classes, some or all were not loaded -
ExecutionControl.NotImplementedException
- if not implemented -
ExecutionControl.EngineTerminationException
- the execution engine has terminated
redefine
void redefine(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
- Parameters:
-
cbcs
- the class name and bytecodes to redefine - Throws:
-
ExecutionControl.ClassInstallException
- exception occurred redefining the classes, some or all were not redefined -
ExecutionControl.NotImplementedException
- if not implemented -
ExecutionControl.EngineTerminationException
- the execution engine has terminated
invoke
String invoke(String className, String methodName) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
- Parameters:
-
className
- the class whose method should be invoked -
methodName
- the name of method to invoke - Returns:
- the result of the execution or null if no result
- Throws:
-
ExecutionControl.UserException
- the invoke raised a user exception -
ExecutionControl.ResolutionException
- the invoke attempted to directly or indirectly invoke an unresolved snippet -
ExecutionControl.StoppedException
- if theinvoke()
was canceled bystop()
-
ExecutionControl.EngineTerminationException
- the execution engine has terminated -
ExecutionControl.InternalException
- an internal problem occurred ExecutionControl.RunException
varValue
String varValue(String className, String varName) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
- Parameters:
-
className
- the name of the wrapper class of the variable -
varName
- the name of the variable - Returns:
- the value of the variable
- Throws:
-
ExecutionControl.UserException
- formatting the value raised a user exception -
ExecutionControl.ResolutionException
- formatting the value attempted to directly or indirectly invoke an unresolved snippet -
ExecutionControl.StoppedException
- if the formatting the value was canceled bystop()
-
ExecutionControl.EngineTerminationException
- the execution engine has terminated -
ExecutionControl.InternalException
- an internal problem occurred ExecutionControl.RunException
addToClasspath
void addToClasspath(String path) throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
- Parameters:
-
path
- the path to add - Throws:
-
ExecutionControl.EngineTerminationException
- the execution engine has terminated -
ExecutionControl.InternalException
- an internal problem occurred
stop
void stop() throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
- Throws:
-
ExecutionControl.EngineTerminationException
- the execution engine has terminated -
ExecutionControl.InternalException
- an internal problem occurred
extensionCommand
Object extensionCommand(String command, Object arg) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
- Parameters:
-
command
- the non-standard command -
arg
- the commands argument - Returns:
- the commands return value
- Throws:
-
ExecutionControl.UserException
- the command raised a user exception -
ExecutionControl.ResolutionException
- the command attempted to directly or indirectly invoke an unresolved snippet -
ExecutionControl.StoppedException
- if the command was canceled bystop()
-
ExecutionControl.EngineTerminationException
- the execution engine has terminated -
ExecutionControl.NotImplementedException
- if not implemented -
ExecutionControl.InternalException
- an internal problem occurred ExecutionControl.RunException
close
void close()
No calls to methods on this interface should be made after close.
- Specified by:
-
close
in interfaceAutoCloseable
generate
static ExecutionControl generate(ExecutionEnv env, String name, Map<String,String> parameters) throws Throwable
ExecutionControl
instance.- Parameters:
-
env
- the execution environment (provided by JShell) -
name
- the name of provider -
parameters
- the parameter map. - Returns:
- the execution engine
- Throws:
-
Throwable
- an exception that occurred attempting to find or create the execution engine. -
IllegalArgumentException
- if no ExecutionControlProvider has the specifiedname
andparameters
.
generate
static ExecutionControl generate(ExecutionEnv env, String spec) throws Throwable
ExecutionControl
instance.- Parameters:
-
env
- the execution environment (provided by JShell) -
spec
- theExecutionControl
spec, which is described in the documentation of this package documentation. - Returns:
- the execution engine
- Throws:
-
Throwable
- an exception that occurred attempting to find or create the execution engine. -
IllegalArgumentException
- if no ExecutionControlProvider has the specifiedname
andparameters
. -
IllegalArgumentException
- ifspec
is malformed
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/jdk.jshell/jdk/jshell/spi/ExecutionControl.html