comparison src/share/vm/classfile/verifier.cpp @ 1955:1070423b51f3

6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>' Summary: Update verifier to conform to spec re: reference vs. 'Object' types Reviewed-by: dholmes, coleenp
author kamg
date Wed, 27 Oct 2010 12:53:36 -0400
parents 7f0fdccac34f
children 9752a6549f2e
comparison
equal deleted inserted replaced
1882:ee0d26abaad3 1955:1070423b51f3
245 } 245 }
246 246
247 ClassVerifier::~ClassVerifier() { 247 ClassVerifier::~ClassVerifier() {
248 } 248 }
249 249
250 VerificationType ClassVerifier::object_type() const {
251 return VerificationType::reference_type(vmSymbols::java_lang_Object());
252 }
253
250 void ClassVerifier::verify_class(TRAPS) { 254 void ClassVerifier::verify_class(TRAPS) {
251 if (_verify_verbose) { 255 if (_verify_verbose) {
252 tty->print_cr("Verifying class %s with new format", 256 tty->print_cr("Verifying class %s with new format",
253 _klass->external_name()); 257 _klass->external_name());
254 } 258 }
724 verify_error(bci, bad_type_msg, "dastore"); 728 verify_error(bci, bad_type_msg, "dastore");
725 return; 729 return;
726 } 730 }
727 no_control_flow = false; break; 731 no_control_flow = false; break;
728 case Bytecodes::_aastore : 732 case Bytecodes::_aastore :
729 type = current_frame.pop_stack( 733 type = current_frame.pop_stack(object_type(), CHECK_VERIFY(this));
730 VerificationType::reference_check(), CHECK_VERIFY(this));
731 type2 = current_frame.pop_stack( 734 type2 = current_frame.pop_stack(
732 VerificationType::integer_type(), CHECK_VERIFY(this)); 735 VerificationType::integer_type(), CHECK_VERIFY(this));
733 atype = current_frame.pop_stack( 736 atype = current_frame.pop_stack(
734 VerificationType::reference_check(), CHECK_VERIFY(this)); 737 VerificationType::reference_check(), CHECK_VERIFY(this));
735 // more type-checking is done at runtime 738 // more type-checking is done at runtime
1230 no_control_flow = false; break; 1233 no_control_flow = false; break;
1231 case Bytecodes::_checkcast : 1234 case Bytecodes::_checkcast :
1232 { 1235 {
1233 index = bcs.get_index_u2(); 1236 index = bcs.get_index_u2();
1234 verify_cp_class_type(index, cp, CHECK_VERIFY(this)); 1237 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
1235 current_frame.pop_stack( 1238 current_frame.pop_stack(object_type(), CHECK_VERIFY(this));
1236 VerificationType::reference_check(), CHECK_VERIFY(this));
1237 VerificationType klass_type = cp_index_to_type( 1239 VerificationType klass_type = cp_index_to_type(
1238 index, cp, CHECK_VERIFY(this)); 1240 index, cp, CHECK_VERIFY(this));
1239 current_frame.push_stack(klass_type, CHECK_VERIFY(this)); 1241 current_frame.push_stack(klass_type, CHECK_VERIFY(this));
1240 no_control_flow = false; break; 1242 no_control_flow = false; break;
1241 } 1243 }
1242 case Bytecodes::_instanceof : { 1244 case Bytecodes::_instanceof : {
1243 index = bcs.get_index_u2(); 1245 index = bcs.get_index_u2();
1244 verify_cp_class_type(index, cp, CHECK_VERIFY(this)); 1246 verify_cp_class_type(index, cp, CHECK_VERIFY(this));
1245 current_frame.pop_stack( 1247 current_frame.pop_stack(object_type(), CHECK_VERIFY(this));
1246 VerificationType::reference_check(), CHECK_VERIFY(this));
1247 current_frame.push_stack( 1248 current_frame.push_stack(
1248 VerificationType::integer_type(), CHECK_VERIFY(this)); 1249 VerificationType::integer_type(), CHECK_VERIFY(this));
1249 no_control_flow = false; break; 1250 no_control_flow = false; break;
1250 } 1251 }
1251 case Bytecodes::_monitorenter : 1252 case Bytecodes::_monitorenter :
1608 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); 1609 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w");
1609 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); 1610 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long);
1610 verify_cp_type(index, cp, types, CHECK_VERIFY(this)); 1611 verify_cp_type(index, cp, types, CHECK_VERIFY(this));
1611 } 1612 }
1612 if (tag.is_string() && cp->is_pseudo_string_at(index)) { 1613 if (tag.is_string() && cp->is_pseudo_string_at(index)) {
1613 current_frame->push_stack( 1614 current_frame->push_stack(object_type(), CHECK_VERIFY(this));
1614 VerificationType::reference_type(
1615 vmSymbols::java_lang_Object()), CHECK_VERIFY(this));
1616 } else if (tag.is_string() || tag.is_unresolved_string()) { 1615 } else if (tag.is_string() || tag.is_unresolved_string()) {
1617 current_frame->push_stack( 1616 current_frame->push_stack(
1618 VerificationType::reference_type( 1617 VerificationType::reference_type(
1619 vmSymbols::java_lang_String()), CHECK_VERIFY(this)); 1618 vmSymbols::java_lang_String()), CHECK_VERIFY(this));
1620 } else if (tag.is_klass() || tag.is_unresolved_klass()) { 1619 } else if (tag.is_klass() || tag.is_unresolved_klass()) {