T
- The class or subclass of JNIHandleSet
containg the JNI handles this agent
requires.public abstract class JvmtiAgentBase<T extends JNIHandleSet> extends Object
JNIHandleSet
.JNIHandleSet
class}.org.graalvm.nativeimage.hosted.Feature
that will register the agent using
JvmtiAgentBase.registerAgent(JvmtiAgentBase)
in its'
org.graalvm.nativeimage.hosted.Feature#afterRegistration
callback.CEntryPoint
that matches the signature
(parameters and the return type) of the desired JVMTI event. The method must also be annotated
with CEntryPointOptions
and must use the AgentIsolate.Prologue
prologue.CEntryPointLiteral
from your callback method.JvmtiAgentBase.onLoadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM, com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEnv, com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEventCallbacks, java.lang.String)
method.JvmtiEventMode
.Constructor and Description |
---|
JvmtiAgentBase() |
Modifier and Type | Method and Description |
---|---|
protected abstract JNIHandleSet |
constructJavaHandles(com.oracle.svm.jni.nativeapi.JNIEnvironment env)
Callback method that should create your subclass of
JNIHandleSet . |
protected abstract int |
getRequiredJvmtiVersion()
Returns the JVMTI version required by the agent.
|
T |
handles()
Returns the JNI handle set constructed with
JvmtiAgentBase.constructJavaHandles(com.oracle.svm.jni.nativeapi.JNIEnvironment) . |
boolean |
isDestroyed()
Checks if the agent cleanup code had ran.
|
static int |
onLoad(com.oracle.svm.jni.nativeapi.JNIJavaVM vm,
org.graalvm.nativeimage.c.type.CCharPointer options,
org.graalvm.word.PointerBase reserved) |
protected abstract int |
onLoadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM vm,
JvmtiEnv jvmti,
JvmtiEventCallbacks callbacks,
String options)
JVMTI Agent_OnLoad callback.
|
static void |
onThreadEnd(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni,
com.oracle.svm.jni.nativeapi.JNIObjectHandle thread) |
static int |
onUnload(com.oracle.svm.jni.nativeapi.JNIJavaVM vm) |
protected abstract int |
onUnloadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM vm)
JVMTI Agent_OnUnload callback.
|
static void |
onVMDeath(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni) |
protected abstract void |
onVMDeathCallback(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni)
JVMTI VMDeath event callback.
|
static void |
onVMInit(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni,
com.oracle.svm.jni.nativeapi.JNIObjectHandle thread) |
protected abstract void |
onVMInitCallback(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni,
com.oracle.svm.jni.nativeapi.JNIObjectHandle thread)
JVMTI VMInit event callback.
|
static void |
onVMStart(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni) |
protected abstract void |
onVMStartCallback(JvmtiEnv jvmti,
com.oracle.svm.jni.nativeapi.JNIEnvironment jni)
JVMTI VMStart event callback.
|
protected static <T extends JNIHandleSet> |
registerAgent(JvmtiAgentBase<T> agentSingleton)
Registers the agent singleton.
|
static <T extends JNIHandleSet,U extends JvmtiAgentBase<T>> |
singleton() |
protected void |
unload(com.oracle.svm.jni.nativeapi.JNIJavaVM vm)
Releases all global JNI references and resources aquired by the framework.
|
protected abstract JNIHandleSet constructJavaHandles(com.oracle.svm.jni.nativeapi.JNIEnvironment env)
JNIHandleSet
.env
- JNI environment of the thread running the JVMTI callback.JNIHandleSet
subclass.protected abstract int onLoadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks callbacks, String options)
vm
- The JNI Java VM.jvmti
- The JVMTI environment.callbacks
- A structure that allows setting the callbacks for JVMTI events.options
- Command line options passed to the agent.protected abstract int onUnloadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM vm)
vm
- The JNI Java VM.protected abstract void onVMStartCallback(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni)
jvmti
- The JVMTI environment.jni
- The JNI environment of the thread running the JVMTI callback.protected abstract void onVMInitCallback(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni, com.oracle.svm.jni.nativeapi.JNIObjectHandle thread)
jvmti
- The JVMTI environment.jni
- The JNI environment of the thread running the JVMTI callback.thread
- The initial thread.protected abstract void onVMDeathCallback(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni)
jvmti
- The JVMTI environment.jni
- The JNi environment of the thead running the JVMTI callback.protected abstract int getRequiredJvmtiVersion()
public boolean isDestroyed()
public T handles()
JvmtiAgentBase.constructJavaHandles(com.oracle.svm.jni.nativeapi.JNIEnvironment)
. The handles are
guaranteed to be created before JvmtiAgentBase.onLoadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM, com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEnv, com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEventCallbacks, java.lang.String)
is called.JvmtiAgentBase.constructJavaHandles(com.oracle.svm.jni.nativeapi.JNIEnvironment)
.public static <T extends JNIHandleSet,U extends JvmtiAgentBase<T>> U singleton()
protected static <T extends JNIHandleSet> void registerAgent(JvmtiAgentBase<T> agentSingleton)
agentSingleton
- The agent implementation.public static int onLoad(com.oracle.svm.jni.nativeapi.JNIJavaVM vm, org.graalvm.nativeimage.c.type.CCharPointer options, org.graalvm.word.PointerBase reserved)
protected void unload(com.oracle.svm.jni.nativeapi.JNIJavaVM vm)
JvmtiAgentBase.onUnloadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM)
.
During the call to unload some JVMTI event handlers may still be running. As such, it is
necessary to provide proper synchronization that ensures all events finish before this call,
and events that happen after it do not access any JNI handles. To check if this function has
been called, use JvmtiAgentBase.isDestroyed()
.vm
- The JNIJavaVM received from the JvmtiAgentBase.onUnloadCallback(com.oracle.svm.jni.nativeapi.JNIJavaVM)
function.public static int onUnload(com.oracle.svm.jni.nativeapi.JNIJavaVM vm)
public static void onVMStart(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni)
public static void onVMInit(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni, com.oracle.svm.jni.nativeapi.JNIObjectHandle thread)
public static void onVMDeath(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni)
public static void onThreadEnd(JvmtiEnv jvmti, com.oracle.svm.jni.nativeapi.JNIEnvironment jni, com.oracle.svm.jni.nativeapi.JNIObjectHandle thread)