java.lang.Object
jdk.jshell.execution.DirectExecutionControl
- 所有已实现的接口:
-
AutoCloseable,ExecutionControl
- 直接已知的子类:
-
LocalExecutionControl,RemoteExecutionControl
一个在当前进程中运行的
ExecutionControl实现。可以直接使用,也可以通过通道与Util.forwardExecutionControl(ExecutionControl, java.io.ObjectInput, java.io.ObjectOutput)一起使用。
- 自版本:
- 9
-
Nested Class Summary
Nested classes/interfaces declared in interface jdk.jshell.spi.ExecutionControl
ExecutionControl.ClassBytecodes, ExecutionControl.ClassInstallException, ExecutionControl.EngineTerminationException, ExecutionControl.ExecutionControlException, ExecutionControl.InternalException, ExecutionControl.NotImplementedException, ExecutionControl.ResolutionException, ExecutionControl.RunException, ExecutionControl.StoppedException, ExecutionControl.UserException -
Constructor Summary
ConstructorsConstructorDescription使用默认类加载创建一个实例。DirectExecutionControl(LoaderDelegate loaderDelegate) 创建一个实例,将加载操作委托给指定的代理。 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToClasspath(String cp) 将路径添加到执行类路径。protected void通知已重新定义类。protected void标记进入用户代码。protected void标记离开用户代码。voidclose()关闭此执行引擎。extensionCommand(String command, Object arg) 运行非标准命令(或来自更新版本的标准命令)。protected Class<?> 查找具有指定二进制名称的类。protected String调用指定的“doit-method”,一个没有参数的静态方法。通过在指定的包装类上调用方法来调用可执行片段。voidload(ExecutionControl.ClassBytecodes[] cbcs) 尝试加载新类。void尝试重新定义先前加载的类。voidstop()中断正在运行的调用。protected String将用户代码中的传入异常转换为ExecutionControl.ExecutionControlException的子类型的实例,并抛出转换后的异常。protected String将代理代码中的传入异常转换为ExecutionControl.ExecutionControlException的子类型的实例,并抛出转换后的异常。protected static StringvalueString(Object value) 将ExecutionControl.invoke(String, String)或ExecutionControl.varValue(String, String)中的Object值转换为String。返回变量的值。
-
Constructor Details
-
DirectExecutionControl
创建一个实例,将加载操作委托给指定的代理。- 参数:
-
loaderDelegate- 处理加载类的代理
-
DirectExecutionControl
public DirectExecutionControl()使用默认类加载创建一个实例。
-
-
Method Details
-
load
public void load(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException 从接口中复制的描述:ExecutionControl尝试加载新类。- 指定者:
-
load在接口ExecutionControl中 - 参数:
-
cbcs- 要加载的类名和字节码 - 抛出:
-
ExecutionControl.ClassInstallException- 加载类时发生异常,一些或全部类未加载 -
ExecutionControl.NotImplementedException- 如果未实现 -
ExecutionControl.EngineTerminationException- 执行引擎已终止
-
redefine
public void redefine(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException 从接口中复制的描述:ExecutionControl尝试重新定义先前加载的类。- 指定者:
-
redefine在接口ExecutionControl中 - 参数:
-
cbcs- 要重新定义的类名和字节码 - 抛出:
-
ExecutionControl.ClassInstallException- 重新定义类时发生异常,一些或全部类未重新定义 -
ExecutionControl.NotImplementedException- 如果未实现 -
ExecutionControl.EngineTerminationException- 执行引擎已终止
-
classesRedefined
protected void classesRedefined(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException 通知已重新定义类。- 参数:
-
cbcs- 要重新定义的类名和字节码 - 抛出:
-
ExecutionControl.NotImplementedException- 如果未实现 -
ExecutionControl.EngineTerminationException- 执行引擎已终止
-
invoke
public String invoke(String className, String methodName) throws ExecutionControl.RunException, ExecutionControl.InternalException, ExecutionControl.EngineTerminationException 从接口中复制的描述:ExecutionControl通过在指定的包装类上调用方法来调用可执行片段。该方法必须没有参数并返回String。- 指定者:
-
invoke在接口ExecutionControl中 - 参数:
-
className- 应调用其方法的类 -
methodName- 要调用的方法的名称 - 返回:
- 执行结果,如果没有结果则为null
- 抛出:
-
ExecutionControl.UserException- 调用引发了用户异常 -
ExecutionControl.ResolutionException- 调用尝试直接或间接调用未解析的片段 -
ExecutionControl.StoppedException- 如果invoke()被ExecutionControl.stop()取消 -
ExecutionControl.InternalException- 发生内部问题 -
ExecutionControl.EngineTerminationException- 执行引擎已终止 -
ExecutionControl.RunException
-
varValue
public String varValue(String className, String varName) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException 从接口中复制的描述:ExecutionControl返回变量的值。- 指定者:
-
varValue在接口ExecutionControl中 - 参数:
-
className- 变量的包装类名称 -
varName- 变量的名称 - 返回:
- 变量的值
- 抛出:
-
ExecutionControl.UserException- 格式化值引发了用户异常 -
ExecutionControl.ResolutionException- 格式化值尝试直接或间接调用未解析的片段 -
ExecutionControl.StoppedException- 如果取消格式化值的操作由ExecutionControl.stop()执行 -
ExecutionControl.EngineTerminationException- 执行引擎已终止 -
ExecutionControl.InternalException- 发生内部问题 -
ExecutionControl.RunException
-
addToClasspath
public void addToClasspath(String cp) throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException 从接口中复制的描述:ExecutionControl将路径添加到执行类路径。- 指定者:
-
addToClasspath在接口ExecutionControl中 - 参数:
-
cp- 要添加的路径 - 抛出:
-
ExecutionControl.EngineTerminationException- 执行引擎已终止 -
ExecutionControl.InternalException- 发生内部问题
-
stop
public void stop() throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException中断正在运行的调用。不支持。
- 指定者:
-
stop在接口ExecutionControl中 - 抛出:
-
ExecutionControl.EngineTerminationException- 执行引擎已终止 -
ExecutionControl.InternalException- 发生内部问题
-
extensionCommand
public Object extensionCommand(String command, Object arg) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException 从接口中复制的描述:ExecutionControl运行非标准命令(或来自更新版本的标准命令)。- 指定者:
-
extensionCommand在接口ExecutionControl中 - 参数:
-
command- 非标准命令 -
arg- 命令的参数 - 返回:
- 命令的返回值
- 抛出:
-
ExecutionControl.UserException- 命令引发了用户异常 -
ExecutionControl.ResolutionException- 命令尝试直接或间接调用未解析的片段 -
ExecutionControl.StoppedException- 如果命令被ExecutionControl.stop()取消 -
ExecutionControl.EngineTerminationException- 执行引擎已终止 -
ExecutionControl.NotImplementedException- 如果未实现 -
ExecutionControl.InternalException- 发生内部问题 -
ExecutionControl.RunException
-
close
public void close()从接口中复制的描述:ExecutionControl关闭此执行引擎。实现应该释放此执行引擎持有的所有资源。在关闭后不应调用此接口上的方法。
- 指定者:
-
close在接口AutoCloseable中 - 指定者:
-
close在接口ExecutionControl中
-
findClass
查找具有指定二进制名称的类。- 参数:
-
name- 类的二进制名称 - 返回:
- 类对象
- 抛出:
-
ClassNotFoundException- 如果找不到类
-
invoke
调用指定的“doit-method”,一个没有参数的静态方法。此类中的invoke(java.lang.String, java.lang.String)将调用此方法来执行。- 参数:
-
doitMethod- 要调用的方法 - 返回:
- 值或null
- 抛出:
-
Exception- 由Method.invoke(Object, Object...)抛出的任何异常或任何ExecutionControl.ExecutionControlException传递。
-
valueString
将来自ExecutionControl.invoke(String, String)或ExecutionControl.varValue(String, String)的Object值转换为String。- 参数:
-
value- 要转换的值 - 返回:
-
String表示
-
throwConvertedInvocationException
protected String throwConvertedInvocationException(Throwable cause) throws ExecutionControl.RunException, ExecutionControl.InternalException 将用户代码中的传入异常转换为ExecutionControl.ExecutionControlException的子类型的实例,并抛出转换后的异常。- 参数:
-
cause- 要转换的异常 - 返回:
- 由于总是抛出,因此永远不会返回
- 抛出:
-
ExecutionControl.RunException- 用于正常异常发生 -
ExecutionControl.InternalException- 用于内部问题
-
throwConvertedOtherException
protected String throwConvertedOtherException(Throwable ex) throws ExecutionControl.RunException, ExecutionControl.InternalException 将代理代码中的传入异常转换为ExecutionControl.ExecutionControlException的子类型的实例,并抛出转换后的异常。- 参数:
-
ex- 要转换的异常 - 返回:
- 由于总是抛出,因此永远不会返回
- 抛出:
-
ExecutionControl.RunException- 用于正常异常发生 -
ExecutionControl.InternalException- 用于内部问题
-
clientCodeEnter
标记进入用户代码。- 抛出:
-
ExecutionControl.InternalException- 在意外失败情况下
-
clientCodeLeave
标记离开用户代码。- 抛出:
-
ExecutionControl.InternalException- 在意外失败情况下
-