< prev index next >
src/share/vm/interpreter/linkResolver.cpp
Print this page
@@ -233,11 +233,11 @@
#endif
//------------------------------------------------------------------------------------------------------------------------
// Implementation of LinkInfo
-LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS) {
+LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS) {
// resolve klass
_resolved_klass = pool->klass_ref_at(index, CHECK);
// Get name, signature, and static klass
_name = pool->name_ref_at(index);
@@ -313,23 +313,25 @@
//
// According to JVM spec. $5.4.3c & $5.4.3d
// Look up method in klasses, including static methods
// Then look up local default methods
-methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
+Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
bool checkpolymorphism,
- bool in_imethod_resolve, TRAPS) {
+ bool in_imethod_resolve) {
+ NoSafepointVerifier nsv; // Method* returned may not be reclaimed
+
Klass* klass = link_info.resolved_klass();
Symbol* name = link_info.name();
Symbol* signature = link_info.signature();
// Ignore overpasses so statics can be found during resolution
Method* result = klass->uncached_lookup_method(name, signature, Klass::skip_overpass);
if (klass->is_array_klass()) {
// Only consider klass and super klass for arrays
- return methodHandle(THREAD, result);
+ return result;
}
InstanceKlass* ik = InstanceKlass::cast(klass);
// JDK 8, JVMS 5.4.3.4: Interface method resolution should
@@ -361,11 +363,11 @@
if (MethodHandles::is_signature_polymorphic(iid)) {
// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method.
return NULL;
}
}
- return methodHandle(THREAD, result);
+ return result;
}
// returns first instance method
// Looks up method in classes, then looks up local default methods
methodHandle LinkResolver::lookup_instance_method_in_klasses(Klass* klass,
@@ -416,19 +418,17 @@
vtable_index = vt.index_of_miranda(name, signature);
}
return vtable_index;
}
-methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) {
+Method* LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info) {
InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass());
// Specify 'true' in order to skip default methods when searching the
// interfaces. Function lookup_method_in_klasses() already looked for
// the method in the default methods table.
- return methodHandle(THREAD,
- ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(),
- Klass::skip_defaults));
+ return ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), Klass::skip_defaults);
}
methodHandle LinkResolver::lookup_polymorphic_method(
const LinkInfo& link_info,
Handle *appendix_result_or_null,
@@ -713,17 +713,17 @@
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
}
// 3. lookup method in resolved klass and its super klasses
- methodHandle resolved_method = lookup_method_in_klasses(link_info, true, false, CHECK_NULL);
+ methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, true, false));
// 4. lookup method in all the interfaces implemented by the resolved klass
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy
- resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL);
+ resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));
- if (resolved_method.is_null()) {
+ if (resolved_method == NULL) {
// JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc
resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, (Handle*)NULL, THREAD);
if (HAS_PENDING_EXCEPTION) {
nested_exception = Handle(THREAD, PENDING_EXCEPTION);
CLEAR_PENDING_EXCEPTION;
@@ -815,15 +815,15 @@
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
}
// lookup method in this interface or its super, java.lang.Object
// JDK8: also look for static methods
- methodHandle resolved_method = lookup_method_in_klasses(link_info, false, true, CHECK_NULL);
+ methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true));
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) {
// lookup method in all the super-interfaces
- resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL);
+ resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));
}
if (resolved_method.is_null()) {
// no method found
ResourceMark rm(THREAD);
< prev index next >