- 所有父级接口:
AutoCloseable
- 所有已知的实现类:
DirectExecutionControl,JdiDefaultExecutionControl,JdiExecutionControl,LocalExecutionControl,RemoteExecutionControl,StreamingExecutionControl
该接口指定了实现可插入 JShell 执行引擎所必须提供的功能。
此服务提供者接口的受众是希望实现自己版本的执行引擎以支持 JShell API 的工程师。
片段被编译成包装在“包装类”中的代码。核心 JShell 实现使用执行引擎来加载和执行代码段(对于可执行代码段)。
此接口中定义的方法只能由核心 JShell 实现调用。
- 自从:
- 9
-
内部类总结
内部类修饰符和类型接口描述static final class将类名称与类字节码捆绑在一起。static class类安装(加载或重新定义)遇到问题。static class发生意外执行引擎终止。static class所有ExecutionControl异常的抽象基础。static class发生内部问题。static class该命令未执行。static class异常表明遇到了具有未解析引用的DeclarationSnippet。static class特定于运行用户代码的异常的抽象基础。static classstatic class发生“正常”用户异常。 -
方法总结
修饰符和类型方法描述voidaddToClasspath(String path) 将路径添加到执行类路径。voidclose()关闭此执行引擎。extensionCommand(String command, Object arg) 运行非标准命令(或来自较新版本的标准命令)。static ExecutionControlgenerate(ExecutionEnv env, String spec) 搜索提供者,然后创建并返回ExecutionControl实例。static ExecutionControl搜索提供者,然后创建并返回ExecutionControl实例。通过调用指定包装器类上的方法来调用可执行代码段。voidload(ExecutionControl.ClassBytecodes[] cbcs) 尝试加载新类。void尝试重新定义以前加载的类。voidstop()中断正在运行的调用。返回变量的值。
-
方法详情
-
load
void load(ExecutionControl.ClassBytecodes [] cbcs) throws ExecutionControl.ClassInstallException , ExecutionControl.NotImplementedException , ExecutionControl.EngineTerminationException 尝试加载新类。- 参数:
cbcs- 要加载的类名和字节码- 抛出:
ExecutionControl.ClassInstallException- 加载类时发生异常,部分或全部未加载ExecutionControl.NotImplementedException- 如果没有实现ExecutionControl.EngineTerminationException- 执行引擎已终止
-
redefine
void redefine(ExecutionControl.ClassBytecodes [] cbcs) throws ExecutionControl.ClassInstallException , ExecutionControl.NotImplementedException , ExecutionControl.EngineTerminationException 尝试重新定义以前加载的类。- 参数:
cbcs- 要重新定义的类名和字节码- 抛出:
ExecutionControl.ClassInstallException- 重新定义类时发生异常,部分或全部未重新定义ExecutionControl.NotImplementedException- 如果没有实现ExecutionControl.EngineTerminationException- 执行引擎已终止
-
invoke
String invoke(String className, String methodName) throws ExecutionControl.RunException , ExecutionControl.EngineTerminationException , ExecutionControl.InternalException 通过调用指定包装器类上的方法来调用可执行代码段。该方法必须没有参数并返回字符串。- 参数:
className- 应调用其方法的类methodName- 要调用的方法的名称- 返回:
- 执行的结果,如果没有结果则为 null
- 抛出:
ExecutionControl.UserException- 调用引发了用户异常ExecutionControl.ResolutionException- 调用试图直接或间接调用未解析的片段ExecutionControl.StoppedException- 如果invoke()被stop()取消ExecutionControl.EngineTerminationException- 执行引擎已终止ExecutionControl.InternalException- 发生内部问题ExecutionControl.RunException
-
varValue
String varValue(String className, String varName) throws ExecutionControl.RunException , ExecutionControl.EngineTerminationException , ExecutionControl.InternalException 返回变量的值。- 参数:
className- 变量的包装类名称varName- 变量的名称- 返回:
- 变量的值
- 抛出:
ExecutionControl.UserException- 格式化值引发了用户异常ExecutionControl.ResolutionException- 格式化试图直接或间接调用未解析片段的值ExecutionControl.StoppedException- 如果格式化值被stop()取消ExecutionControl.EngineTerminationException- 执行引擎已终止ExecutionControl.InternalException- 发生内部问题ExecutionControl.RunException
-
addToClasspath
void addToClasspath(String path) throws ExecutionControl.EngineTerminationException , ExecutionControl.InternalException 将路径添加到执行类路径。- 参数:
path- 添加的路径- 抛出:
ExecutionControl.EngineTerminationException- 执行引擎已终止ExecutionControl.InternalException- 发生内部问题
-
stop
中断正在运行的调用。- 抛出:
ExecutionControl.EngineTerminationException- 执行引擎已终止ExecutionControl.InternalException- 发生内部问题
-
extensionCommand
Object extensionCommand(String command, Object arg) throws ExecutionControl.RunException , ExecutionControl.EngineTerminationException , ExecutionControl.InternalException 运行非标准命令(或来自较新版本的标准命令)。- 参数:
command- 非标准命令arg- 命令参数- 返回:
- 命令返回值
- 抛出:
ExecutionControl.UserException- 命令引发了用户异常ExecutionControl.ResolutionException- 该命令试图直接或间接调用未解析的片段ExecutionControl.StoppedException- 如果命令被stop()取消ExecutionControl.EngineTerminationException- 执行引擎已终止ExecutionControl.NotImplementedException- 如果没有实现ExecutionControl.InternalException- 发生内部问题ExecutionControl.RunException
-
close
void close()关闭此执行引擎。实现应释放此执行引擎持有的所有资源。关闭后不应调用此接口上的方法。
- 指定者:
close在接口AutoCloseable中
-
generate
static ExecutionControl generate(ExecutionEnv env, String name, Map <String , String > parameters) throws Throwable搜索提供者,然后创建并返回ExecutionControl实例。- 参数:
env——执行环境(JShell提供)name- 提供商的名称parameters- 参数图。- 返回:
- 执行引擎
- 抛出:
Throwable- 试图查找或创建执行引擎时发生的异常。IllegalArgumentException- 如果没有 ExecutionControlProvider 具有指定的name和parameters。
-
generate
搜索提供者,然后创建并返回ExecutionControl实例。- 参数:
env——执行环境(JShell提供)spec-ExecutionControl规范,在此 包装文件 的文档中进行了描述。- 返回:
- 执行引擎
- 抛出:
Throwable- 试图查找或创建执行引擎时发生的异常。IllegalArgumentException- 如果没有 ExecutionControlProvider 具有指定的name和parameters。IllegalArgumentException- 如果spec格式不正确
-