AutoCloseable
, ExecutionControl
LocalExecutionControl
, RemoteExecutionControl
public class DirectExecutionControl extends Object implements ExecutionControl
ExecutionControl
implementation that runs in the current process. May be used directly, or over a channel with Util.forwardExecutionControl(ExecutionControl, java.io.ObjectInput, java.io.ObjectOutput)
.ExecutionControl.ClassBytecodes, ExecutionControl.ClassInstallException, ExecutionControl.EngineTerminationException, ExecutionControl.ExecutionControlException, ExecutionControl.InternalException, ExecutionControl.NotImplementedException, ExecutionControl.ResolutionException, ExecutionControl.RunException, ExecutionControl.StoppedException, ExecutionControl.UserException
Constructor | Description |
---|---|
DirectExecutionControl() |
Create an instance using the default class loading. |
DirectExecutionControl |
Creates an instance, delegating loader operations to the specified delegate. |
Modifier and Type | Method | Description |
---|---|---|
void |
addToClasspath |
Adds the path to the execution class path. |
protected void |
classesRedefined |
Notify that classes have been redefined. |
protected void |
clientCodeEnter() |
Marks entry into user code. |
protected void |
clientCodeLeave() |
Marks departure from user code. |
void |
close() |
Shuts down this execution engine. |
Object |
extensionCommand |
Run a non-standard command (or a standard command from a newer version). |
protected Class |
findClass |
Finds the class with the specified binary name. |
protected String |
invoke |
Invoke the specified "doit-method", a static method with no parameters. |
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. |
protected String |
throwConvertedInvocationException |
Converts incoming exceptions in user code into instances of subtypes of ExecutionControl.ExecutionControlException and throws the converted exception. |
protected String |
throwConvertedOtherException |
Converts incoming exceptions in agent code into instances of subtypes of ExecutionControl.ExecutionControlException and throws the converted exception. |
protected static String |
valueString |
Converts the Object value from ExecutionControl.invoke(String, String) or ExecutionControl.varValue(String, String) to String . |
String |
varValue |
Returns the value of a variable. |
public DirectExecutionControl(LoaderDelegate loaderDelegate)
loaderDelegate
- the delegate to handle loading classespublic DirectExecutionControl()
public void load(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
ExecutionControl
load
in interface ExecutionControl
cbcs
- the class name and bytecodes to loadExecutionControl.ClassInstallException
- exception occurred loading the classes, some or all were not loadedExecutionControl.NotImplementedException
- if not implementedExecutionControl.EngineTerminationException
- the execution engine has terminatedpublic void redefine(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
ExecutionControl
redefine
in interface ExecutionControl
cbcs
- the class name and bytecodes to redefineExecutionControl.ClassInstallException
- exception occurred redefining the classes, some or all were not redefinedExecutionControl.NotImplementedException
- if not implementedExecutionControl.EngineTerminationException
- the execution engine has terminatedprotected void classesRedefined(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
cbcs
- the class name and bytecodes to redefineExecutionControl.NotImplementedException
- if not implementedExecutionControl.EngineTerminationException
- the execution engine has terminatedpublic String invoke(String className, String methodName) throws ExecutionControl.RunException, ExecutionControl.InternalException, ExecutionControl.EngineTerminationException
ExecutionControl
invoke
in interface ExecutionControl
className
- the class whose method should be invokedmethodName
- the name of method to invokeExecutionControl.UserException
- the invoke raised a user exceptionExecutionControl.ResolutionException
- the invoke attempted to directly or indirectly invoke an unresolved snippetExecutionControl.StoppedException
- if the invoke()
was canceled by ExecutionControl.stop()
ExecutionControl.InternalException
- an internal problem occurredExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.RunException
public String varValue(String className, String varName) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
varValue
in interface ExecutionControl
className
- the name of the wrapper class of the variablevarName
- the name of the variableExecutionControl.UserException
- formatting the value raised a user exceptionExecutionControl.ResolutionException
- formatting the value attempted to directly or indirectly invoke an unresolved snippetExecutionControl.StoppedException
- if the formatting the value was canceled by ExecutionControl.stop()
ExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredExecutionControl.RunException
public void addToClasspath(String cp) throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
addToClasspath
in interface ExecutionControl
cp
- the path to addExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredpublic void stop() throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
Not supported.
stop
in interface ExecutionControl
ExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredpublic Object extensionCommand(String command, Object arg) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
extensionCommand
in interface ExecutionControl
command
- the non-standard commandarg
- the commands argumentExecutionControl.UserException
- the command raised a user exceptionExecutionControl.ResolutionException
- the command attempted to directly or indirectly invoke an unresolved snippetExecutionControl.StoppedException
- if the command was canceled by ExecutionControl.stop()
ExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.NotImplementedException
- if not implementedExecutionControl.InternalException
- an internal problem occurredExecutionControl.RunException
public void close()
ExecutionControl
No calls to methods on this interface should be made after close.
close
in interface AutoCloseable
close
in interface ExecutionControl
protected Class<?> findClass(String name) throws ClassNotFoundException
name
- the binary name of the classClassNotFoundException
- if the class could not be foundprotected String invoke(Method doitMethod) throws Exception
invoke(java.lang.String, java.lang.String)
in this class will call this to invoke.doitMethod
- the Method to invokeException
- any exceptions thrown by Method.invoke(Object, Object...)
or any ExecutionControl.ExecutionControlException
to pass-through.protected static String valueString(Object value)
Object
value from ExecutionControl.invoke(String, String)
or ExecutionControl.varValue(String, String)
to String
.value
- the value to convertString
representationprotected String throwConvertedInvocationException(Throwable cause) throws ExecutionControl.RunException, ExecutionControl.InternalException
ExecutionControl.ExecutionControlException
and throws the converted exception.cause
- the exception to convertExecutionControl.RunException
- for normal exception occurrencesExecutionControl.InternalException
- for internal problemsprotected String throwConvertedOtherException(Throwable ex) throws ExecutionControl.RunException, ExecutionControl.InternalException
ExecutionControl.ExecutionControlException
and throws the converted exception.ex
- the exception to convertExecutionControl.RunException
- for normal exception occurrencesExecutionControl.InternalException
- for internal problemsprotected void clientCodeEnter() throws ExecutionControl.InternalException
ExecutionControl.InternalException
- in unexpected failure casesprotected void clientCodeLeave() throws ExecutionControl.InternalException
ExecutionControl.InternalException
- in unexpected failure cases
© 1993, 2023, 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/21/docs/api/jdk.jshell/jdk/jshell/execution/DirectExecutionControl.html