diff --git a/src/share/vm/oops/klassVtable.cpp b/src/share/vm/oops/klassVtable.cpp index b3f477cd07cf91d12a850b3b72daf47ffba7eac9..d3d9d26b250388d6a3236d7ce5c26652bc1a2c75 100644 --- a/src/share/vm/oops/klassVtable.cpp +++ b/src/share/vm/oops/klassVtable.cpp @@ -1154,7 +1154,7 @@ inline bool interface_method_needs_itable_index(Method* m) { int klassItable::assign_itable_indices_for_interface(Klass* klass) { // an interface does not have an itable, but its methods need to be numbered - if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count, + if (TraceItables) tty->print_cr("%3d: Initializing itable indices for interface %s", ++initialize_count, klass->name()->as_C_string()); Array* methods = InstanceKlass::cast(klass)->methods(); int nof_methods = methods->length(); @@ -1168,7 +1168,7 @@ int klassItable::assign_itable_indices_for_interface(Klass* klass) { ResourceMark rm; const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : ""; if (m->has_vtable_index()) { - tty->print("itable index %d for method: %s, flags: ", m->vtable_index(), sig); + tty->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig); } else { tty->print("itable index %d for method: %s, flags: ", ime_num, sig); } @@ -1204,22 +1204,25 @@ int klassItable::method_count_for_interface(Klass* interf) { assert(interf->is_interface(), "must be"); Array* methods = InstanceKlass::cast(interf)->methods(); int nof_methods = methods->length(); + int length = 0; while (nof_methods > 0) { Method* m = methods->at(nof_methods-1); if (m->has_itable_index()) { - int length = m->itable_index() + 1; -#ifdef ASSERT - while (nof_methods = 0) { - m = methods->at(--nof_methods); - assert(!m->has_itable_index() || m->itable_index() < length, ""); - } -#endif //ASSERT - return length; // return the rightmost itable index, plus one + length = m->itable_index() + 1; + break; } nof_methods -= 1; } - // no methods have itable indices - return 0; +#ifdef ASSERT + int nof_methods_copy = nof_methods; + while (nof_methods_copy > 0) { + Method* mm = methods->at(--nof_methods_copy); + assert(!mm->has_itable_index() || mm->itable_index() < length, ""); + } +#endif //ASSERT + // return the rightmost itable index, plus one; or 0 if no methods have + // itable indices + return length; } diff --git a/src/share/vm/prims/methodHandles.cpp b/src/share/vm/prims/methodHandles.cpp index 8645340d7366dc3e3902926a1016107655c14f7a..9e19dbbe3daf1cc40d5bc433a54c3004207fdcf8 100644 --- a/src/share/vm/prims/methodHandles.cpp +++ b/src/share/vm/prims/methodHandles.cpp @@ -176,7 +176,9 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target) { oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, bool intern) { assert(info.resolved_appendix().is_null(), "only normal methods here"); methodHandle m = info.resolved_method(); + assert(m.not_null(), "null method handle"); KlassHandle m_klass = m->method_holder(); + assert(m.not_null(), "null holder for method handle"); int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); int vmindex = Method::invalid_vtable_index;