comparison src/share/vm/interpreter/linkResolver.cpp @ 710:e5b0439ef4ae

6655638: dynamic languages need method handles Summary: initial implementation, with known omissions (x86/64, sparc, compiler optim., c-oops, C++ interp.) Reviewed-by: kvn, twisti, never
author jrose
date Wed, 08 Apr 2009 10:56:49 -0700
parents a61af66fc99e
children be93aad57795
comparison
equal deleted inserted replaced
709:1d037ecd7960 710:e5b0439ef4ae
1 /* 1 /*
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
149 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { 149 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
150 instanceKlass *ik = instanceKlass::cast(klass()); 150 instanceKlass *ik = instanceKlass::cast(klass());
151 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature())); 151 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature()));
152 } 152 }
153 153
154 void LinkResolver::lookup_implicit_method(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
155 if (EnableMethodHandles && MethodHandles::enabled() &&
156 name == vmSymbolHandles::invoke_name() && klass() == SystemDictionary::MethodHandle_klass()) {
157 methodOop result_oop = SystemDictionary::find_method_handle_invoke(signature,
158 Handle(),
159 Handle(),
160 CHECK);
161 if (result_oop != NULL) {
162 assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature(), "consistent");
163 result = methodHandle(THREAD, result_oop);
164 }
165 }
166 }
167
154 void LinkResolver::check_method_accessability(KlassHandle ref_klass, 168 void LinkResolver::check_method_accessability(KlassHandle ref_klass,
155 KlassHandle resolved_klass, 169 KlassHandle resolved_klass,
156 KlassHandle sel_klass, 170 KlassHandle sel_klass,
157 methodHandle sel_method, 171 methodHandle sel_method,
158 TRAPS) { 172 TRAPS) {
236 lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK); 250 lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK);
237 251
238 if (resolved_method.is_null()) { // not found in the class hierarchy 252 if (resolved_method.is_null()) { // not found in the class hierarchy
239 // 3. lookup method in all the interfaces implemented by the resolved klass 253 // 3. lookup method in all the interfaces implemented by the resolved klass
240 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); 254 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
255
256 if (resolved_method.is_null()) {
257 // JSR 292: see if this is an implicitly generated method MethodHandle.invoke(*...)
258 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, CHECK);
259 }
241 260
242 if (resolved_method.is_null()) { 261 if (resolved_method.is_null()) {
243 // 4. method lookup failed 262 // 4. method lookup failed
244 ResourceMark rm(THREAD); 263 ResourceMark rm(THREAD);
245 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(), 264 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),