Beispiel #1
0
/*
 * Get Method Declaring Class
 *
 * For the method indicated by method, return the class that
 * defined it via declaring_class_ptr.
 *
 * REQUIRED Functionality.
 */
jvmtiError JNICALL
jvmtiGetMethodDeclaringClass(jvmtiEnv* env,
                             jmethodID method,
                             jclass* declaring_class_ptr)
{
    TRACE("GetMethodDeclaringClass called for " << method);
    SuspendEnabledChecker sec;
    /*
     * Check given env & current phase.
     */
    jvmtiPhase phases[] = {JVMTI_PHASE_START, JVMTI_PHASE_LIVE};

    CHECK_EVERYTHING();

    if( !method ) return JVMTI_ERROR_INVALID_FIELDID;
    if( !declaring_class_ptr ) return JVMTI_ERROR_NULL_POINTER;

    Method* mtd = (Method*)method;
    Class* cls = mtd->get_class();

    ObjectHandle hclss = struct_Class_to_java_lang_Class_Handle(cls);
    ObjectHandle newH = NewLocalRef(p_TLS_vmthread->jni_env, hclss);

    *declaring_class_ptr = (jclass)newH;

    return JVMTI_ERROR_NONE;
}
static jobject ToLocalRef(JNIEnv* env, jobject globalRef)
{
    jobject localRef = NewLocalRef(env, globalRef);
    env->DeleteGlobalRef(globalRef);
    return localRef;
}