- 所有超接口:
-
AutoCloseable
- 所有已知实现类:
-
DirectExecutionControl,JdiDefaultExecutionControl,JdiExecutionControl,LocalExecutionControl,RemoteExecutionControl,StreamingExecutionControl
该接口指定了必须提供的功能,以实现可插拔的JShell执行引擎。
此服务提供程序接口的受众是希望实现其自己版本的执行引擎以支持JShell API的工程师。
片段被编译为包装在“包装类”中的代码。执行引擎由核心JShell实现用于加载和执行片段。
此接口中定义的方法应仅由核心JShell实现调用。
- 自版本:
- 9
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class将类名与类字节码捆绑在一起。static class类安装(加载或重新定义)遇到问题。static class发生了未经邀请的执行引擎终止。static class所有ExecutionControl异常的抽象基类。static class发生了内部问题。static class该命令未实现。static class表示遇到具有未解析引用的DeclarationSnippet。static class运行用户代码特定异常的抽象基类。static class表示invoke(java.lang.String, java.lang.String)(或理论上varValue(java.lang.String, java.lang.String))被stop()中断。static class发生了“正常”的用户异常。 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToClasspath(String path) 将路径添加到执行类路径。voidclose()关闭此执行引擎。extensionCommand(String command, Object arg) 运行非标准命令(或来自更新版本的标准命令)。static ExecutionControlgenerate(ExecutionEnv env, String spec) 搜索提供程序,然后创建并返回ExecutionControl实例。static ExecutionControl搜索提供程序,然后创建并返回ExecutionControl实例。通过在指定的包装类上调用方法来调用可执行片段。voidload(ExecutionControl.ClassBytecodes[] cbcs) 尝试加载新类。void尝试重新定义先前加载的类。voidstop()中断正在运行的调用。返回变量的值。
-
Method Details
-
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 通过在指定的包装类上调用方法来调用可执行片段。该方法必须没有参数并返回String。- 参数:
-
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- 如果没有指定name和parameters的ExecutionControlProvider。
-
generate
搜索提供程序,然后创建并返回ExecutionControl实例。- 参数:
-
env- 执行环境(由JShell提供) -
spec-ExecutionControl规范,在此包文档中有描述。 - 返回:
- 执行引擎
- 抛出:
-
Throwable- 尝试查找或创建执行引擎时发生的异常。 -
IllegalArgumentException- 如果没有指定name和parameters的ExecutionControlProvider。 -
IllegalArgumentException- 如果spec格式不正确
-