提交 81010277 编写于 作者: A aeriksso

8072588: JVM crashes in JNI if toString is declared as an interface method

Summary: Check for a valid itable index instead of checking if the holder is an interface
Reviewed-by: dsimms, dholmes
上级 ae466267
...@@ -1325,39 +1325,32 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive ...@@ -1325,39 +1325,32 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive
Method* m = Method::resolve_jmethod_id(method_id); Method* m = Method::resolve_jmethod_id(method_id);
number_of_parameters = m->size_of_parameters(); number_of_parameters = m->size_of_parameters();
Klass* holder = m->method_holder(); Klass* holder = m->method_holder();
if (!(holder)->is_interface()) { if (call_type != JNI_VIRTUAL) {
selected_method = m;
} else if (!m->has_itable_index()) {
// non-interface call -- for that little speed boost, don't handlize // non-interface call -- for that little speed boost, don't handlize
debug_only(No_Safepoint_Verifier nosafepoint;) debug_only(No_Safepoint_Verifier nosafepoint;)
if (call_type == JNI_VIRTUAL) { // jni_GetMethodID makes sure class is linked and initialized
// jni_GetMethodID makes sure class is linked and initialized // so m should have a valid vtable index.
// so m should have a valid vtable index. assert(m->valid_vtable_index(), "no valid vtable index");
assert(!m->has_itable_index(), ""); int vtbl_index = m->vtable_index();
int vtbl_index = m->vtable_index(); if (vtbl_index != Method::nonvirtual_vtable_index) {
if (vtbl_index != Method::nonvirtual_vtable_index) { Klass* k = h_recv->klass();
Klass* k = h_recv->klass(); // k might be an arrayKlassOop but all vtables start at
// k might be an arrayKlassOop but all vtables start at // the same place. The cast is to avoid virtual call and assertion.
// the same place. The cast is to avoid virtual call and assertion. InstanceKlass *ik = (InstanceKlass*)k;
InstanceKlass *ik = (InstanceKlass*)k; selected_method = ik->method_at_vtable(vtbl_index);
selected_method = ik->method_at_vtable(vtbl_index);
} else {
// final method
selected_method = m;
}
} else { } else {
// JNI_NONVIRTUAL call // final method
selected_method = m; selected_method = m;
} }
} else { } else {
// interface call // interface call
KlassHandle h_holder(THREAD, holder); KlassHandle h_holder(THREAD, holder);
if (call_type == JNI_VIRTUAL) { int itbl_index = m->itable_index();
int itbl_index = m->itable_index(); Klass* k = h_recv->klass();
Klass* k = h_recv->klass(); selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK);
selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK);
} else {
selected_method = m;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册