--- old/src/share/vm/classfile/verifier.cpp 2017-09-08 02:09:09.929861790 -0400 +++ new/src/share/vm/classfile/verifier.cpp 2017-09-08 02:09:08.053755626 -0400 @@ -2776,10 +2776,6 @@ } } - // need to track if invokespecial is related to a nestmate access - bool nestmate_access = false; - bool nestmates_checked = false; - if (method_name->byte_at(0) == '<') { // Make sure can only be invoked by invokespecial if (opcode != Bytecodes::_invokespecial || @@ -2788,69 +2784,6 @@ "Illegal call to internal method"); return; } - } else if (UseNewCode && opcode == Bytecodes::_invokespecial) { - bool same_or_direct_interface = is_same_or_direct_interface(current_class(), current_type(), ref_class_type); - bool is_super_class = ref_class_type.equals(VerificationType::reference_type(current_class()->super()->name())); - - // We can pass these initial set of verification checks when dealing with nestmates that are - // in the same type hierarchy, only to fail later when we finally apply the 4.9.2 check that - // the objectref on the operand stack is assignable to the current class. So we need to perform - // that check early and if it would fail then do a nestmate check. Then below we skip the - // operand check when we pop the stack. Unfortunately in the failing case we perform the check - // a second time to trigger the failure. This also means that we are forced to do the nestmate - // access check early, instead of using it is a last resort when all other checks have failed. - - // If we don't skip anonymous classes here things break very badly - if (!current_class()->is_anonymous()) { - VerificationType top = current_frame->stack_at(current_frame->stack_size() - nargs - 1); - bool is_assignable = current_type().is_assignable_from(top, this, false, CHECK_VERIFY(this)); - if (!is_assignable) { - nestmate_access = ref_class_type.is_nestmate_of(current_class(), CHECK_VERIFY(this)); - nestmates_checked = true; - } - } - - if (!same_or_direct_interface && !is_super_class) { - 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 || have_imr_indirect) && !nestmates_checked) { - // invokespecial may still be legitimate if current class and reference class - // are nestmates. But in that case we also have to check that the method being - // invoked is defined in the reference class. However that is deferred to runtime - // as we don't have the information available here. - nestmate_access = ref_class_type.is_nestmate_of(current_class(), CHECK_VERIFY(this)); - nestmates_checked = true; - } - - // report any definite verification failures - if (!nestmate_access) { - 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 (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()))) { @@ -2895,13 +2828,9 @@ CHECK_VERIFY(this)); if (was_recursively_verified()) return; } else { // other methods - // Ensures that target class is assignable to current class (4.9.2), - // unless performing a nestmate access + // Ensures that target class is assignable to current class (4.9.2) if (opcode == Bytecodes::_invokespecial) { - if (UseNewCode && nestmate_access) { - VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this)); - } - else if (!current_class()->is_anonymous()) { + if (!current_class()->is_anonymous()) { current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); } else { // anonymous class invokespecial calls: check if the @@ -2912,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; } }