use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.
the class JniCallInterceptor method fromReflectedMethod.
@CEntryPoint(name = "FromReflectedMethod")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIMethodId fromReflectedMethod(JNIEnvironment env, JNIObjectHandle method) {
InterceptedState state = initInterceptedState();
JNIObjectHandle callerClass = getCallerClass(state, env);
JNIMethodId result = jniFunctions().getFromReflectedMethod().invoke(env, method);
JNIObjectHandle declaring = nullHandle();
String name = null;
String signature = null;
if (result.isNonNull()) {
declaring = getMethodDeclaringClass(result);
CCharPointerPointer namePtr = StackValue.get(CCharPointerPointer.class);
CCharPointerPointer signaturePtr = StackValue.get(CCharPointerPointer.class);
if (jvmtiFunctions().GetMethodName().invoke(jvmtiEnv(), result, namePtr, signaturePtr, nullPointer()) == JvmtiError.JVMTI_ERROR_NONE) {
name = fromCString(namePtr.read());
signature = fromCString(signaturePtr.read());
jvmtiFunctions().Deallocate().invoke(jvmtiEnv(), namePtr.read());
jvmtiFunctions().Deallocate().invoke(jvmtiEnv(), signaturePtr.read());
}
}
if (shouldTrace()) {
traceCall(env, "FromReflectedMethod", declaring, nullHandle(), callerClass, result.isNonNull(), state, name, signature);
}
return result;
}
use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.
the class JniCallInterceptor method fromReflectedField.
@CEntryPoint(name = "FromReflectedField")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIFieldId fromReflectedField(JNIEnvironment env, JNIObjectHandle field) {
InterceptedState state = initInterceptedState();
JNIObjectHandle callerClass = getCallerClass(state, env);
JNIFieldId result = jniFunctions().getFromReflectedField().invoke(env, field);
JNIObjectHandle declaring = nullHandle();
String name = Tracer.EXPLICIT_NULL;
if (result.isNonNull()) {
declaring = Support.callObjectMethod(env, field, agent.handles().javaLangReflectMemberGetDeclaringClass);
name = getFieldName(declaring, result);
}
if (shouldTrace()) {
traceCall(env, "FromReflectedField", declaring, nullHandle(), callerClass, result.isNonNull(), state, name);
}
return result;
}
use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.
the class JniCallInterceptor method toReflectedField.
@CEntryPoint(name = "ToReflectedField")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIObjectHandle toReflectedField(JNIEnvironment env, JNIObjectHandle clazz, JNIFieldId field, boolean isStatic) {
InterceptedState state = initInterceptedState();
JNIObjectHandle callerClass = getCallerClass(state, env);
JNIObjectHandle declaring = getFieldDeclaringClass(clazz, field);
String name = getFieldName(clazz, field);
JNIObjectHandle result = jniFunctions().getToReflectedField().invoke(env, clazz, field, isStatic);
if (shouldTrace()) {
traceCall(env, "ToReflectedField", clazz, declaring, callerClass, result.notEqual(nullHandle()), state, name);
}
return result;
}
use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.
the class JniCallInterceptor method getMethodID.
@CEntryPoint(name = "GetMethodID")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIMethodId getMethodID(JNIEnvironment env, JNIObjectHandle clazz, CCharPointer name, CCharPointer signature) {
InterceptedState state = initInterceptedState();
JNIObjectHandle callerClass = getCallerClass(state, env);
JNIMethodId result = jniFunctions().getGetMethodID().invoke(env, clazz, name, signature);
if (shouldTrace()) {
traceCall(env, "GetMethodID", clazz, getMethodDeclaringClass(result), callerClass, result.isNonNull(), state, fromCString(name), fromCString(signature));
}
return result;
}
use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.
the class JniCallInterceptor method newObjectArray.
@CEntryPoint(name = "NewObjectArray")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIObjectHandle newObjectArray(JNIEnvironment env, int length, JNIObjectHandle elementClass, JNIObjectHandle initialElement) {
InterceptedState state = initInterceptedState();
JNIObjectHandle callerClass = getCallerClass(state, env);
JNIObjectHandle result = jniFunctions().getNewObjectArray().invoke(env, length, elementClass, initialElement);
JNIObjectHandle resultClass = nullHandle();
if (result.notEqual(nullHandle()) && !testException(env)) {
resultClass = jniFunctions().getGetObjectClass().invoke(env, result);
if (clearException(env)) {
resultClass = nullHandle();
}
}
if (shouldTrace()) {
traceCall(env, "NewObjectArray", resultClass, nullHandle(), callerClass, result.notEqual(nullHandle()), state);
}
return result;
}
Aggregations