Beispiel #1
0
void jthread_set_tm_data(jobject thread, void *val)
{
    static unsigned offset = (unsigned)-1;

    hythread_suspend_disable();

    ManagedObject *thread_obj = ((ObjectHandle) thread)->object;
    if (offset == -1) {
        Class *clazz = thread_obj->vt()->clss;
        Field *field = class_lookup_field_recursive(clazz, "vm_thread", "J");
        offset = field->get_offset();
    }
    U_8* java_ref = (U_8*)thread_obj;
    *(jlong*)(java_ref + offset) = (jlong) (POINTER_SIZE_INT) val;

    hythread_suspend_enable();
} // jthread_set_tm_data
Beispiel #2
0
void* jthread_get_tm_data(jobject thread)
{
    static int offset = -1;

    hythread_suspend_disable();

    ManagedObject *thread_obj = ((ObjectHandle) thread)->object;
    if (offset == -1) {
        Class *clazz = thread_obj->vt()->clss;
        Field *field = class_lookup_field_recursive(clazz, "vm_thread", "J");
        offset = field->get_offset();
    }
    U_8* java_ref = (U_8*)thread_obj;
    void** val = (void**)(java_ref + offset);

    hythread_suspend_enable();

    return *val;
} // jthread_get_tm_data