public class DirectExecutionControl extends Object implements ExecutionControl
ExecutionControl
implementation that runs in the current process.
May be used directly, or over a channel with
Util.forwardExecutionControl(ExecutionControl, java.io.ObjectInput, java.io.ObjectOutput)
.ExecutionControl.ClassBytecodes, ExecutionControl.ClassInstallException, ExecutionControl.EngineTerminationException, ExecutionControl.ExecutionControlException, ExecutionControl.Generator, ExecutionControl.InternalException, ExecutionControl.NotImplementedException, ExecutionControl.ResolutionException, ExecutionControl.RunException, ExecutionControl.StoppedException, ExecutionControl.UserException
Constructor and Description |
---|
DirectExecutionControl()
Create an instance using the default class loading.
|
DirectExecutionControl(LoaderDelegate loaderDelegate)
Creates an instance, delegating loader operations to the specified
delegate.
|
Modifier and Type | Method and Description |
---|---|
void |
addToClasspath(String cp)
Adds the path to the execution class path.
|
protected void |
clientCodeEnter()
Marks entry into user code.
|
protected void |
clientCodeLeave()
Marks departure from user code.
|
void |
close()
Shuts down this execution engine.
|
Object |
extensionCommand(String command,
Object arg)
Run a non-standard command (or a standard command from a newer version).
|
protected Class<?> |
findClass(String name)
Finds the class with the specified binary name.
|
protected String |
invoke(Method doitMethod)
Invoke the specified "doit-method", a static method with no parameters.
|
String |
invoke(String className,
String methodName)
Invokes an executable Snippet by calling a method on the specified
wrapper class.
|
void |
load(ExecutionControl.ClassBytecodes[] cbcs)
Attempts to load new classes.
|
void |
redefine(ExecutionControl.ClassBytecodes[] cbcs)
Attempts to redefine previously loaded classes.
|
void |
setClasspath(String path)
Sets the execution class path to the specified path.
|
void |
stop()
Interrupts a running invoke.
|
protected String |
throwConvertedInvocationException(Throwable cause)
Converts incoming exceptions in user code into instances of subtypes of
ExecutionControl.ExecutionControlException and throws the
converted exception. |
protected String |
throwConvertedOtherException(Throwable ex)
Converts incoming exceptions in agent code into instances of subtypes of
ExecutionControl.ExecutionControlException and throws the
converted exception. |
protected static String |
valueString(Object value)
Converts the
Object value from
ExecutionControl.invoke(String, String) or
ExecutionControl.varValue(String, String) to String . |
String |
varValue(String className,
String varName)
Returns the value of a variable.
|
public DirectExecutionControl()
public DirectExecutionControl(LoaderDelegate loaderDelegate)
loaderDelegate
- the delegate to handle loading classespublic void load(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
ExecutionControl
load
in interface ExecutionControl
cbcs
- the class name and bytecodes to loadExecutionControl.ClassInstallException
- exception occurred loading the classes,
some or all were not loadedExecutionControl.NotImplementedException
- if not implementedExecutionControl.EngineTerminationException
- the execution engine has terminatedpublic void redefine(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException, ExecutionControl.NotImplementedException, ExecutionControl.EngineTerminationException
ExecutionControl
redefine
in interface ExecutionControl
cbcs
- the class name and bytecodes to redefineExecutionControl.ClassInstallException
- exception occurred redefining the classes,
some or all were not redefinedExecutionControl.NotImplementedException
- if not implementedExecutionControl.EngineTerminationException
- the execution engine has terminatedpublic String invoke(String className, String methodName) throws ExecutionControl.RunException, ExecutionControl.InternalException, ExecutionControl.EngineTerminationException
ExecutionControl
invoke
in interface ExecutionControl
className
- the class whose method should be invokedmethodName
- the name of method to invokeExecutionControl.UserException
- the invoke raised a user exceptionExecutionControl.ResolutionException
- the invoke attempted to directly or
indirectly invoke an unresolved snippetExecutionControl.StoppedException
- if the invoke()
was canceled by
ExecutionControl.stop()
ExecutionControl.InternalException
- an internal problem occurredExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.RunException
public String varValue(String className, String varName) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
varValue
in interface ExecutionControl
className
- the name of the wrapper class of the variablevarName
- the name of the variableExecutionControl.UserException
- formatting the value raised a user exceptionExecutionControl.ResolutionException
- formatting the value attempted to directly or
indirectly invoke an unresolved snippetExecutionControl.StoppedException
- if the formatting the value was canceled by
ExecutionControl.stop()
ExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredExecutionControl.RunException
public void addToClasspath(String cp) throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
addToClasspath
in interface ExecutionControl
cp
- the path to addExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredpublic void setClasspath(String path) throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
setClasspath
in interface ExecutionControl
path
- the path to addExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredpublic void stop() throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
Not supported.
stop
in interface ExecutionControl
ExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.InternalException
- an internal problem occurredpublic Object extensionCommand(String command, Object arg) throws ExecutionControl.RunException, ExecutionControl.EngineTerminationException, ExecutionControl.InternalException
ExecutionControl
extensionCommand
in interface ExecutionControl
command
- the non-standard commandarg
- the commands argumentExecutionControl.UserException
- the command raised a user exceptionExecutionControl.ResolutionException
- the command attempted to directly or
indirectly invoke an unresolved snippetExecutionControl.StoppedException
- if the command was canceled by
ExecutionControl.stop()
ExecutionControl.EngineTerminationException
- the execution engine has terminatedExecutionControl.NotImplementedException
- if not implementedExecutionControl.InternalException
- an internal problem occurredExecutionControl.RunException
public void close()
ExecutionControl
No calls to methods on this interface should be made after close.
close
in interface ExecutionControl
protected Class<?> findClass(String name) throws ClassNotFoundException
name
- the binary name of the classClassNotFoundException
- if the class could not be foundprotected String invoke(Method doitMethod) throws Exception
invoke(java.lang.String, java.lang.String)
in this class will call this to invoke.doitMethod
- the Method to invokeException
- any exceptions thrown by
Method.invoke(Object, Object...)
or any ExecutionControl.ExecutionControlException
to pass-through.protected static String valueString(Object value)
Object
value from
ExecutionControl.invoke(String, String)
or
ExecutionControl.varValue(String, String)
to String
.value
- the value to convertString
representationprotected String throwConvertedInvocationException(Throwable cause) throws ExecutionControl.RunException, ExecutionControl.InternalException
ExecutionControl.ExecutionControlException
and throws the
converted exception.cause
- the exception to convertExecutionControl.RunException
- for normal exception occurrencesExecutionControl.InternalException
- for internal problemsprotected String throwConvertedOtherException(Throwable ex) throws ExecutionControl.RunException, ExecutionControl.InternalException
ExecutionControl.ExecutionControlException
and throws the
converted exception.ex
- the exception to convertExecutionControl.RunException
- for normal exception occurrencesExecutionControl.InternalException
- for internal problemsprotected void clientCodeEnter() throws ExecutionControl.InternalException
ExecutionControl.InternalException
- in unexpected failure casesprotected void clientCodeLeave() throws ExecutionControl.InternalException
ExecutionControl.InternalException
- in unexpected failure cases
Copyright © 2015, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-08-10-220919.robert.dev