package com.oracle.svm.agent;
import static com.oracle.svm.jni.JNIObjectHandles.nullHandle;
import org.graalvm.word.WordFactory;
import com.oracle.svm.jni.nativeapi.JNIEnvironment;
import com.oracle.svm.jni.nativeapi.JNIFieldId;
import com.oracle.svm.jni.nativeapi.JNIMethodId;
import com.oracle.svm.jni.nativeapi.JNIObjectHandle;
import com.oracle.svm.jvmtiagentbase.JNIHandleSet;
public class NativeImageAgentJNIHandleSet extends JNIHandleSet {
final JNIObjectHandle javaLangClass;
final JNIMethodId javaLangClassForName3;
final JNIMethodId javaUtilEnumerationNextElement;
final JNIMethodId javaLangClassGetDeclaredMethod;
final JNIMethodId javaLangClassGetDeclaredConstructor;
final JNIMethodId javaLangClassGetDeclaredField;
final JNIMethodId javaLangClassGetName;
final JNIMethodId javaLangReflectMemberGetName;
final JNIMethodId javaLangReflectMemberGetDeclaringClass;
final JNIMethodId javaUtilEnumerationHasMoreElements;
final JNIObjectHandle javaLangClassLoader;
final JNIMethodId javaLangObjectGetClass;
private JNIMethodId javaLangInvokeMethodTypeParameterArray = WordFactory.nullPointer();
private JNIMethodId javaUtilResourceBundleGetBundleImplSLCC;
private JNIMethodId javaIoObjectStreamClassComputeDefaultSUID;
private JNIMethodId javaIoObjectStreamClassForClass;
private JNIMethodId javaIoObjectStreamClassGetClassDataLayout0;
private JNIObjectHandle javaIOObjectStreamClassClassDataSlot;
private JNIFieldId javaIOObjectStreamClassClassDataSlotDesc;
private JNIFieldId javaIOObjectStreamClassClassDataSlotHasData;
private boolean queriedJavaUtilResourceBundleGetBundleImplSLCC;
NativeImageAgentJNIHandleSet(JNIEnvironment env) {
super(env);
javaLangClass = newClassGlobalRef(env, "java/lang/Class");
javaLangClassForName3 = getMethodId(env, javaLangClass, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", true);
javaLangClassGetDeclaredMethod = getMethodId(env, javaLangClass, "getDeclaredMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;", false);
javaLangClassGetDeclaredConstructor = getMethodId(env, javaLangClass, "getDeclaredConstructor", "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;", false);
javaLangClassGetDeclaredField = getMethodId(env, javaLangClass, "getDeclaredField", "(Ljava/lang/String;)Ljava/lang/reflect/Field;", false);
javaLangClassGetName = getMethodId(env, javaLangClass, "getName", "()Ljava/lang/String;", false);
JNIObjectHandle javaLangReflectMember = findClass(env, "java/lang/reflect/Member");
javaLangReflectMemberGetName = getMethodId(env, javaLangReflectMember, "getName", "()Ljava/lang/String;", false);
javaLangReflectMemberGetDeclaringClass = getMethodId(env, javaLangReflectMember, "getDeclaringClass", "()Ljava/lang/Class;", false);
JNIObjectHandle javaUtilEnumeration = findClass(env, "java/util/Enumeration");
javaUtilEnumerationHasMoreElements = getMethodId(env, javaUtilEnumeration, "hasMoreElements", "()Z", false);
javaUtilEnumerationNextElement = getMethodId(env, javaUtilEnumeration, "nextElement", "()Ljava/lang/Object;", false);
javaLangClassLoader = newClassGlobalRef(env, "java/lang/ClassLoader");
JNIObjectHandle javaLangObject = findClass(env, "java/lang/Object");
javaLangObjectGetClass = getMethodId(env, javaLangObject, "getClass", "()Ljava/lang/Class;", false);
}
JNIMethodId getJavaLangInvokeMethodTypeParameterArray(JNIEnvironment env) {
if (javaLangInvokeMethodTypeParameterArray.isNull()) {
JNIObjectHandle javaLangInvokeMethodType = newClassGlobalRef(env, "java/lang/invoke/MethodType");
javaLangInvokeMethodTypeParameterArray = getMethodId(env, javaLangInvokeMethodType, "parameterArray", "()[Ljava/lang/Class;", false);
}
return javaLangInvokeMethodTypeParameterArray;
}
JNIMethodId tryGetJavaUtilResourceBundleGetBundleImplSLCC(JNIEnvironment env) {
if (!queriedJavaUtilResourceBundleGetBundleImplSLCC) {
JNIObjectHandle javaUtilResourceBundle = findClass(env, "java/util/ResourceBundle");
javaUtilResourceBundleGetBundleImplSLCC = getMethodIdOptional(env, javaUtilResourceBundle, "getBundleImpl",
"(Ljava/lang/String;Ljava/util/Locale;Ljava/lang/Class;Ljava/util/ResourceBundle$Control;)Ljava/util/ResourceBundle;", true);
queriedJavaUtilResourceBundleGetBundleImplSLCC = true;
}
return javaUtilResourceBundleGetBundleImplSLCC;
}
JNIMethodId getJavaIoObjectStreamClassComputeDefaultSUID(JNIEnvironment env, JNIObjectHandle javaIoObjectStreamClass) {
if (javaIoObjectStreamClassComputeDefaultSUID.equal(nullHandle())) {
javaIoObjectStreamClassComputeDefaultSUID = getMethodId(env, javaIoObjectStreamClass, "computeDefaultSUID", "(Ljava/lang/Class;)J", true);
}
return javaIoObjectStreamClassComputeDefaultSUID;
}
JNIMethodId getJavaIoObjectStreamClassForClass(JNIEnvironment env, JNIObjectHandle javaIoObjectStreamClass) {
if (javaIoObjectStreamClassForClass.equal(nullHandle())) {
javaIoObjectStreamClassForClass = getMethodId(env, javaIoObjectStreamClass, "forClass", "()Ljava/lang/Class;", false);
}
return javaIoObjectStreamClassForClass;
}
JNIMethodId getJavaIoObjectStreamClassGetClassDataLayout0(JNIEnvironment env, JNIObjectHandle javaIoObjectStreamClass) {
if (javaIoObjectStreamClassGetClassDataLayout0.equal(nullHandle())) {
javaIoObjectStreamClassGetClassDataLayout0 = getMethodId(env, javaIoObjectStreamClass, "getClassDataLayout0", "()[Ljava/io/ObjectStreamClass$ClassDataSlot;", false);
}
return javaIoObjectStreamClassGetClassDataLayout0;
}
JNIObjectHandle getJavaIOObjectStreamClassClassDataSlot(JNIEnvironment env) {
if (javaIOObjectStreamClassClassDataSlot.equal(nullHandle())) {
javaIOObjectStreamClassClassDataSlot = newClassGlobalRef(env, "java/io/ObjectStreamClass$ClassDataSlot");
}
return javaIOObjectStreamClassClassDataSlot;
}
JNIFieldId getJavaIOObjectStreamClassClassDataSlotDesc(JNIEnvironment env) {
if (javaIOObjectStreamClassClassDataSlotDesc.equal(nullHandle())) {
javaIOObjectStreamClassClassDataSlotDesc = getFieldId(env, getJavaIOObjectStreamClassClassDataSlot(env), "desc", "Ljava/io/ObjectStreamClass;", false);
}
return javaIOObjectStreamClassClassDataSlotDesc;
}
JNIFieldId getJavaIOObjectStreamClassClassDataSlotHasData(JNIEnvironment env) {
if (javaIOObjectStreamClassClassDataSlotHasData.equal(nullHandle())) {
javaIOObjectStreamClassClassDataSlotHasData = getFieldId(env, getJavaIOObjectStreamClassClassDataSlot(env), "hasData", "Z", false);
}
return javaIOObjectStreamClassClassDataSlotHasData;
}
}