java.lang.Object
jdk.jshell.execution.DirectExecutionControl
- 所有已实现的接口:
AutoCloseable,ExecutionControl
在当前进程中运行的
ExecutionControl 实现。可直接使用,或通过 Util.forwardExecutionControl(ExecutionControl, java.io.ObjectInput, java.io.ObjectOutput) 通道使用。
- 自从:
- 9
-
内部类总结
在接口 jdk.jshell.spi.ExecutionControl 中声明的嵌套类/接口
ExecutionControl.ClassBytecodes, ExecutionControl.ClassInstallException, ExecutionControl.EngineTerminationException, ExecutionControl.ExecutionControlException, ExecutionControl.InternalException, ExecutionControl.NotImplementedException, ExecutionControl.ResolutionException, ExecutionControl.RunException, ExecutionControl.StoppedException, ExecutionControl.UserException -
构造方法总结
构造方法 -
方法总结
修饰符和类型方法描述voidaddToClasspath(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) 将Object值从ExecutionControl.invoke(String, String)或ExecutionControl.varValue(String, String)转换为String。返回变量的值。
-
构造方法详细信息
-
DirectExecutionControl
创建一个实例,将加载器操作委托给指定的委托。- 参数:
loaderDelegate- 处理加载类的委托
-
DirectExecutionControl
public DirectExecutionControl()使用默认类加载创建实例。
-
-
方法详情
-
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复制的描述通过调用指定包装器类上的方法来调用可执行代码段。该方法必须没有参数并返回字符串。- 指定者:
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
将Object值从ExecutionControl.invoke(String, String)或ExecutionControl.varValue(String, String)转换为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- 在意外故障情况下
-