-
- All Superinterfaces:
-
AutoCloseable
- 所有已知实现类:
-
DirectExecutionControl,JdiDefaultExecutionControl,JdiExecutionControl,LocalExecutionControl,RemoteExecutionControl,StreamingExecutionControl
public interface ExecutionControl extends AutoCloseable
该接口指定了实现可插拔JShell执行引擎必须提供的功能。该服务提供商接口的受众是希望实现自己的执行引擎版本以支持JShell API的工程师。
一个Snippet被编译成一个包装在“包装类”中的代码。 执行引擎由核心JShell实现使用,并且对于可执行代码段执行代码段。
此接口中定义的方法只能由核心JShell实现调用。
- 从以下版本开始:
- 9
-
-
Nested Class Summary
Nested Classes Modifier and Type 接口 描述 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发生“正常”用户异常。
-
方法摘要
所有方法 静态方法 接口方法 抽象方法 Default Methods Modifier and Type 方法 描述 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)通过调用指定的包装类上的方法来调用可执行代码段。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
通过调用指定的包装类上的方法来调用可执行代码段。 该方法必须没有参数并返回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格式错误
-
-