comparison src/share/vm/classfile/verifier.cpp @ 20527:8cb56c8cb30d

Merge
author jiangli
date Mon, 15 Sep 2014 16:39:00 -0400
parents 92baebeb744b 077483254bf6
children c2844108a708
comparison
equal deleted inserted replaced
20411:fe1f65b0a2d8 20527:8cb56c8cb30d
1732 VerificationType catch_type = cp_index_to_type( 1732 VerificationType catch_type = cp_index_to_type(
1733 catch_type_index, cp, CHECK_VERIFY(this)); 1733 catch_type_index, cp, CHECK_VERIFY(this));
1734 VerificationType throwable = 1734 VerificationType throwable =
1735 VerificationType::reference_type(vmSymbols::java_lang_Throwable()); 1735 VerificationType::reference_type(vmSymbols::java_lang_Throwable());
1736 bool is_subclass = throwable.is_assignable_from( 1736 bool is_subclass = throwable.is_assignable_from(
1737 catch_type, this, CHECK_VERIFY(this)); 1737 catch_type, this, false, CHECK_VERIFY(this));
1738 if (!is_subclass) { 1738 if (!is_subclass) {
1739 // 4286534: should throw VerifyError according to recent spec change 1739 // 4286534: should throw VerifyError according to recent spec change
1740 verify_error(ErrorContext::bad_type(handler_pc, 1740 verify_error(ErrorContext::bad_type(handler_pc,
1741 TypeOrigin::cp(catch_type_index, catch_type), 1741 TypeOrigin::cp(catch_type_index, catch_type),
1742 TypeOrigin::implicit(throwable)), 1742 TypeOrigin::implicit(throwable)),
2187 target_class_type.equals(current_type()) && 2187 target_class_type.equals(current_type()) &&
2188 _klass->find_local_field(field_name, field_sig, &fd)) { 2188 _klass->find_local_field(field_name, field_sig, &fd)) {
2189 stack_object_type = current_type(); 2189 stack_object_type = current_type();
2190 } 2190 }
2191 is_assignable = target_class_type.is_assignable_from( 2191 is_assignable = target_class_type.is_assignable_from(
2192 stack_object_type, this, CHECK_VERIFY(this)); 2192 stack_object_type, this, false, CHECK_VERIFY(this));
2193 if (!is_assignable) { 2193 if (!is_assignable) {
2194 verify_error(ErrorContext::bad_type(bci, 2194 verify_error(ErrorContext::bad_type(bci,
2195 current_frame->stack_top_ctx(), 2195 current_frame->stack_top_ctx(),
2196 TypeOrigin::cp(index, target_class_type)), 2196 TypeOrigin::cp(index, target_class_type)),
2197 "Bad type on operand stack in putfield"); 2197 "Bad type on operand stack in putfield");
2214 if (is_protected_access(current_class(), ref_class_oop, field_name, 2214 if (is_protected_access(current_class(), ref_class_oop, field_name,
2215 field_sig, false)) { 2215 field_sig, false)) {
2216 // It's protected access, check if stack object is assignable to 2216 // It's protected access, check if stack object is assignable to
2217 // current class. 2217 // current class.
2218 is_assignable = current_type().is_assignable_from( 2218 is_assignable = current_type().is_assignable_from(
2219 stack_object_type, this, CHECK_VERIFY(this)); 2219 stack_object_type, this, true, CHECK_VERIFY(this));
2220 if (!is_assignable) { 2220 if (!is_assignable) {
2221 verify_error(ErrorContext::bad_type(bci, 2221 verify_error(ErrorContext::bad_type(bci,
2222 current_frame->stack_top_ctx(), 2222 current_frame->stack_top_ctx(),
2223 TypeOrigin::implicit(current_type())), 2223 TypeOrigin::implicit(current_type())),
2224 "Bad access to protected data in getfield"); 2224 "Bad access to protected data in getfield");
2487 // Do nothing if method is not found. Let resolution detect the error. 2487 // Do nothing if method is not found. Let resolution detect the error.
2488 if (m != NULL) { 2488 if (m != NULL) {
2489 instanceKlassHandle mh(THREAD, m->method_holder()); 2489 instanceKlassHandle mh(THREAD, m->method_holder());
2490 if (m->is_protected() && !mh->is_same_class_package(_klass())) { 2490 if (m->is_protected() && !mh->is_same_class_package(_klass())) {
2491 bool assignable = current_type().is_assignable_from( 2491 bool assignable = current_type().is_assignable_from(
2492 objectref_type, this, CHECK_VERIFY(this)); 2492 objectref_type, this, true, CHECK_VERIFY(this));
2493 if (!assignable) { 2493 if (!assignable) {
2494 verify_error(ErrorContext::bad_type(bci, 2494 verify_error(ErrorContext::bad_type(bci,
2495 TypeOrigin::cp(new_class_index, objectref_type), 2495 TypeOrigin::cp(new_class_index, objectref_type),
2496 TypeOrigin::implicit(current_type())), 2496 TypeOrigin::implicit(current_type())),
2497 "Bad access to protected <init> method"); 2497 "Bad access to protected <init> method");
2662 current_class()->super()->name()))) { 2662 current_class()->super()->name()))) {
2663 bool subtype = false; 2663 bool subtype = false;
2664 bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; 2664 bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref;
2665 if (!current_class()->is_anonymous()) { 2665 if (!current_class()->is_anonymous()) {
2666 subtype = ref_class_type.is_assignable_from( 2666 subtype = ref_class_type.is_assignable_from(
2667 current_type(), this, CHECK_VERIFY(this)); 2667 current_type(), this, false, CHECK_VERIFY(this));
2668 } else { 2668 } else {
2669 VerificationType host_klass_type = 2669 VerificationType host_klass_type =
2670 VerificationType::reference_type(current_class()->host_klass()->name()); 2670 VerificationType::reference_type(current_class()->host_klass()->name());
2671 subtype = ref_class_type.is_assignable_from(host_klass_type, this, CHECK_VERIFY(this)); 2671 subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this));
2672 2672
2673 // If invokespecial of IMR, need to recheck for same or 2673 // If invokespecial of IMR, need to recheck for same or
2674 // direct interface relative to the host class 2674 // direct interface relative to the host class
2675 have_imr_indirect = (have_imr_indirect && 2675 have_imr_indirect = (have_imr_indirect &&
2676 !is_same_or_direct_interface( 2676 !is_same_or_direct_interface(
2710 // objectref is a subtype of the host_klass of the current class 2710 // objectref is a subtype of the host_klass of the current class
2711 // to allow an anonymous class to reference methods in the host_klass 2711 // to allow an anonymous class to reference methods in the host_klass
2712 VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this)); 2712 VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this));
2713 VerificationType hosttype = 2713 VerificationType hosttype =
2714 VerificationType::reference_type(current_class()->host_klass()->name()); 2714 VerificationType::reference_type(current_class()->host_klass()->name());
2715 bool subtype = hosttype.is_assignable_from(top, this, CHECK_VERIFY(this)); 2715 bool subtype = hosttype.is_assignable_from(top, this, false, CHECK_VERIFY(this));
2716 if (!subtype) { 2716 if (!subtype) {
2717 verify_error( ErrorContext::bad_type(current_frame->offset(), 2717 verify_error( ErrorContext::bad_type(current_frame->offset(),
2718 current_frame->stack_top_ctx(), 2718 current_frame->stack_top_ctx(),
2719 TypeOrigin::implicit(top)), 2719 TypeOrigin::implicit(top)),
2720 "Bad type on operand stack"); 2720 "Bad type on operand stack");
2735 if (is_protected_access( 2735 if (is_protected_access(
2736 _klass, ref_class, method_name, method_sig, true)) { 2736 _klass, ref_class, method_name, method_sig, true)) {
2737 // It's protected access, check if stack object is 2737 // It's protected access, check if stack object is
2738 // assignable to current class. 2738 // assignable to current class.
2739 bool is_assignable = current_type().is_assignable_from( 2739 bool is_assignable = current_type().is_assignable_from(
2740 stack_object_type, this, CHECK_VERIFY(this)); 2740 stack_object_type, this, true, CHECK_VERIFY(this));
2741 if (!is_assignable) { 2741 if (!is_assignable) {
2742 if (ref_class_type.name() == vmSymbols::java_lang_Object() 2742 if (ref_class_type.name() == vmSymbols::java_lang_Object()
2743 && stack_object_type.is_array() 2743 && stack_object_type.is_array()
2744 && method_name == vmSymbols::clone_name()) { 2744 && method_name == vmSymbols::clone_name()) {
2745 // Special case: arrays pretend to implement public Object 2745 // Special case: arrays pretend to implement public Object
2918 verify_error(ErrorContext::bad_type(bci, 2918 verify_error(ErrorContext::bad_type(bci,
2919 current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), 2919 current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)),
2920 "Method expects a return value"); 2920 "Method expects a return value");
2921 return; 2921 return;
2922 } 2922 }
2923 bool match = return_type.is_assignable_from(type, this, CHECK_VERIFY(this)); 2923 bool match = return_type.is_assignable_from(type, this, false, CHECK_VERIFY(this));
2924 if (!match) { 2924 if (!match) {
2925 verify_error(ErrorContext::bad_type(bci, 2925 verify_error(ErrorContext::bad_type(bci,
2926 current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), 2926 current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)),
2927 "Bad return type"); 2927 "Bad return type");
2928 return; 2928 return;