comparison src/share/vm/classfile/verifier.cpp @ 18009:f73af4455d7d

Merge
author asaha
date Thu, 29 May 2014 09:56:06 -0700
parents 364b73402247 78bbf4d43a14
children d6fcbd1e1075 54bc75c144b0
comparison
equal deleted inserted replaced
18008:da65bbf6f89e 18009:f73af4455d7d
362 } 362 }
363 #endif 363 #endif
364 364
365 void ErrorContext::details(outputStream* ss, const Method* method) const { 365 void ErrorContext::details(outputStream* ss, const Method* method) const {
366 if (is_valid()) { 366 if (is_valid()) {
367 ss->print_cr(""); 367 ss->cr();
368 ss->print_cr("Exception Details:"); 368 ss->print_cr("Exception Details:");
369 location_details(ss, method); 369 location_details(ss, method);
370 reason_details(ss); 370 reason_details(ss);
371 frame_details(ss); 371 frame_details(ss);
372 bytecode_details(ss, method); 372 bytecode_details(ss, method);
377 377
378 void ErrorContext::reason_details(outputStream* ss) const { 378 void ErrorContext::reason_details(outputStream* ss) const {
379 streamIndentor si(ss); 379 streamIndentor si(ss);
380 ss->indent().print_cr("Reason:"); 380 ss->indent().print_cr("Reason:");
381 streamIndentor si2(ss); 381 streamIndentor si2(ss);
382 ss->indent().print(""); 382 ss->indent().print("%s", "");
383 switch (_fault) { 383 switch (_fault) {
384 case INVALID_BYTECODE: 384 case INVALID_BYTECODE:
385 ss->print("Error exists in the bytecode"); 385 ss->print("Error exists in the bytecode");
386 break; 386 break;
387 case WRONG_TYPE: 387 case WRONG_TYPE:
430 case UNKNOWN: 430 case UNKNOWN:
431 default: 431 default:
432 ShouldNotReachHere(); 432 ShouldNotReachHere();
433 ss->print_cr("Unknown"); 433 ss->print_cr("Unknown");
434 } 434 }
435 ss->print_cr(""); 435 ss->cr();
436 } 436 }
437 437
438 void ErrorContext::location_details(outputStream* ss, const Method* method) const { 438 void ErrorContext::location_details(outputStream* ss, const Method* method) const {
439 if (_bci != -1 && method != NULL) { 439 if (_bci != -1 && method != NULL) {
440 streamIndentor si(ss); 440 streamIndentor si(ss);
505 streamIndentor si2(ss); 505 streamIndentor si2(ss);
506 int current_offset = -1; 506 int current_offset = -1;
507 for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { 507 for (u2 i = 0; i < sm_table->number_of_entries(); ++i) {
508 ss->indent(); 508 ss->indent();
509 sm_frame->print_on(ss, current_offset); 509 sm_frame->print_on(ss, current_offset);
510 ss->print_cr(""); 510 ss->cr();
511 current_offset += sm_frame->offset_delta(); 511 current_offset += sm_frame->offset_delta();
512 sm_frame = sm_frame->next(); 512 sm_frame = sm_frame->next();
513 } 513 }
514 } 514 }
515 } 515 }
577 _method = m; // initialize _method 577 _method = m; // initialize _method
578 if (VerboseVerification) { 578 if (VerboseVerification) {
579 tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string()); 579 tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string());
580 } 580 }
581 581
582 const char* bad_type_msg = "Bad type on operand stack in %s"; 582 // For clang, the only good constant format string is a literal constant format string.
583 #define bad_type_msg "Bad type on operand stack in %s"
583 584
584 int32_t max_stack = m->verifier_max_stack(); 585 int32_t max_stack = m->verifier_max_stack();
585 int32_t max_locals = m->max_locals(); 586 int32_t max_locals = m->max_locals();
586 constantPoolHandle cp(THREAD, m->constants()); 587 constantPoolHandle cp(THREAD, m->constants());
587 588
1676 verify_error(ErrorContext::bad_code(code_length), 1677 verify_error(ErrorContext::bad_code(code_length),
1677 "Control flow falls through code end"); 1678 "Control flow falls through code end");
1678 return; 1679 return;
1679 } 1680 }
1680 } 1681 }
1682
1683 #undef bad_type_message
1681 1684
1682 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { 1685 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) {
1683 char* code_data = NEW_RESOURCE_ARRAY(char, code_length); 1686 char* code_data = NEW_RESOURCE_ARRAY(char, code_length);
1684 memset(code_data, 0, sizeof(char) * code_length); 1687 memset(code_data, 0, sizeof(char) * code_length);
1685 RawBytecodeStream bcs(m); 1688 RawBytecodeStream bcs(m);
2391 // Get referenced class type 2394 // Get referenced class type
2392 VerificationType ref_class_type; 2395 VerificationType ref_class_type;
2393 if (opcode == Bytecodes::_invokedynamic) { 2396 if (opcode == Bytecodes::_invokedynamic) {
2394 if (!EnableInvokeDynamic || 2397 if (!EnableInvokeDynamic ||
2395 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { 2398 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
2396 class_format_error( 2399 if (!EnableInvokeDynamic) {
2397 (!EnableInvokeDynamic ? 2400 class_format_error("invokedynamic instructions not enabled in this JVM");
2398 "invokedynamic instructions not enabled in this JVM" : 2401 } else {
2399 "invokedynamic instructions not supported by this class file version"), 2402 class_format_error("invokedynamic instructions not supported by this class file version (%d), class %s",
2400 _klass->external_name()); 2403 _klass->major_version(), _klass->external_name());
2404 }
2401 return; 2405 return;
2402 } 2406 }
2403 } else { 2407 } else {
2404 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); 2408 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this));
2405 } 2409 }