Method* getMethodFromMethodObject(Env* env, Object* methodObject) { if (!java_lang_reflect_Method) { java_lang_reflect_Method = rvmFindClassUsingLoader(env, "java/lang/reflect/Method", NULL); if (!java_lang_reflect_Method) return NULL; } if (!java_lang_reflect_Method_method) { java_lang_reflect_Method_method = rvmGetInstanceField(env, java_lang_reflect_Method, "method", "J"); if (!java_lang_reflect_Method_method) return NULL; } return (Method*) LONG_TO_PTR(rvmGetLongInstanceFieldValue(env, methodObject, java_lang_reflect_Method_method)); }
Field* getFieldFromFieldObject(Env* env, Object* fieldObject) { if (!java_lang_reflect_Field) { java_lang_reflect_Field = rvmFindClassUsingLoader(env, "java/lang/reflect/Field", NULL); if (!java_lang_reflect_Field) return NULL; } if (!java_lang_reflect_Field_field) { java_lang_reflect_Field_field = rvmGetInstanceField(env, java_lang_reflect_Field, "field", "J"); if (!java_lang_reflect_Field_field) return NULL; } return (Field*) LONG_TO_PTR(rvmGetLongInstanceFieldValue(env, fieldObject, java_lang_reflect_Field_field)); }
void rvmThrow(Env* env, Object* e) { // TODO: Check that e != NULL? if (env->throwable) { rvmAbort("rvmThrow() called with env->throwable already set"); } if (IS_TRACE_ENABLED) { jlong stackState = rvmGetLongInstanceFieldValue(env, e, stackStateField); CallStack* callStack = (CallStack*) LONG_TO_PTR(stackState); if (!callStack || callStack->length == 0) { TRACEF("Throwing a %s with empty call stack", e->clazz->name); } else { TRACEF("Throwing a %s. Call stack:", e->clazz->name); Method* m; jint index = 0; while ((m = rvmGetNextCallStackMethod(env, callStack, &index)) != NULL) { TRACEF(" %s.%s%s", m->clazz->name, m->name, m->desc); } } } env->throwable = e; }
static jlong GetLongField(JNIEnv* env, jobject obj, jfieldID fieldID) { return rvmGetLongInstanceFieldValue((Env*) env, (Object*) obj, (InstanceField*) fieldID); }