--- old/src/share/vm/classfile/verifier.cpp 2017-09-10 22:11:45.841102028 -0400 +++ new/src/share/vm/classfile/verifier.cpp 2017-09-10 22:11:43.972996622 -0400 @@ -2786,38 +2786,35 @@ } } else if (opcode == Bytecodes::_invokespecial && !is_same_or_direct_interface(current_class(), current_type(), ref_class_type) - && !ref_class_type.equals(VerificationType::reference_type( - current_class()->super()->name()))) { - bool subtype = false; - bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; - if (!current_class()->is_anonymous()) { - subtype = ref_class_type.is_assignable_from( - current_type(), this, false, CHECK_VERIFY(this)); - } else { - VerificationType host_klass_type = - VerificationType::reference_type(current_class()->host_klass()->name()); - subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this)); + && !ref_class_type.equals(VerificationType::reference_type(current_class()->super()->name()))) { + bool subtype = false; + bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; + if (!current_class()->is_anonymous()) { + subtype = ref_class_type.is_assignable_from(current_type(), this, false, CHECK_VERIFY(this)); + } else { + VerificationType host_klass_type = + VerificationType::reference_type(current_class()->host_klass()->name()); + subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this)); - // If invokespecial of IMR, need to recheck for same or - // direct interface relative to the host class - have_imr_indirect = (have_imr_indirect && - !is_same_or_direct_interface( - current_class()->host_klass(), - host_klass_type, ref_class_type)); - } - if (!subtype) { - verify_error(ErrorContext::bad_code(bci), - "Bad invokespecial instruction: " - "current class isn't assignable to reference class."); + // If invokespecial of IMR, need to recheck for same or + // direct interface relative to the host class + have_imr_indirect = (have_imr_indirect && + !is_same_or_direct_interface(current_class()->host_klass(), + host_klass_type, ref_class_type)); + } + if (!subtype) { + verify_error(ErrorContext::bad_code(bci), + "Bad invokespecial instruction: " + "current class isn't assignable to reference class."); + return; + } else if (have_imr_indirect) { + verify_error(ErrorContext::bad_code(bci), + "Bad invokespecial instruction: " + "interface method reference is in an indirect superinterface."); return; - } else if (have_imr_indirect) { - verify_error(ErrorContext::bad_code(bci), - "Bad invokespecial instruction: " - "interface method reference is in an indirect superinterface."); - return; - } - + } } + // Match method descriptor with operand stack for (int i = nargs - 1; i >= 0; i--) { // Run backwards current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this)); @@ -2831,7 +2828,7 @@ CHECK_VERIFY(this)); if (was_recursively_verified()) return; } else { // other methods - // Ensures that target class is assignable to method class. + // Ensures that target class is assignable to current class (4.9.2) if (opcode == Bytecodes::_invokespecial) { if (!current_class()->is_anonymous()) { current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); @@ -2844,10 +2841,10 @@ VerificationType::reference_type(current_class()->host_klass()->name()); bool subtype = hosttype.is_assignable_from(top, this, false, CHECK_VERIFY(this)); if (!subtype) { - verify_error( ErrorContext::bad_type(current_frame->offset(), - current_frame->stack_top_ctx(), - TypeOrigin::implicit(top)), - "Bad type on operand stack"); + verify_error(ErrorContext::bad_type(current_frame->offset(), + current_frame->stack_top_ctx(), + TypeOrigin::implicit(top)), + "Bad type on operand stack"); return; } }