Beispiel #1
0
void JNICALL callbackException(prms_EXCPT)
{
    check_EXCPT;

    if (flag) return;

    jvmtiError result;
    jclass myclass = NULL;
    jfieldID myfield = NULL;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
                "special_method", DEBUG_OUT)) return;

    flag = true;
    util = true;

    if (!is_needed_field_found(jvmti_env, "SetFieldAccessWatch0102.java", "first_field", &myclass, &myfield, DEBUG_OUT))
        return;

    CAPABILITY_TURN_OFF_VOID(can_generate_field_access_events);

    result = jvmti_env->SetFieldAccessWatch(myclass, myfield);
    fprintf(stderr, "\tnative: SetFieldAccessWatch result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    fflush(stderr);

    if (result == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) test = true;
}
Beispiel #2
0
void JNICALL callbackException(prms_EXCPT)
{
    check_EXCPT;

    if (flag) return;

    char* name;
    char* signature;
    char* generic;
    jvmtiError result;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
                "special_method", DEBUG_OUT)) return;

    flag = true;
    util = true;


    CAPABILITY_TURN_OFF_VOID(can_generate_compiled_method_load_events);

    result = jvmti_env->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD);
    fprintf(stderr, "\tnative: GenerateEvents result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    if (result == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) test = true;
}
void JNICALL callbackException(prms_EXCPT)
{
    check_EXCPT;
    if (flag) return;
    char* signature;
    char* generic;
    jboolean obsolete = true;
    jvmtiError result;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
                "special_method", DEBUG_OUT)) return;

    flag = true;
    util = true;

    CAPABILITY_TURN_OFF_VOID(can_redefine_classes);

    result = jvmti_env->IsMethodObsolete(method, &obsolete);
    fprintf(stderr, "\tnative: IsMethodObsolete result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    fflush(stderr);

    if (result == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) test = true;
}
void JNICALL callbackClassLoad(prms_CLS_LD)
{
    check_CLS_LD;

    if (flag) return;
    char* signature;
    char* generic;
    char* filename;
    jvmtiError result;

    result = jvmti_env->GetClassSignature(klass, &signature,&generic);
    if (strcmp(signature, "Lorg/apache/harmony/vts/test/vm/jvmti/GetSourceFileName0102;")) return;
    fprintf(stderr, "\tnative: GetClassSignature result = %d (must be zero) \n", result);
    fprintf(stderr, "\tnative: klass ptr is %p \n", klass);
    fprintf(stderr, "\tnative: signature is %s \n", signature);
    fprintf(stderr, "\tnative: generic is %s \n", generic);
    fflush(stderr);
    if (result != JVMTI_ERROR_NONE) return;

    flag = true;
    util = true;

    CAPABILITY_TURN_OFF_VOID(can_get_source_file_name);

    result = jvmti_env->GetSourceFileName(klass, &filename);
    fprintf(stderr, "\tnative: GetSourceFileName result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    if (result != JVMTI_ERROR_MUST_POSSESS_CAPABILITY) return;
    test = true;
}
void JNICALL callbackException(prms_EXCPT)
{
    check_EXCPT;

    if (flag) return;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
                                      "special_method", DEBUG_OUT)) return;

    flag = true;
    util = true;

    jlocation loc = 14;      /* Value was got as a result of experiment with
                              decoding ta_SetBreakpoint.class by jcf-dump */

    jvmtiError result = jvmti_env->SetBreakpoint(method, loc);
    fprintf(stderr, "\tnative: SetBreakpoint result = %d (must be zero) \n", result);
    fprintf(stderr, "\tnative: methodID is %p \n", method);
    fprintf(stderr, "\tnative: breakpoint location is %lld \n", (long long)loc);

    CAPABILITY_TURN_OFF_VOID(can_generate_breakpoint_events);

    result = jvmti_env->ClearBreakpoint(method, loc);
    fprintf(stderr, "\tnative: ClearBreakpoint result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    if (result != JVMTI_ERROR_MUST_POSSESS_CAPABILITY) return;
    test = true;
}
void JNICALL callbackThreadStart(prms_THRD_START)
{
    check_THRD_START;

    if (flag) return;

    jvmtiPhase phase;
    jvmtiThreadInfo tinfo;
    jvmtiError result;
    jint tcount;
    jthread* threads;
    jthread my_thread = NULL;
    jint state = 0;
    long ethalon = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_INTERRUPTED;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_thread_debug(jvmti_env, thread, SPP_LIVE_ONLY,
                "agent", DEBUG_OUT)) return;

    fprintf(stderr, "\tnative: test started\n");
    flag = true;

    if (!util) return;

    result = jvmti_env->GetAllThreads(&tcount, &threads);
    fprintf(stderr, "\tnative: GetAllThreads result = %d (must be zero) \n", result);
    if (result != JVMTI_ERROR_NONE) return;

    for ( int i = 0; i < tcount; i++ )
    {
        result = jvmti_env->GetThreadInfo(threads[i], &tinfo);
        if (DEBUG_OUT) {
            fprintf(stderr, "\tnative: GetThreadInfo result = %d (must be zero) \n", result);
            fprintf(stderr, "\tnative: current thread name is %s (must be zero) \n", tinfo.name);
        }
        if (result != JVMTI_ERROR_NONE) continue;
        if (strcmp(tinfo.name, "SuperPuperTest")) continue;
        my_thread = threads[i];
        fprintf(stderr, "\tnative: tested thread was found = %p\n", my_thread);
        break;
    }

    if (!my_thread) return;

    CAPABILITY_TURN_OFF_VOID(can_signal_thread);

    result = jvmti_env->StopThread(my_thread, stored_exception);

    fprintf(stderr, "\tnative: StopThread result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);

    if (result == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) test = true;
}
Beispiel #7
0
void JNICALL callbackException(prms_EXCPT)
{
    if (flag) return;

    check_EXCPT;

    jint depth = 0; /* I need current function only */
    jint varnum;
    jint slot = 0;
    jobject value_1 = (jobject)thread;
    jvmtiError result;
    jvmtiLocalVariableEntry* table;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
                "special_method", DEBUG_OUT)) return;

    flag = true;
    util = true;

    result = jvmti_env->GetLocalVariableTable(method, &varnum, &table);
    fprintf(stderr, "\tnative: GetLocalVariableTable result = %d (must be zero) \n", result);
    fprintf(stderr, "\tnative: method ID is %p (must be NON-zero) \n", method);
    fprintf(stderr, "\tnative: variables number is %d (must be 6) \n", varnum);
    fprintf(stderr, "\tnative: table is %p (must be NON-zero)\n", table);
    fflush(stderr);

    if (result != JVMTI_ERROR_NONE) return;

    for (int i = 0; i < varnum; i++)
        if (!strcmp(table[i].name, "_OBJ"))
            slot = table[i].slot;

    CAPABILITY_TURN_OFF_VOID(can_access_local_variables);

    result = jvmti_env->SetLocalObject(NULL, depth, slot, value_1);
    fprintf(stderr, "\tnative: SetLocalObject result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    if (result != JVMTI_ERROR_MUST_POSSESS_CAPABILITY) return;
    test = true;
}
void JNICALL callbackException(prms_EXCPT)
{
    check_EXCPT;
    if (flag) return;
    jvmtiError result;
    jlong nanos = 0;

    /*
     * Function separate all other exceptions in all other method
     */
    if (!check_phase_and_method_debug(jvmti_env, method, SPP_LIVE_ONLY,
                "special_method", DEBUG_OUT)) return;

    flag = true;
    util = true;

    CAPABILITY_TURN_OFF_VOID(can_get_current_thread_cpu_time);

    result = jvmti_env->GetCurrentThreadCpuTime(&nanos);
    fprintf(stderr, "\tnative: GetCurrentThreadCpuTime result = %d (must be JVMTI_ERROR_MUST_POSSESS_CAPABILITY (99)) \n", result);
    if (result == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) test = true;
}