--- old/src/share/vm/oops/method.cpp 2017-06-01 17:27:42.844206502 +0200 +++ new/src/share/vm/oops/method.cpp 2017-06-01 17:27:42.762206609 +0200 @@ -46,6 +46,7 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" +#include "oops/valueKlass.hpp" #include "prims/jvmtiExport.hpp" #include "prims/methodHandles.hpp" #include "prims/nativeLookup.hpp" @@ -467,6 +468,27 @@ return rtf.type(); } +#ifdef ASSERT +// ValueKlass the method is declared to return. This must not +// safepoint as it is called with references live on the stack at +// locations the GC is unaware of. +ValueKlass* Method::returned_value_type(Thread* thread) const { + assert(is_returning_vt(), "method return type should be value type"); + SignatureStream ss(signature()); + while (!ss.at_return_type()) { + ss.next(); + } + Handle class_loader(thread, method_holder()->class_loader()); + Handle protection_domain(thread, method_holder()->protection_domain()); + Klass* k = NULL; + { + NoSafepointVerifier nsv; + k = ss.as_klass(class_loader, protection_domain, SignatureStream::ReturnNull, thread); + } + assert(k != NULL && !thread->has_pending_exception(), "can't resolve klass"); + return ValueKlass::cast(k); +} +#endif bool Method::is_empty_method() const { return code_size() == 1