-
- All Superinterfaces:
-
AutoCloseable
- 所有已知实现类:
-
DirectExecutionControl,JdiDefaultExecutionControl,JdiExecutionControl,LocalExecutionControl,RemoteExecutionControl,StreamingExecutionControl
public interface ExecutionControl extends AutoCloseable
此接口指定实现可插入JShell执行引擎必须提供的功能。此服务提供程序接口的受众是希望实现自己版本的执行引擎以支持JShell API的工程师。
Snippet被编译成包装在“包装类”中的代码。 核心JShell实现使用执行引擎来加载,对于可执行代码片段,执行Snippet。
此接口中定义的方法只能由核心JShell实现调用。
- 从以下版本开始:
- 9
-
-
嵌套类汇总
嵌套类 变量和类型 接口 描述 static classExecutionControl.ClassBytecodes使用类字节码捆绑类名。static classExecutionControl.ClassInstallException类安装(加载或重新定义)遇到问题。static classExecutionControl.EngineTerminationException已发生未绑定的执行引擎终止。static classExecutionControl.ExecutionControlException所有ExecutionControl异常的抽象基础。static classExecutionControl.InternalException发生了内部问题。static classExecutionControl.NotImplementedException该命令未实现。static classExecutionControl.ResolutionException表示遇到未解析引用的DeclarationSnippet的异常。static classExecutionControl.RunException特定于运行用户代码的异常的抽象基础。static classExecutionControl.StoppedExceptionstatic classExecutionControl.UserException发生“正常”用户异常。
-
方法摘要
所有方法 静态方法 实例方法 抽象方法 变量和类型 方法 描述 voidaddToClasspath(String path)添加执行类路径的路径。voidclose()关闭这个执行引擎。ObjectextensionCommand(String command, Object arg)运行非标准命令(或较新版本的标准命令)。static ExecutionControlgenerate(ExecutionEnv env, String spec)搜索提供程序,然后创建并返回ExecutionControl实例。static ExecutionControlgenerate(ExecutionEnv env, String name, Map<String,String> parameters)搜索提供程序,然后创建并返回ExecutionControl实例。Stringinvoke(String className, String methodName)通过调用指定的包装类上的方法来调用可执行的Snippet。voidload(ExecutionControl.ClassBytecodes[] cbcs)尝试加载新类。voidredefine(ExecutionControl.ClassBytecodes[] cbcs)尝试重新定义以前加载的类。voidstop()中断正在运行的调用。StringvarValue(String className, String varName)返回变量的值。
-
-
-
方法详细信息
-
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
通过调用指定的包装类上的方法来调用可执行的Snippet。 该方法必须没有参数并返回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
void stop() throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
中断正在运行的调用。- 异常
-
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()
关闭这个执行引擎。 实现应释放此执行引擎持有的所有资源。关闭后不应调用此接口上的方法。
- Specified by:
-
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
static ExecutionControl generate(ExecutionEnv env, String spec) throws Throwable
搜索提供程序,然后创建并返回ExecutionControl实例。- 参数
-
env- 执行环境(由JShell提供) -
spec-ExecutionControl规范,在此 package documentation的文档中描述。 - 结果
- 执行引擎
- 异常
-
Throwable- 尝试查找或创建执行引擎时发生的异常。 -
IllegalArgumentException- 如果没有ExecutionControlProvider具有指定的name和parameters。 -
IllegalArgumentException- 如果spec格式错误
-
-