< prev index next >

src/hotspot/share/interpreter/interpreterRuntime.cpp

Print this page
rev 49028 : 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
Reviewed-by: coleenp, dholmes, mdoerr


 469   }
 470 
 471   do {
 472     should_repeat = false;
 473 
 474     // assertions
 475 #ifdef ASSERT
 476     assert(h_exception.not_null(), "NULL exceptions should be handled by athrow");
 477     // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
 478     if (!(h_exception->is_a(SystemDictionary::Throwable_klass()))) {
 479       if (ExitVMOnVerifyError) vm_exit(-1);
 480       ShouldNotReachHere();
 481     }
 482 #endif
 483 
 484     // tracing
 485     if (log_is_enabled(Info, exceptions)) {
 486       ResourceMark rm(thread);
 487       stringStream tempst;
 488       tempst.print("interpreter method <%s>\n"
 489                    " at bci %d for thread " INTPTR_FORMAT,
 490                    h_method->print_value_string(), current_bci, p2i(thread));
 491       Exceptions::log_exception(h_exception, tempst);
 492     }
 493 // Don't go paging in something which won't be used.
 494 //     else if (extable->length() == 0) {
 495 //       // disabled for now - interpreter is not using shortcut yet
 496 //       // (shortcut is not to call runtime if we have no exception handlers)
 497 //       // warning("performance bug: should not call runtime if method has no exception handlers");
 498 //     }
 499     // for AbortVMOnException flag
 500     Exceptions::debug_check_abort(h_exception);
 501 
 502     // exception handler lookup
 503     Klass* klass = h_exception->klass();
 504     handler_bci = Method::fast_exception_handler_bci_for(h_method, klass, current_bci, THREAD);
 505     if (HAS_PENDING_EXCEPTION) {
 506       // We threw an exception while trying to find the exception handler.
 507       // Transfer the new exception to the exception handle which will
 508       // be set into thread local storage, and do another lookup for an
 509       // exception handler for this exception, this time starting at the
 510       // BCI of the exception handler which caused the exception to be


 564   // (this is good for exceptions caught in native methods as well)
 565   if (JvmtiExport::can_post_on_exceptions()) {
 566     JvmtiExport::notice_unwind_due_to_exception(thread, h_method(), handler_pc, h_exception(), (handler_pc != NULL));
 567   }
 568 
 569   thread->set_vm_result(h_exception());
 570   return continuation;
 571 IRT_END
 572 
 573 
 574 IRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* thread))
 575   assert(thread->has_pending_exception(), "must only ne called if there's an exception pending");
 576   // nothing to do - eventually we should remove this code entirely (see comments @ call sites)
 577 IRT_END
 578 
 579 
 580 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread))
 581   THROW(vmSymbols::java_lang_AbstractMethodError());
 582 IRT_END
 583 






















 584 
 585 IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread))
 586   THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
 587 IRT_END
 588 












 589 
 590 //------------------------------------------------------------------------------------------------------------------------
 591 // Fields
 592 //
 593 
 594 void InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode) {
 595   Thread* THREAD = thread;
 596   // resolve field
 597   fieldDescriptor info;
 598   LastFrameAccessor last_frame(thread);
 599   constantPoolHandle pool(thread, last_frame.method()->constants());
 600   methodHandle m(thread, last_frame.method());
 601   bool is_put    = (bytecode == Bytecodes::_putfield  || bytecode == Bytecodes::_nofast_putfield ||
 602                     bytecode == Bytecodes::_putstatic);
 603   bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);
 604 
 605   {
 606     JvmtiHideSingleStepping jhss(thread);
 607     LinkResolver::resolve_field_access(info, pool, last_frame.get_index_u2_cpcache(bytecode),
 608                                        m, bytecode, CHECK);




 469   }
 470 
 471   do {
 472     should_repeat = false;
 473 
 474     // assertions
 475 #ifdef ASSERT
 476     assert(h_exception.not_null(), "NULL exceptions should be handled by athrow");
 477     // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
 478     if (!(h_exception->is_a(SystemDictionary::Throwable_klass()))) {
 479       if (ExitVMOnVerifyError) vm_exit(-1);
 480       ShouldNotReachHere();
 481     }
 482 #endif
 483 
 484     // tracing
 485     if (log_is_enabled(Info, exceptions)) {
 486       ResourceMark rm(thread);
 487       stringStream tempst;
 488       tempst.print("interpreter method <%s>\n"
 489                    " at bci %d for thread " INTPTR_FORMAT " (%s)",
 490                    h_method->print_value_string(), current_bci, p2i(thread), thread->name());
 491       Exceptions::log_exception(h_exception, tempst);
 492     }
 493 // Don't go paging in something which won't be used.
 494 //     else if (extable->length() == 0) {
 495 //       // disabled for now - interpreter is not using shortcut yet
 496 //       // (shortcut is not to call runtime if we have no exception handlers)
 497 //       // warning("performance bug: should not call runtime if method has no exception handlers");
 498 //     }
 499     // for AbortVMOnException flag
 500     Exceptions::debug_check_abort(h_exception);
 501 
 502     // exception handler lookup
 503     Klass* klass = h_exception->klass();
 504     handler_bci = Method::fast_exception_handler_bci_for(h_method, klass, current_bci, THREAD);
 505     if (HAS_PENDING_EXCEPTION) {
 506       // We threw an exception while trying to find the exception handler.
 507       // Transfer the new exception to the exception handle which will
 508       // be set into thread local storage, and do another lookup for an
 509       // exception handler for this exception, this time starting at the
 510       // BCI of the exception handler which caused the exception to be


 564   // (this is good for exceptions caught in native methods as well)
 565   if (JvmtiExport::can_post_on_exceptions()) {
 566     JvmtiExport::notice_unwind_due_to_exception(thread, h_method(), handler_pc, h_exception(), (handler_pc != NULL));
 567   }
 568 
 569   thread->set_vm_result(h_exception());
 570   return continuation;
 571 IRT_END
 572 
 573 
 574 IRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* thread))
 575   assert(thread->has_pending_exception(), "must only ne called if there's an exception pending");
 576   // nothing to do - eventually we should remove this code entirely (see comments @ call sites)
 577 IRT_END
 578 
 579 
 580 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread))
 581   THROW(vmSymbols::java_lang_AbstractMethodError());
 582 IRT_END
 583 
 584 // This method is called from the "abstract_entry" of the interpreter.
 585 // At that point, the arguments have already been removed from the stack
 586 // and therefore we don't have the receiver object at our fingertips. (Though,
 587 // on some platforms the receiver still resides in a register...). Thus,
 588 // we have no choice but print an error message not containing the receiver
 589 // type.
 590 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* thread,
 591                                                                         Method* missingMethod))
 592   ResourceMark rm(thread);
 593   assert(missingMethod != NULL, "sanity");
 594   methodHandle m(thread, missingMethod);
 595   LinkResolver::throw_abstract_method_error(m, THREAD);
 596 IRT_END
 597 
 598 IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* thread,
 599                                                                      Klass* recvKlass,
 600                                                                      Method* missingMethod))
 601   ResourceMark rm(thread);
 602   methodHandle mh = methodHandle(thread, missingMethod);
 603   LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
 604 IRT_END
 605 
 606 
 607 IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread))
 608   THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
 609 IRT_END
 610 
 611 IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* thread,
 612                                                                               Klass* recvKlass,
 613                                                                               Klass* interfaceKlass))
 614   ResourceMark rm(thread);
 615   char buf[1000];
 616   buf[0] = '\0';
 617   jio_snprintf(buf, sizeof(buf),
 618                "Class %s does not implement the requested interface %s",
 619                recvKlass ? recvKlass->external_name() : "NULL",
 620                interfaceKlass ? interfaceKlass->external_name() : "NULL");
 621   THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 622 IRT_END
 623 
 624 //------------------------------------------------------------------------------------------------------------------------
 625 // Fields
 626 //
 627 
 628 void InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode) {
 629   Thread* THREAD = thread;
 630   // resolve field
 631   fieldDescriptor info;
 632   LastFrameAccessor last_frame(thread);
 633   constantPoolHandle pool(thread, last_frame.method()->constants());
 634   methodHandle m(thread, last_frame.method());
 635   bool is_put    = (bytecode == Bytecodes::_putfield  || bytecode == Bytecodes::_nofast_putfield ||
 636                     bytecode == Bytecodes::_putstatic);
 637   bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);
 638 
 639   {
 640     JvmtiHideSingleStepping jhss(thread);
 641     LinkResolver::resolve_field_access(info, pool, last_frame.get_index_u2_cpcache(bytecode),
 642                                        m, bytecode, CHECK);


< prev index next >