Search in sources :

Example 1 with JValue

use of org.graalvm.jniutils.JNI.JValue in project graal by oracle.

the class JNIUtil method findClass.

/**
 * Finds a class in HotSpot heap using a given {@code ClassLoader}.
 *
 * @param env the {@code JNIEnv}
 * @param binaryName the class binary name
 */
public static JClass findClass(JNIEnv env, JObject classLoader, String binaryName) {
    if (classLoader.isNull()) {
        throw new IllegalArgumentException("ClassLoader must be non null.");
    }
    trace(1, "%s->HS: findClass %s", getFeatureName(), binaryName);
    JMethodID findClassId = findMethod(env, JNIUtil.GetObjectClass(env, classLoader), false, false, METHOD_LOAD_CLASS[0], METHOD_LOAD_CLASS[1]);
    JValue params = StackValue.get(1, JValue.class);
    params.addressOf(0).setJObject(JNIUtil.createHSString(env, binaryName.replace('/', '.')));
    return (JClass) env.getFunctions().getCallObjectMethodA().call(env, classLoader, findClassId, params);
}
Also used : JMethodID(org.graalvm.jniutils.JNI.JMethodID) JValue(org.graalvm.jniutils.JNI.JValue) JClass(org.graalvm.jniutils.JNI.JClass)

Aggregations

JClass (org.graalvm.jniutils.JNI.JClass)1 JMethodID (org.graalvm.jniutils.JNI.JMethodID)1 JValue (org.graalvm.jniutils.JNI.JValue)1