< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

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


 821         // method stack banging.
 822         assert(thread->deopt_mark() == NULL, "no stack overflow from deopt blob/uncommon trap");
 823         Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, p2i(pc));
 824         return StubRoutines::throw_StackOverflowError_entry();
 825       }
 826 
 827       case IMPLICIT_NULL: {
 828         if (VtableStubs::contains(pc)) {
 829           // We haven't yet entered the callee frame. Fabricate an
 830           // exception and begin dispatching it in the caller. Since
 831           // the caller was at a call site, it's safe to destroy all
 832           // caller-saved registers, as these entry points do.
 833           VtableStub* vt_stub = VtableStubs::stub_containing(pc);
 834 
 835           // If vt_stub is NULL, then return NULL to signal handler to report the SEGV error.
 836           if (vt_stub == NULL) return NULL;
 837 
 838           if (vt_stub->is_abstract_method_error(pc)) {
 839             assert(!vt_stub->is_vtable_stub(), "should never see AbstractMethodErrors from vtable-type VtableStubs");
 840             Events::log_exception(thread, "AbstractMethodError at " INTPTR_FORMAT, p2i(pc));
 841             return StubRoutines::throw_AbstractMethodError_entry();



 842           } else {
 843             Events::log_exception(thread, "NullPointerException at vtable entry " INTPTR_FORMAT, p2i(pc));



 844             return StubRoutines::throw_NullPointerException_at_call_entry();
 845           }
 846         } else {
 847           CodeBlob* cb = CodeCache::find_blob(pc);
 848 
 849           // If code blob is NULL, then return NULL to signal handler to report the SEGV error.
 850           if (cb == NULL) return NULL;
 851 
 852           // Exception happened in CodeCache. Must be either:
 853           // 1. Inline-cache check in C2I handler blob,
 854           // 2. Inline-cache check in nmethod, or
 855           // 3. Implicit null exception in nmethod
 856 
 857           if (!cb->is_compiled()) {
 858             bool is_in_blob = cb->is_adapter_blob() || cb->is_method_handles_adapter_blob();
 859             if (!is_in_blob) {
 860               // Allow normal crash reporting to handle this
 861               return NULL;
 862             }
 863             Events::log_exception(thread, "NullPointerException in code blob at " INTPTR_FORMAT, p2i(pc));


1436     guarantee(callee != NULL && callee->is_method(), "bad handshake");
1437     thread->set_vm_result_2(callee);
1438     thread->set_callee_target(NULL);
1439     return callee->get_c2i_entry();
1440   }
1441 
1442   // Must be compiled to compiled path which is safe to stackwalk
1443   methodHandle callee_method;
1444   JRT_BLOCK
1445     // Force resolving of caller (if we called from compiled frame)
1446     callee_method = SharedRuntime::reresolve_call_site(thread, CHECK_NULL);
1447     thread->set_vm_result_2(callee_method());
1448   JRT_BLOCK_END
1449   // return compiled code entry point after potential safepoints
1450   assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1451   return callee_method->verified_code_entry();
1452 JRT_END
1453 
1454 // Handle abstract method call
1455 JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread* thread))
1456   return StubRoutines::throw_AbstractMethodError_entry();






















1457 JRT_END
1458 
1459 
1460 // resolve a static call and patch code
1461 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread *thread ))
1462   methodHandle callee_method;
1463   JRT_BLOCK
1464     callee_method = SharedRuntime::resolve_helper(thread, false, false, CHECK_NULL);
1465     thread->set_vm_result_2(callee_method());
1466   JRT_BLOCK_END
1467   // return compiled code entry point after potential safepoints
1468   assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1469   return callee_method->verified_code_entry();
1470 JRT_END
1471 
1472 
1473 // resolve virtual call and update inline cache to monomorphic
1474 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread *thread ))
1475   methodHandle callee_method;
1476   JRT_BLOCK




 821         // method stack banging.
 822         assert(thread->deopt_mark() == NULL, "no stack overflow from deopt blob/uncommon trap");
 823         Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, p2i(pc));
 824         return StubRoutines::throw_StackOverflowError_entry();
 825       }
 826 
 827       case IMPLICIT_NULL: {
 828         if (VtableStubs::contains(pc)) {
 829           // We haven't yet entered the callee frame. Fabricate an
 830           // exception and begin dispatching it in the caller. Since
 831           // the caller was at a call site, it's safe to destroy all
 832           // caller-saved registers, as these entry points do.
 833           VtableStub* vt_stub = VtableStubs::stub_containing(pc);
 834 
 835           // If vt_stub is NULL, then return NULL to signal handler to report the SEGV error.
 836           if (vt_stub == NULL) return NULL;
 837 
 838           if (vt_stub->is_abstract_method_error(pc)) {
 839             assert(!vt_stub->is_vtable_stub(), "should never see AbstractMethodErrors from vtable-type VtableStubs");
 840             Events::log_exception(thread, "AbstractMethodError at " INTPTR_FORMAT, p2i(pc));
 841             // Instead of throwing the abstract method error here directly, we re-resolve
 842             // and will throw the AbstractMethodError during resolve. As a result, we'll
 843             // get a more detailed error message.
 844             return SharedRuntime::get_handle_wrong_method_stub();
 845           } else {
 846             Events::log_exception(thread, "NullPointerException at vtable entry " INTPTR_FORMAT, p2i(pc));
 847             // Assert that the signal comes from the expected location in stub code.
 848             assert(vt_stub->is_null_pointer_exception(pc),
 849                    "obtained signal from unexpected location in stub code");
 850             return StubRoutines::throw_NullPointerException_at_call_entry();
 851           }
 852         } else {
 853           CodeBlob* cb = CodeCache::find_blob(pc);
 854 
 855           // If code blob is NULL, then return NULL to signal handler to report the SEGV error.
 856           if (cb == NULL) return NULL;
 857 
 858           // Exception happened in CodeCache. Must be either:
 859           // 1. Inline-cache check in C2I handler blob,
 860           // 2. Inline-cache check in nmethod, or
 861           // 3. Implicit null exception in nmethod
 862 
 863           if (!cb->is_compiled()) {
 864             bool is_in_blob = cb->is_adapter_blob() || cb->is_method_handles_adapter_blob();
 865             if (!is_in_blob) {
 866               // Allow normal crash reporting to handle this
 867               return NULL;
 868             }
 869             Events::log_exception(thread, "NullPointerException in code blob at " INTPTR_FORMAT, p2i(pc));


1442     guarantee(callee != NULL && callee->is_method(), "bad handshake");
1443     thread->set_vm_result_2(callee);
1444     thread->set_callee_target(NULL);
1445     return callee->get_c2i_entry();
1446   }
1447 
1448   // Must be compiled to compiled path which is safe to stackwalk
1449   methodHandle callee_method;
1450   JRT_BLOCK
1451     // Force resolving of caller (if we called from compiled frame)
1452     callee_method = SharedRuntime::reresolve_call_site(thread, CHECK_NULL);
1453     thread->set_vm_result_2(callee_method());
1454   JRT_BLOCK_END
1455   // return compiled code entry point after potential safepoints
1456   assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1457   return callee_method->verified_code_entry();
1458 JRT_END
1459 
1460 // Handle abstract method call
1461 JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread* thread))
1462   // Verbose error message for AbstractMethodError.
1463   // Get the called method from the invoke bytecode.
1464   vframeStream vfst(thread, true);
1465   assert(!vfst.at_end(), "Java frame must exist");
1466   methodHandle caller(vfst.method());
1467   Bytecode_invoke invoke(caller, vfst.bci());
1468   DEBUG_ONLY( invoke.verify(); )
1469 
1470   // Find the compiled caller frame.
1471   RegisterMap reg_map(thread);
1472   frame stubFrame = thread->last_frame();
1473   assert(stubFrame.is_runtime_frame(), "must be");
1474   frame callerFrame = stubFrame.sender(&reg_map);
1475   assert(callerFrame.is_compiled_frame(), "must be");
1476 
1477   // Install exception and return forward entry.
1478   JRT_BLOCK
1479     methodHandle callee = invoke.static_target(thread);
1480     assert(!callee.is_null() && invoke.has_receiver(), "or we should not be here");
1481     oop recv = callerFrame.retrieve_receiver(&reg_map);
1482     LinkResolver::throw_abstract_method_error(callee, recv->klass(), thread);
1483   JRT_BLOCK_END
1484   return StubRoutines::forward_exception_entry();
1485 JRT_END
1486 
1487 
1488 // resolve a static call and patch code
1489 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread *thread ))
1490   methodHandle callee_method;
1491   JRT_BLOCK
1492     callee_method = SharedRuntime::resolve_helper(thread, false, false, CHECK_NULL);
1493     thread->set_vm_result_2(callee_method());
1494   JRT_BLOCK_END
1495   // return compiled code entry point after potential safepoints
1496   assert(callee_method->verified_code_entry() != NULL, " Jump to zero!");
1497   return callee_method->verified_code_entry();
1498 JRT_END
1499 
1500 
1501 // resolve virtual call and update inline cache to monomorphic
1502 JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread *thread ))
1503   methodHandle callee_method;
1504   JRT_BLOCK


< prev index next >