1.1 --- a/src/share/vm/opto/runtime.cpp Wed Oct 09 16:32:21 2013 +0200 1.2 +++ b/src/share/vm/opto/runtime.cpp Fri Oct 11 10:14:02 2013 -0700 1.3 @@ -976,30 +976,36 @@ 1.4 address handler_address = NULL; 1.5 1.6 Handle exception(thread, thread->exception_oop()); 1.7 + address pc = thread->exception_pc(); 1.8 + 1.9 + // Clear out the exception oop and pc since looking up an 1.10 + // exception handler can cause class loading, which might throw an 1.11 + // exception and those fields are expected to be clear during 1.12 + // normal bytecode execution. 1.13 + thread->clear_exception_oop_and_pc(); 1.14 1.15 if (TraceExceptions) { 1.16 - trace_exception(exception(), thread->exception_pc(), ""); 1.17 + trace_exception(exception(), pc, ""); 1.18 } 1.19 + 1.20 // for AbortVMOnException flag 1.21 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); 1.22 1.23 - #ifdef ASSERT 1.24 - if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { 1.25 - // should throw an exception here 1.26 - ShouldNotReachHere(); 1.27 - } 1.28 - #endif 1.29 - 1.30 +#ifdef ASSERT 1.31 + if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { 1.32 + // should throw an exception here 1.33 + ShouldNotReachHere(); 1.34 + } 1.35 +#endif 1.36 1.37 // new exception handling: this method is entered only from adapters 1.38 // exceptions from compiled java methods are handled in compiled code 1.39 // using rethrow node 1.40 1.41 - address pc = thread->exception_pc(); 1.42 nm = CodeCache::find_nmethod(pc); 1.43 assert(nm != NULL, "No NMethod found"); 1.44 if (nm->is_native_method()) { 1.45 - fatal("Native mathod should not have path to exception handling"); 1.46 + fatal("Native method should not have path to exception handling"); 1.47 } else { 1.48 // we are switching to old paradigm: search for exception handler in caller_frame 1.49 // instead in exception handler of caller_frame.sender() 1.50 @@ -1346,7 +1352,8 @@ 1.51 tty->print(" in "); 1.52 CodeBlob* blob = CodeCache::find_blob(exception_pc); 1.53 if (blob->is_nmethod()) { 1.54 - ((nmethod*)blob)->method()->print_value(); 1.55 + nmethod* nm = blob->as_nmethod_or_null(); 1.56 + nm->method()->print_value(); 1.57 } else if (blob->is_runtime_stub()) { 1.58 tty->print("<runtime-stub>"); 1.59 } else {