1 /* 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "classfile/defaultMethods.hpp" 27 #include "classfile/symbolTable.hpp" 28 #include "classfile/systemDictionary.hpp" 29 #include "classfile/vmSymbols.hpp" 30 #include "compiler/compileBroker.hpp" 31 #include "gc/shared/collectedHeap.inline.hpp" 32 #include "interpreter/bytecode.hpp" 33 #include "interpreter/interpreterRuntime.hpp" 34 #include "interpreter/linkResolver.hpp" 35 #include "logging/log.hpp" 36 #include "memory/resourceArea.hpp" 37 #include "memory/universe.inline.hpp" 38 #include "oops/instanceKlass.hpp" 39 #include "oops/method.hpp" 40 #include "oops/objArrayOop.hpp" 41 #include "oops/oop.inline.hpp" 42 #include "prims/methodHandles.hpp" 43 #include "prims/nativeLookup.hpp" 44 #include "runtime/compilationPolicy.hpp" 45 #include "runtime/fieldDescriptor.hpp" 46 #include "runtime/frame.inline.hpp" 47 #include "runtime/handles.inline.hpp" 48 #include "runtime/reflection.hpp" 49 #include "runtime/signature.hpp" 50 #include "runtime/thread.inline.hpp" 51 #include "runtime/vmThread.hpp" 52 53 54 //------------------------------------------------------------------------------------------------------------------------ 55 // Implementation of CallInfo 56 57 58 void CallInfo::set_static(KlassHandle resolved_klass, const methodHandle& resolved_method, TRAPS) { 59 int vtable_index = Method::nonvirtual_vtable_index; 60 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); 61 } 62 63 64 void CallInfo::set_interface(KlassHandle resolved_klass, 65 KlassHandle selected_klass, 66 const methodHandle& resolved_method, 67 const methodHandle& selected_method, 68 int itable_index, TRAPS) { 69 // This is only called for interface methods. If the resolved_method 70 // comes from java/lang/Object, it can be the subject of a virtual call, so 71 // we should pick the vtable index from the resolved method. 72 // In that case, the caller must call set_virtual instead of set_interface. 73 assert(resolved_method->method_holder()->is_interface(), ""); 74 assert(itable_index == resolved_method()->itable_index(), ""); 75 set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); 76 } 77 78 void CallInfo::set_virtual(KlassHandle resolved_klass, 79 KlassHandle selected_klass, 80 const methodHandle& resolved_method, 81 const methodHandle& selected_method, 82 int vtable_index, TRAPS) { 83 assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); 84 assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), ""); 85 CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call); 86 set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); 87 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); 88 } 89 90 void CallInfo::set_handle(const methodHandle& resolved_method, 91 Handle resolved_appendix, 92 Handle resolved_method_type, TRAPS) { 93 set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); 94 } 95 96 void CallInfo::set_handle(KlassHandle resolved_klass, 97 const methodHandle& resolved_method, 98 Handle resolved_appendix, 99 Handle resolved_method_type, TRAPS) { 100 if (resolved_method.is_null()) { 101 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); 102 } 103 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || 104 resolved_method->is_compiled_lambda_form(), 105 "linkMethod must return one of these"); 106 int vtable_index = Method::nonvirtual_vtable_index; 107 assert(!resolved_method->has_vtable_index(), ""); 108 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); 109 _resolved_appendix = resolved_appendix; 110 _resolved_method_type = resolved_method_type; 111 } 112 113 void CallInfo::set_common(KlassHandle resolved_klass, 114 KlassHandle selected_klass, 115 const methodHandle& resolved_method, 116 const methodHandle& selected_method, 117 CallKind kind, 118 int index, 119 TRAPS) { 120 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); 121 _resolved_klass = resolved_klass; 122 _selected_klass = selected_klass; 123 _resolved_method = resolved_method; 124 _selected_method = selected_method; 125 _call_kind = kind; 126 _call_index = index; 127 _resolved_appendix = Handle(); 128 DEBUG_ONLY(verify()); // verify before making side effects 129 130 CompilationPolicy::compile_if_required(selected_method, THREAD); 131 } 132 133 // utility query for unreflecting a method 134 CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) { 135 Klass* resolved_method_holder = resolved_method->method_holder(); 136 if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st 137 resolved_klass = resolved_method_holder; 138 } 139 _resolved_klass = resolved_klass; 140 _selected_klass = resolved_klass; 141 _resolved_method = resolved_method; 142 _selected_method = resolved_method; 143 // classify: 144 CallKind kind = CallInfo::unknown_kind; 145 int index = resolved_method->vtable_index(); 146 if (resolved_method->can_be_statically_bound()) { 147 kind = CallInfo::direct_call; 148 } else if (!resolved_method_holder->is_interface()) { 149 // Could be an Object method inherited into an interface, but still a vtable call. 150 kind = CallInfo::vtable_call; 151 } else if (!resolved_klass->is_interface()) { 152 // A default or miranda method. Compute the vtable index. 153 ResourceMark rm; 154 klassVtable* vt = resolved_klass->vtable(); 155 index = LinkResolver::vtable_index_of_interface_method(resolved_klass, 156 resolved_method); 157 assert(index >= 0 , "we should have valid vtable index at this point"); 158 159 kind = CallInfo::vtable_call; 160 } else if (resolved_method->has_vtable_index()) { 161 // Can occur if an interface redeclares a method of Object. 162 163 #ifdef ASSERT 164 // Ensure that this is really the case. 165 KlassHandle object_klass = SystemDictionary::Object_klass(); 166 Method * object_resolved_method = object_klass()->vtable()->method_at(index); 167 assert(object_resolved_method->name() == resolved_method->name(), 168 "Object and interface method names should match at vtable index %d, %s != %s", 169 index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()); 170 assert(object_resolved_method->signature() == resolved_method->signature(), 171 "Object and interface method signatures should match at vtable index %d, %s != %s", 172 index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string()); 173 #endif // ASSERT 174 175 kind = CallInfo::vtable_call; 176 } else { 177 // A regular interface call. 178 kind = CallInfo::itable_call; 179 index = resolved_method->itable_index(); 180 } 181 assert(index == Method::nonvirtual_vtable_index || index >= 0, "bad index %d", index); 182 _call_kind = kind; 183 _call_index = index; 184 _resolved_appendix = Handle(); 185 DEBUG_ONLY(verify()); 186 } 187 188 #ifdef ASSERT 189 void CallInfo::verify() { 190 switch (call_kind()) { // the meaning and allowed value of index depends on kind 191 case CallInfo::direct_call: 192 if (_call_index == Method::nonvirtual_vtable_index) break; 193 // else fall through to check vtable index: 194 case CallInfo::vtable_call: 195 assert(resolved_klass()->verify_vtable_index(_call_index), ""); 196 break; 197 case CallInfo::itable_call: 198 assert(resolved_method()->method_holder()->verify_itable_index(_call_index), ""); 199 break; 200 case CallInfo::unknown_kind: 201 assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set"); 202 break; 203 default: 204 fatal("Unexpected call kind %d", call_kind()); 205 } 206 } 207 #endif //ASSERT 208 209 #ifndef PRODUCT 210 void CallInfo::print() { 211 ResourceMark rm; 212 const char* kindstr = "unknown"; 213 switch (_call_kind) { 214 case direct_call: kindstr = "direct"; break; 215 case vtable_call: kindstr = "vtable"; break; 216 case itable_call: kindstr = "itable"; break; 217 } 218 tty->print_cr("Call %s@%d %s", kindstr, _call_index, 219 _resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string()); 220 } 221 #endif 222 223 //------------------------------------------------------------------------------------------------------------------------ 224 // Implementation of LinkInfo 225 226 LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS) { 227 // resolve klass 228 Klass* result = pool->klass_ref_at(index, CHECK); 229 _resolved_klass = KlassHandle(THREAD, result); 230 231 // Get name, signature, and static klass 232 _name = pool->name_ref_at(index); 233 _signature = pool->signature_ref_at(index); 234 _current_klass = KlassHandle(THREAD, pool->pool_holder()); 235 _current_method = current_method; 236 237 // Coming from the constant pool always checks access 238 _check_access = true; 239 } 240 241 char* LinkInfo::method_string() const { 242 return Method::name_and_sig_as_C_string(_resolved_klass(), _name, _signature); 243 } 244 245 #ifndef PRODUCT 246 void LinkInfo::print() { 247 ResourceMark rm; 248 tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s", 249 _resolved_klass->name()->as_C_string(), 250 _name->as_C_string(), 251 _signature->as_C_string(), 252 _current_klass.is_null() ? "(none)" : _current_klass->name()->as_C_string(), 253 _check_access ? "true" : "false"); 254 } 255 #endif // PRODUCT 256 //------------------------------------------------------------------------------------------------------------------------ 257 // Klass resolution 258 259 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) { 260 Reflection::VerifyClassAccessResults vca_result = 261 Reflection::verify_class_access(ref_klass(), sel_klass(), true); 262 if (vca_result != Reflection::ACCESS_OK) { 263 ResourceMark rm(THREAD); 264 char* msg = Reflection::verify_class_access_msg(ref_klass(), sel_klass(), vca_result); 265 if (msg == NULL) { 266 Exceptions::fthrow( 267 THREAD_AND_LOCATION, 268 vmSymbols::java_lang_IllegalAccessError(), 269 "failed to access class %s from class %s", 270 sel_klass->external_name(), 271 ref_klass->external_name()); 272 } else { 273 // Use module specific message returned by verify_class_access_msg(). 274 Exceptions::fthrow( 275 THREAD_AND_LOCATION, 276 vmSymbols::java_lang_IllegalAccessError(), 277 "%s", msg); 278 } 279 } 280 } 281 282 //------------------------------------------------------------------------------------------------------------------------ 283 // Method resolution 284 // 285 // According to JVM spec. $5.4.3c & $5.4.3d 286 287 // Look up method in klasses, including static methods 288 // Then look up local default methods 289 methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, 290 bool checkpolymorphism, 291 bool in_imethod_resolve, TRAPS) { 292 KlassHandle klass = link_info.resolved_klass(); 293 Symbol* name = link_info.name(); 294 Symbol* signature = link_info.signature(); 295 296 // Ignore overpasses so statics can be found during resolution 297 Method* result = klass->uncached_lookup_method(name, signature, Klass::skip_overpass); 298 299 if (klass->is_array_klass()) { 300 // Only consider klass and super klass for arrays 301 return methodHandle(THREAD, result); 302 } 303 304 InstanceKlass* ik = InstanceKlass::cast(klass()); 305 306 // JDK 8, JVMS 5.4.3.4: Interface method resolution should 307 // ignore static and non-public methods of java.lang.Object, 308 // like clone, finalize, registerNatives. 309 if (in_imethod_resolve && 310 result != NULL && 311 ik->is_interface() && 312 (result->is_static() || !result->is_public()) && 313 result->method_holder() == SystemDictionary::Object_klass()) { 314 result = NULL; 315 } 316 317 // Before considering default methods, check for an overpass in the 318 // current class if a method has not been found. 319 if (result == NULL) { 320 result = ik->find_method(name, signature); 321 } 322 323 if (result == NULL) { 324 Array<Method*>* default_methods = ik->default_methods(); 325 if (default_methods != NULL) { 326 result = InstanceKlass::find_method(default_methods, name, signature); 327 } 328 } 329 330 if (checkpolymorphism && result != NULL) { 331 vmIntrinsics::ID iid = result->intrinsic_id(); 332 if (MethodHandles::is_signature_polymorphic(iid)) { 333 // Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. 334 return NULL; 335 } 336 } 337 return methodHandle(THREAD, result); 338 } 339 340 // returns first instance method 341 // Looks up method in classes, then looks up local default methods 342 methodHandle LinkResolver::lookup_instance_method_in_klasses(KlassHandle klass, 343 Symbol* name, 344 Symbol* signature, TRAPS) { 345 Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass); 346 347 while (result != NULL && result->is_static() && result->method_holder()->super() != NULL) { 348 Klass* super_klass = result->method_holder()->super(); 349 result = super_klass->uncached_lookup_method(name, signature, Klass::find_overpass); 350 } 351 352 if (klass->is_array_klass()) { 353 // Only consider klass and super klass for arrays 354 return methodHandle(THREAD, result); 355 } 356 357 if (result == NULL) { 358 Array<Method*>* default_methods = InstanceKlass::cast(klass())->default_methods(); 359 if (default_methods != NULL) { 360 result = InstanceKlass::find_method(default_methods, name, signature); 361 assert(result == NULL || !result->is_static(), "static defaults not allowed"); 362 } 363 } 364 return methodHandle(THREAD, result); 365 } 366 367 int LinkResolver::vtable_index_of_interface_method(KlassHandle klass, 368 const methodHandle& resolved_method) { 369 370 int vtable_index = Method::invalid_vtable_index; 371 Symbol* name = resolved_method->name(); 372 Symbol* signature = resolved_method->signature(); 373 InstanceKlass* ik = InstanceKlass::cast(klass()); 374 375 // First check in default method array 376 if (!resolved_method->is_abstract() && ik->default_methods() != NULL) { 377 int index = InstanceKlass::find_method_index(ik->default_methods(), 378 name, signature, Klass::find_overpass, 379 Klass::find_static, Klass::find_private); 380 if (index >= 0 ) { 381 vtable_index = ik->default_vtable_indices()->at(index); 382 } 383 } 384 if (vtable_index == Method::invalid_vtable_index) { 385 // get vtable_index for miranda methods 386 ResourceMark rm; 387 klassVtable *vt = ik->vtable(); 388 vtable_index = vt->index_of_miranda(name, signature); 389 } 390 return vtable_index; 391 } 392 393 methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) { 394 InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass()()); 395 396 // Specify 'true' in order to skip default methods when searching the 397 // interfaces. Function lookup_method_in_klasses() already looked for 398 // the method in the default methods table. 399 return methodHandle(THREAD, 400 ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), 401 Klass::skip_defaults)); 402 } 403 404 methodHandle LinkResolver::lookup_polymorphic_method( 405 const LinkInfo& link_info, 406 Handle *appendix_result_or_null, 407 Handle *method_type_result, 408 TRAPS) { 409 KlassHandle klass = link_info.resolved_klass(); 410 Symbol* name = link_info.name(); 411 Symbol* full_signature = link_info.signature(); 412 413 vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name); 414 if (TraceMethodHandles) { 415 ResourceMark rm(THREAD); 416 tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s", 417 vmIntrinsics::name_at(iid), klass->external_name(), 418 name->as_C_string(), full_signature->as_C_string()); 419 } 420 if ((klass() == SystemDictionary::MethodHandle_klass() || 421 klass() == SystemDictionary::VarHandle_klass()) && 422 iid != vmIntrinsics::_none) { 423 if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { 424 // Most of these do not need an up-call to Java to resolve, so can be done anywhere. 425 // Do not erase last argument type (MemberName) if it is a static linkTo method. 426 bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid); 427 TempNewSymbol basic_signature = 428 MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK_NULL); 429 if (TraceMethodHandles) { 430 ResourceMark rm(THREAD); 431 tty->print_cr("lookup_polymorphic_method %s %s => basic %s", 432 name->as_C_string(), 433 full_signature->as_C_string(), 434 basic_signature->as_C_string()); 435 } 436 methodHandle result = SystemDictionary::find_method_handle_intrinsic(iid, 437 basic_signature, 438 CHECK_NULL); 439 if (result.not_null()) { 440 assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic"); 441 assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this"); 442 assert(basic_signature == result->signature(), "predict the result signature"); 443 if (TraceMethodHandles) { 444 ttyLocker ttyl; 445 tty->print("lookup_polymorphic_method => intrinsic "); 446 result->print_on(tty); 447 } 448 } 449 return result; 450 } else if (iid == vmIntrinsics::_invokeGeneric 451 && THREAD->can_call_java() 452 && appendix_result_or_null != NULL) { 453 // This is a method with type-checking semantics. 454 // We will ask Java code to spin an adapter method for it. 455 if (!MethodHandles::enabled()) { 456 // Make sure the Java part of the runtime has been booted up. 457 Klass* natives = SystemDictionary::MethodHandleNatives_klass(); 458 if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) { 459 SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(), 460 Handle(), 461 Handle(), 462 true, 463 CHECK_NULL); 464 } 465 } 466 467 Handle appendix; 468 Handle method_type; 469 methodHandle result = SystemDictionary::find_method_handle_invoker( 470 klass, 471 name, 472 full_signature, 473 link_info.current_klass(), 474 &appendix, 475 &method_type, 476 CHECK_NULL); 477 if (TraceMethodHandles) { 478 ttyLocker ttyl; 479 tty->print("lookup_polymorphic_method => (via Java) "); 480 result->print_on(tty); 481 tty->print(" lookup_polymorphic_method => appendix = "); 482 if (appendix.is_null()) tty->print_cr("(none)"); 483 else appendix->print_on(tty); 484 } 485 if (result.not_null()) { 486 #ifdef ASSERT 487 ResourceMark rm(THREAD); 488 489 TempNewSymbol basic_signature = 490 MethodHandles::lookup_basic_type_signature(full_signature, CHECK_NULL); 491 int actual_size_of_params = result->size_of_parameters(); 492 int expected_size_of_params = ArgumentSizeComputer(basic_signature).size(); 493 // +1 for MethodHandle.this, +1 for trailing MethodType 494 if (!MethodHandles::is_signature_polymorphic_static(iid)) expected_size_of_params += 1; 495 if (appendix.not_null()) expected_size_of_params += 1; 496 if (actual_size_of_params != expected_size_of_params) { 497 tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string()); 498 tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid)); 499 result->print(); 500 } 501 assert(actual_size_of_params == expected_size_of_params, 502 "%d != %d", actual_size_of_params, expected_size_of_params); 503 #endif //ASSERT 504 505 assert(appendix_result_or_null != NULL, ""); 506 (*appendix_result_or_null) = appendix; 507 (*method_type_result) = method_type; 508 } 509 return result; 510 } 511 } 512 return NULL; 513 } 514 515 void LinkResolver::check_method_accessability(KlassHandle ref_klass, 516 KlassHandle resolved_klass, 517 KlassHandle sel_klass, 518 const methodHandle& sel_method, 519 TRAPS) { 520 521 AccessFlags flags = sel_method->access_flags(); 522 523 // Special case: arrays always override "clone". JVMS 2.15. 524 // If the resolved klass is an array class, and the declaring class 525 // is java.lang.Object and the method is "clone", set the flags 526 // to public. 527 // 528 // We'll check for the method name first, as that's most likely 529 // to be false (so we'll short-circuit out of these tests). 530 if (sel_method->name() == vmSymbols::clone_name() && 531 sel_klass() == SystemDictionary::Object_klass() && 532 resolved_klass->is_array_klass()) { 533 // We need to change "protected" to "public". 534 assert(flags.is_protected(), "clone not protected?"); 535 jint new_flags = flags.as_int(); 536 new_flags = new_flags & (~JVM_ACC_PROTECTED); 537 new_flags = new_flags | JVM_ACC_PUBLIC; 538 flags.set_flags(new_flags); 539 } 540 // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); 541 542 if (!Reflection::verify_field_access(ref_klass(), 543 resolved_klass(), 544 sel_klass(), 545 flags, 546 true)) { 547 ResourceMark rm(THREAD); 548 Exceptions::fthrow( 549 THREAD_AND_LOCATION, 550 vmSymbols::java_lang_IllegalAccessError(), 551 "tried to access method %s.%s%s from class %s", 552 sel_klass->external_name(), 553 sel_method->name()->as_C_string(), 554 sel_method->signature()->as_C_string(), 555 ref_klass->external_name() 556 ); 557 return; 558 } 559 } 560 561 methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code, 562 const constantPoolHandle& pool, int index, TRAPS) { 563 // This method is used only 564 // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call), 565 // and 566 // (2) in Bytecode_invoke::static_target 567 // It appears to fail when applied to an invokeinterface call site. 568 // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. 569 // resolve klass 570 KlassHandle resolved_klass; 571 if (code == Bytecodes::_invokedynamic) { 572 resolved_klass = SystemDictionary::MethodHandle_klass(); 573 Symbol* method_name = vmSymbols::invoke_name(); 574 Symbol* method_signature = pool->signature_ref_at(index); 575 KlassHandle current_klass(THREAD, pool->pool_holder()); 576 LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass, NULL); 577 return resolve_method(link_info, /*require_methodref*/false, THREAD); 578 } 579 580 LinkInfo link_info(pool, index, NULL, CHECK_NULL); 581 resolved_klass = link_info.resolved_klass(); 582 583 if (pool->has_preresolution() 584 || (resolved_klass() == SystemDictionary::MethodHandle_klass() && 585 MethodHandles::is_signature_polymorphic_name(resolved_klass(), link_info.name()))) { 586 Method* result = ConstantPool::method_at_if_loaded(pool, index); 587 if (result != NULL) { 588 return methodHandle(THREAD, result); 589 } 590 } 591 592 if (code == Bytecodes::_invokeinterface) { 593 return resolve_interface_method(link_info, code, THREAD); 594 } else if (code == Bytecodes::_invokevirtual) { 595 return resolve_method(link_info, /*require_methodref*/true, THREAD); 596 } else if (!resolved_klass->is_interface()) { 597 return resolve_method(link_info, /*require_methodref*/false, THREAD); 598 } else { 599 return resolve_interface_method(link_info, code, THREAD); 600 } 601 } 602 603 // Check and print a loader constraint violation message for method or interface method 604 void LinkResolver::check_method_loader_constraints(const LinkInfo& link_info, 605 const methodHandle& resolved_method, 606 const char* method_type, TRAPS) { 607 Handle current_loader(THREAD, link_info.current_klass()->class_loader()); 608 Handle resolved_loader(THREAD, resolved_method->method_holder()->class_loader()); 609 610 ResourceMark rm(THREAD); 611 Symbol* failed_type_symbol = 612 SystemDictionary::check_signature_loaders(link_info.signature(), current_loader, 613 resolved_loader, true, CHECK); 614 if (failed_type_symbol != NULL) { 615 const char* msg = "loader constraint violation: when resolving %s" 616 " \"%s\" the class loader (instance of %s) of the current class, %s," 617 " and the class loader (instance of %s) for the method's defining class, %s, have" 618 " different Class objects for the type %s used in the signature"; 619 char* sig = link_info.method_string(); 620 const char* loader1_name = SystemDictionary::loader_name(current_loader()); 621 char* current = link_info.current_klass()->name()->as_C_string(); 622 const char* loader2_name = SystemDictionary::loader_name(resolved_loader()); 623 char* target = resolved_method->method_holder()->name()->as_C_string(); 624 char* failed_type_name = failed_type_symbol->as_C_string(); 625 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1_name) + 626 strlen(current) + strlen(loader2_name) + strlen(target) + 627 strlen(failed_type_name) + strlen(method_type) + 1; 628 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); 629 jio_snprintf(buf, buflen, msg, method_type, sig, loader1_name, current, loader2_name, 630 target, failed_type_name); 631 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); 632 } 633 } 634 635 void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig, 636 KlassHandle current_klass, 637 KlassHandle sel_klass, TRAPS) { 638 Handle ref_loader(THREAD, current_klass->class_loader()); 639 Handle sel_loader(THREAD, sel_klass->class_loader()); 640 641 ResourceMark rm(THREAD); // needed for check_signature_loaders 642 Symbol* failed_type_symbol = 643 SystemDictionary::check_signature_loaders(sig, 644 ref_loader, sel_loader, 645 false, 646 CHECK); 647 if (failed_type_symbol != NULL) { 648 const char* msg = "loader constraint violation: when resolving field" 649 " \"%s\" the class loader (instance of %s) of the referring class, " 650 "%s, and the class loader (instance of %s) for the field's resolved " 651 "type, %s, have different Class objects for that type"; 652 char* field_name = field->as_C_string(); 653 const char* loader1_name = SystemDictionary::loader_name(ref_loader()); 654 char* sel = sel_klass->name()->as_C_string(); 655 const char* loader2_name = SystemDictionary::loader_name(sel_loader()); 656 char* failed_type_name = failed_type_symbol->as_C_string(); 657 size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1_name) + 658 strlen(sel) + strlen(loader2_name) + strlen(failed_type_name) + 1; 659 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); 660 jio_snprintf(buf, buflen, msg, field_name, loader1_name, sel, loader2_name, 661 failed_type_name); 662 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); 663 } 664 } 665 666 methodHandle LinkResolver::resolve_method(const LinkInfo& link_info, 667 bool require_methodref, TRAPS) { 668 669 Handle nested_exception; 670 KlassHandle resolved_klass = link_info.resolved_klass(); 671 672 // 1. check if methodref required, that resolved_klass is not interfacemethodref 673 if (require_methodref && resolved_klass->is_interface()) { 674 ResourceMark rm(THREAD); 675 char buf[200]; 676 jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", 677 resolved_klass()->external_name()); 678 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 679 } 680 681 // 2. lookup method in resolved klass and its super klasses 682 methodHandle resolved_method = lookup_method_in_klasses(link_info, true, false, CHECK_NULL); 683 684 if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy 685 // 3. lookup method in all the interfaces implemented by the resolved klass 686 resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL); 687 688 if (resolved_method.is_null()) { 689 // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc 690 resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, (Handle*)NULL, THREAD); 691 if (HAS_PENDING_EXCEPTION) { 692 nested_exception = Handle(THREAD, PENDING_EXCEPTION); 693 CLEAR_PENDING_EXCEPTION; 694 } 695 } 696 } 697 698 if (resolved_method.is_null()) { 699 // 4. method lookup failed 700 ResourceMark rm(THREAD); 701 THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(), 702 Method::name_and_sig_as_C_string(resolved_klass(), 703 link_info.name(), 704 link_info.signature()), 705 nested_exception, NULL); 706 } 707 708 // 5. access checks, access checking may be turned off when calling from within the VM. 709 KlassHandle current_klass = link_info.current_klass(); 710 if (link_info.check_access()) { 711 assert(current_klass.not_null() , "current_klass should not be null"); 712 713 // check if method can be accessed by the referring class 714 check_method_accessability(current_klass, 715 resolved_klass, 716 KlassHandle(THREAD, resolved_method->method_holder()), 717 resolved_method, 718 CHECK_NULL); 719 720 // check loader constraints 721 check_method_loader_constraints(link_info, resolved_method, "method", CHECK_NULL); 722 } 723 724 return resolved_method; 725 } 726 727 static void trace_method_resolution(const char* prefix, 728 KlassHandle klass, 729 KlassHandle resolved_klass, 730 const methodHandle& method, 731 bool logitables, 732 int index = -1) { 733 #ifndef PRODUCT 734 ResourceMark rm; 735 outputStream* st; 736 if (logitables) { 737 st = Log(itables)::trace_stream(); 738 } else { 739 st = Log(vtables)::trace_stream(); 740 } 741 st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", 742 prefix, 743 (klass.is_null() ? "<NULL>" : klass->internal_name()), 744 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 745 Method::name_and_sig_as_C_string(resolved_klass(), 746 method->name(), 747 method->signature()), 748 method->method_holder()->internal_name()); 749 method->print_linkage_flags(st); 750 if (index != -1) { 751 st->print("vtable_index:%d", index); 752 } 753 st->cr(); 754 #endif // PRODUCT 755 } 756 757 // Do linktime resolution of a method in the interface within the context of the specied bytecode. 758 methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) { 759 760 KlassHandle resolved_klass = link_info.resolved_klass(); 761 762 // check if klass is interface 763 if (!resolved_klass->is_interface()) { 764 ResourceMark rm(THREAD); 765 char buf[200]; 766 jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); 767 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 768 } 769 770 // lookup method in this interface or its super, java.lang.Object 771 // JDK8: also look for static methods 772 methodHandle resolved_method = lookup_method_in_klasses(link_info, false, true, CHECK_NULL); 773 774 if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { 775 // lookup method in all the super-interfaces 776 resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL); 777 } 778 779 if (resolved_method.is_null()) { 780 // no method found 781 ResourceMark rm(THREAD); 782 THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), 783 Method::name_and_sig_as_C_string(resolved_klass(), 784 link_info.name(), 785 link_info.signature())); 786 } 787 788 if (link_info.check_access()) { 789 // JDK8 adds non-public interface methods, and accessability check requirement 790 KlassHandle current_klass = link_info.current_klass(); 791 792 assert(current_klass.not_null() , "current_klass should not be null"); 793 794 // check if method can be accessed by the referring class 795 check_method_accessability(current_klass, 796 resolved_klass, 797 KlassHandle(THREAD, resolved_method->method_holder()), 798 resolved_method, 799 CHECK_NULL); 800 801 check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL); 802 } 803 804 if (code != Bytecodes::_invokestatic && resolved_method->is_static()) { 805 ResourceMark rm(THREAD); 806 char buf[200]; 807 jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", 808 Method::name_and_sig_as_C_string(resolved_klass(), 809 resolved_method->name(), resolved_method->signature())); 810 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 811 } 812 813 if (code == Bytecodes::_invokeinterface && resolved_method->is_private()) { 814 ResourceMark rm(THREAD); 815 char buf[200]; 816 817 KlassHandle current_klass = link_info.current_klass(); 818 jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s, caller-class:%s", 819 Method::name_and_sig_as_C_string(resolved_klass(), 820 resolved_method->name(), 821 resolved_method->signature()), 822 (current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); 823 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 824 } 825 826 if (log_develop_is_enabled(Trace, itables)) { 827 trace_method_resolution("invokeinterface resolved method: caller-class", 828 link_info.current_klass(), resolved_klass, 829 resolved_method, true); 830 } 831 832 return resolved_method; 833 } 834 835 //------------------------------------------------------------------------------------------------------------------------ 836 // Field resolution 837 838 void LinkResolver::check_field_accessability(KlassHandle ref_klass, 839 KlassHandle resolved_klass, 840 KlassHandle sel_klass, 841 const fieldDescriptor& fd, 842 TRAPS) { 843 if (!Reflection::verify_field_access(ref_klass(), 844 resolved_klass(), 845 sel_klass(), 846 fd.access_flags(), 847 true)) { 848 ResourceMark rm(THREAD); 849 Exceptions::fthrow( 850 THREAD_AND_LOCATION, 851 vmSymbols::java_lang_IllegalAccessError(), 852 "tried to access field %s.%s from class %s", 853 sel_klass->external_name(), 854 fd.name()->as_C_string(), 855 ref_klass->external_name() 856 ); 857 return; 858 } 859 } 860 861 void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) { 862 LinkInfo link_info(pool, index, method, CHECK); 863 resolve_field(fd, link_info, byte, true, CHECK); 864 } 865 866 void LinkResolver::resolve_field(fieldDescriptor& fd, 867 const LinkInfo& link_info, 868 Bytecodes::Code byte, bool initialize_class, 869 TRAPS) { 870 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || 871 byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || 872 byte == Bytecodes::_nofast_getfield || byte == Bytecodes::_nofast_putfield || 873 (byte == Bytecodes::_nop && !link_info.check_access()), "bad field access bytecode"); 874 875 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); 876 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); 877 // Check if there's a resolved klass containing the field 878 KlassHandle resolved_klass = link_info.resolved_klass(); 879 Symbol* field = link_info.name(); 880 Symbol* sig = link_info.signature(); 881 882 if (resolved_klass.is_null()) { 883 ResourceMark rm(THREAD); 884 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 885 } 886 887 // Resolve instance field 888 KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); 889 // check if field exists; i.e., if a klass containing the field def has been selected 890 if (sel_klass.is_null()) { 891 ResourceMark rm(THREAD); 892 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 893 } 894 895 if (!link_info.check_access()) 896 // Access checking may be turned off when calling from within the VM. 897 return; 898 899 // check access 900 KlassHandle current_klass = link_info.current_klass(); 901 check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); 902 903 // check for errors 904 if (is_static != fd.is_static()) { 905 ResourceMark rm(THREAD); 906 char msg[200]; 907 jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string()); 908 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); 909 } 910 911 // A final field can be modified only 912 // (1) by methods declared in the class declaring the field and 913 // (2) by the <clinit> method (in case of a static field) 914 // or by the <init> method (in case of an instance field). 915 if (is_put && fd.access_flags().is_final()) { 916 if (sel_klass() != current_klass()) { 917 THROW(vmSymbols::java_lang_IllegalAccessError()); 918 } 919 920 if (CheckFinalFieldModifications && 921 fd.constants()->pool_holder()->major_version() >= 52) { 922 methodHandle m = link_info.current_method(); 923 assert(!m.is_null(), "information about the current method must be available for 'put' bytecodes"); 924 Symbol* method_name = m->name(); 925 if ((byte == Bytecodes::_putstatic && fd.is_static() && method_name != vmSymbols::class_initializer_name()) || 926 ((byte == Bytecodes::_putfield || byte == Bytecodes::_nofast_putfield) && !fd.is_static() && method_name != vmSymbols::object_initializer_name())) { 927 THROW(vmSymbols::java_lang_IllegalAccessError()); 928 } 929 } 930 } 931 932 // initialize resolved_klass if necessary 933 // note 1: the klass which declared the field must be initialized (i.e, sel_klass) 934 // according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99) 935 // 936 // note 2: we don't want to force initialization if we are just checking 937 // if the field access is legal; e.g., during compilation 938 if (is_static && initialize_class) { 939 sel_klass->initialize(CHECK); 940 } 941 942 if (sel_klass() != current_klass()) { 943 check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK); 944 } 945 946 // return information. note that the klass is set to the actual klass containing the 947 // field, otherwise access of static fields in superclasses will not work. 948 } 949 950 951 //------------------------------------------------------------------------------------------------------------------------ 952 // Invoke resolution 953 // 954 // Naming conventions: 955 // 956 // resolved_method the specified method (i.e., static receiver specified via constant pool index) 957 // sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class) 958 // resolved_klass the specified klass (i.e., specified via constant pool index) 959 // recv_klass the receiver klass 960 961 962 void LinkResolver::resolve_static_call(CallInfo& result, 963 const LinkInfo& link_info, 964 bool initialize_class, TRAPS) { 965 methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK); 966 967 // The resolved class can change as a result of this resolution. 968 KlassHandle resolved_klass = KlassHandle(THREAD, resolved_method->method_holder()); 969 970 Method* save_resolved_method = resolved_method(); 971 // Initialize klass (this should only happen if everything is ok) 972 if (initialize_class && resolved_klass->should_be_initialized()) { 973 resolved_klass->initialize(CHECK); 974 // Use updated LinkInfo (to reresolve with resolved_klass as method_holder?) 975 LinkInfo new_info(resolved_klass, link_info.name(), link_info.signature(), 976 link_info.current_klass(), NULL, link_info.check_access()); 977 resolved_method = linktime_resolve_static_method(new_info, CHECK); 978 } 979 980 assert(save_resolved_method == resolved_method(), "does this change?"); 981 // setup result 982 result.set_static(resolved_klass, resolved_method, CHECK); 983 } 984 985 // throws linktime exceptions 986 methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) { 987 988 KlassHandle resolved_klass = link_info.resolved_klass(); 989 methodHandle resolved_method; 990 if (!resolved_klass->is_interface()) { 991 resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); 992 } else { 993 resolved_method = resolve_interface_method(link_info, Bytecodes::_invokestatic, CHECK_NULL); 994 } 995 assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); 996 997 // check if static 998 if (!resolved_method->is_static()) { 999 ResourceMark rm(THREAD); 1000 char buf[200]; 1001 jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), 1002 resolved_method->name(), 1003 resolved_method->signature())); 1004 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1005 } 1006 return resolved_method; 1007 } 1008 1009 1010 void LinkResolver::resolve_special_call(CallInfo& result, 1011 const LinkInfo& link_info, 1012 TRAPS) { 1013 methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK); 1014 runtime_resolve_special_method(result, resolved_method, 1015 link_info.resolved_klass(), 1016 link_info.current_klass(), 1017 link_info.check_access(), CHECK); 1018 } 1019 1020 // throws linktime exceptions 1021 methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, 1022 TRAPS) { 1023 1024 // Invokespecial is called for multiple special reasons: 1025 // <init> 1026 // local private method invocation, for classes and interfaces 1027 // superclass.method, which can also resolve to a default method 1028 // and the selected method is recalculated relative to the direct superclass 1029 // superinterface.method, which explicitly does not check shadowing 1030 KlassHandle resolved_klass = link_info.resolved_klass(); 1031 methodHandle resolved_method; 1032 1033 if (!resolved_klass->is_interface()) { 1034 resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); 1035 } else { 1036 resolved_method = resolve_interface_method(link_info, Bytecodes::_invokespecial, CHECK_NULL); 1037 } 1038 1039 // check if method name is <init>, that it is found in same klass as static type 1040 if (resolved_method->name() == vmSymbols::object_initializer_name() && 1041 resolved_method->method_holder() != resolved_klass()) { 1042 ResourceMark rm(THREAD); 1043 Exceptions::fthrow( 1044 THREAD_AND_LOCATION, 1045 vmSymbols::java_lang_NoSuchMethodError(), 1046 "%s: method %s%s not found", 1047 resolved_klass->external_name(), 1048 resolved_method->name()->as_C_string(), 1049 resolved_method->signature()->as_C_string() 1050 ); 1051 return NULL; 1052 } 1053 1054 // check if invokespecial's interface method reference is in an indirect superinterface 1055 KlassHandle current_klass = link_info.current_klass(); 1056 if (!current_klass.is_null() && resolved_klass->is_interface()) { 1057 Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ? 1058 current_klass() : 1059 InstanceKlass::cast(current_klass())->host_klass(); 1060 // Disable verification for the dynamically-generated reflection bytecodes. 1061 bool is_reflect = klass_to_check->is_subclass_of( 1062 SystemDictionary::reflect_MagicAccessorImpl_klass()); 1063 1064 if (!is_reflect && 1065 !InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) { 1066 ResourceMark rm(THREAD); 1067 char buf[200]; 1068 jio_snprintf(buf, sizeof(buf), 1069 "Interface method reference: %s, is in an indirect superinterface of %s", 1070 Method::name_and_sig_as_C_string(resolved_klass(), 1071 resolved_method->name(), 1072 resolved_method->signature()), 1073 current_klass->external_name()); 1074 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1075 } 1076 } 1077 1078 // check if not static 1079 if (resolved_method->is_static()) { 1080 ResourceMark rm(THREAD); 1081 char buf[200]; 1082 jio_snprintf(buf, sizeof(buf), 1083 "Expecting non-static method %s", 1084 Method::name_and_sig_as_C_string(resolved_klass(), 1085 resolved_method->name(), 1086 resolved_method->signature())); 1087 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1088 } 1089 1090 if (log_develop_is_enabled(Trace, itables)) { 1091 trace_method_resolution("invokespecial resolved method: caller-class:", 1092 current_klass, resolved_klass, resolved_method, true); 1093 } 1094 1095 return resolved_method; 1096 } 1097 1098 // throws runtime exceptions 1099 void LinkResolver::runtime_resolve_special_method(CallInfo& result, 1100 const methodHandle& resolved_method, 1101 KlassHandle resolved_klass, 1102 KlassHandle current_klass, 1103 bool check_access, TRAPS) { 1104 1105 // resolved method is selected method unless we have an old-style lookup 1106 // for a superclass method 1107 // Invokespecial for a superinterface, resolved method is selected method, 1108 // no checks for shadowing 1109 methodHandle sel_method(THREAD, resolved_method()); 1110 1111 // check if this is an old-style super call and do a new lookup if so 1112 { KlassHandle method_klass = KlassHandle(THREAD, 1113 resolved_method->method_holder()); 1114 1115 if (check_access && 1116 // a) check if ACC_SUPER flag is set for the current class 1117 (current_klass->is_super() || !AllowNonVirtualCalls) && 1118 // b) check if the class of the resolved_klass is a superclass 1119 // (not supertype in order to exclude interface classes) of the current class. 1120 // This check is not performed for super.invoke for interface methods 1121 // in super interfaces. 1122 current_klass->is_subclass_of(resolved_klass()) && 1123 current_klass() != resolved_klass() && 1124 // c) check if the method is not <init> 1125 resolved_method->name() != vmSymbols::object_initializer_name()) { 1126 // Lookup super method 1127 KlassHandle super_klass(THREAD, current_klass->super()); 1128 sel_method = lookup_instance_method_in_klasses(super_klass, 1129 resolved_method->name(), 1130 resolved_method->signature(), CHECK); 1131 // check if found 1132 if (sel_method.is_null()) { 1133 ResourceMark rm(THREAD); 1134 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 1135 Method::name_and_sig_as_C_string(resolved_klass(), 1136 resolved_method->name(), 1137 resolved_method->signature())); 1138 } 1139 } 1140 } 1141 1142 // check if not static 1143 if (sel_method->is_static()) { 1144 ResourceMark rm(THREAD); 1145 char buf[200]; 1146 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), 1147 resolved_method->name(), 1148 resolved_method->signature())); 1149 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1150 } 1151 1152 // check if abstract 1153 if (sel_method->is_abstract()) { 1154 ResourceMark rm(THREAD); 1155 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 1156 Method::name_and_sig_as_C_string(resolved_klass(), 1157 sel_method->name(), 1158 sel_method->signature())); 1159 } 1160 1161 if (log_develop_is_enabled(Trace, itables)) { 1162 trace_method_resolution("invokespecial selected method: resolved-class:", 1163 resolved_klass, resolved_klass, sel_method, true); 1164 } 1165 1166 // setup result 1167 result.set_static(resolved_klass, sel_method, CHECK); 1168 } 1169 1170 void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, 1171 const LinkInfo& link_info, 1172 bool check_null_and_abstract, TRAPS) { 1173 methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK); 1174 runtime_resolve_virtual_method(result, resolved_method, 1175 link_info.resolved_klass(), 1176 recv, receiver_klass, 1177 check_null_and_abstract, CHECK); 1178 } 1179 1180 // throws linktime exceptions 1181 methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_info, 1182 TRAPS) { 1183 // normal method resolution 1184 methodHandle resolved_method = resolve_method(link_info, /*require_methodref*/true, CHECK_NULL); 1185 1186 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); 1187 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); 1188 1189 // check if private interface method 1190 KlassHandle resolved_klass = link_info.resolved_klass(); 1191 KlassHandle current_klass = link_info.current_klass(); 1192 1193 if (resolved_klass->is_interface() && resolved_method->is_private()) { 1194 ResourceMark rm(THREAD); 1195 char buf[200]; 1196 jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", 1197 Method::name_and_sig_as_C_string(resolved_klass(), 1198 resolved_method->name(), 1199 resolved_method->signature()), 1200 (current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); 1201 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1202 } 1203 1204 // check if not static 1205 if (resolved_method->is_static()) { 1206 ResourceMark rm(THREAD); 1207 char buf[200]; 1208 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), 1209 resolved_method->name(), 1210 resolved_method->signature())); 1211 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1212 } 1213 1214 if (log_develop_is_enabled(Trace, vtables)) { 1215 trace_method_resolution("invokevirtual resolved method: caller-class:", 1216 current_klass, resolved_klass, resolved_method, false); 1217 } 1218 1219 return resolved_method; 1220 } 1221 1222 // throws runtime exceptions 1223 void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, 1224 const methodHandle& resolved_method, 1225 KlassHandle resolved_klass, 1226 Handle recv, 1227 KlassHandle recv_klass, 1228 bool check_null_and_abstract, 1229 TRAPS) { 1230 1231 // setup default return values 1232 int vtable_index = Method::invalid_vtable_index; 1233 methodHandle selected_method; 1234 1235 assert(recv.is_null() || recv->is_oop(), "receiver is not an oop"); 1236 1237 // runtime method resolution 1238 if (check_null_and_abstract && recv.is_null()) { // check if receiver exists 1239 THROW(vmSymbols::java_lang_NullPointerException()); 1240 } 1241 1242 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s 1243 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since 1244 // a missing receiver might result in a bogus lookup. 1245 assert(resolved_method->method_holder()->is_linked(), "must be linked"); 1246 1247 // do lookup based on receiver klass using the vtable index 1248 if (resolved_method->method_holder()->is_interface()) { // default or miranda method 1249 vtable_index = vtable_index_of_interface_method(resolved_klass, 1250 resolved_method); 1251 assert(vtable_index >= 0 , "we should have valid vtable index at this point"); 1252 1253 selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index)); 1254 } else { 1255 // at this point we are sure that resolved_method is virtual and not 1256 // a default or miranda method; therefore, it must have a valid vtable index. 1257 assert(!resolved_method->has_itable_index(), ""); 1258 vtable_index = resolved_method->vtable_index(); 1259 // We could get a negative vtable_index for final methods, 1260 // because as an optimization they are they are never put in the vtable, 1261 // unless they override an existing method. 1262 // If we do get a negative, it means the resolved method is the the selected 1263 // method, and it can never be changed by an override. 1264 if (vtable_index == Method::nonvirtual_vtable_index) { 1265 assert(resolved_method->can_be_statically_bound(), "cannot override this method"); 1266 selected_method = resolved_method; 1267 } else { 1268 selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index)); 1269 } 1270 } 1271 1272 // check if method exists 1273 if (selected_method.is_null()) { 1274 ResourceMark rm(THREAD); 1275 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 1276 Method::name_and_sig_as_C_string(resolved_klass(), 1277 resolved_method->name(), 1278 resolved_method->signature())); 1279 } 1280 1281 // check if abstract 1282 if (check_null_and_abstract && selected_method->is_abstract()) { 1283 ResourceMark rm(THREAD); 1284 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 1285 Method::name_and_sig_as_C_string(resolved_klass(), 1286 selected_method->name(), 1287 selected_method->signature())); 1288 } 1289 1290 if (log_develop_is_enabled(Trace, vtables)) { 1291 trace_method_resolution("invokevirtual selected method: receiver-class:", 1292 recv_klass, resolved_klass, selected_method, 1293 false, vtable_index); 1294 } 1295 // setup result 1296 result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); 1297 } 1298 1299 void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, 1300 const LinkInfo& link_info, 1301 bool check_null_and_abstract, TRAPS) { 1302 // throws linktime exceptions 1303 methodHandle resolved_method = linktime_resolve_interface_method(link_info, CHECK); 1304 runtime_resolve_interface_method(result, resolved_method,link_info.resolved_klass(), 1305 recv, recv_klass, check_null_and_abstract, CHECK); 1306 } 1307 1308 methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info, 1309 TRAPS) { 1310 // normal interface method resolution 1311 methodHandle resolved_method = resolve_interface_method(link_info, Bytecodes::_invokeinterface, CHECK_NULL); 1312 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); 1313 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); 1314 1315 return resolved_method; 1316 } 1317 1318 // throws runtime exceptions 1319 void LinkResolver::runtime_resolve_interface_method(CallInfo& result, 1320 const methodHandle& resolved_method, 1321 KlassHandle resolved_klass, 1322 Handle recv, 1323 KlassHandle recv_klass, 1324 bool check_null_and_abstract, TRAPS) { 1325 // check if receiver exists 1326 if (check_null_and_abstract && recv.is_null()) { 1327 THROW(vmSymbols::java_lang_NullPointerException()); 1328 } 1329 1330 // check if receiver klass implements the resolved interface 1331 if (!recv_klass->is_subtype_of(resolved_klass())) { 1332 ResourceMark rm(THREAD); 1333 char buf[200]; 1334 jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", 1335 recv_klass()->external_name(), 1336 resolved_klass()->external_name()); 1337 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 1338 } 1339 1340 // do lookup based on receiver klass 1341 // This search must match the linktime preparation search for itable initialization 1342 // to correctly enforce loader constraints for interface method inheritance 1343 methodHandle sel_method = lookup_instance_method_in_klasses(recv_klass, 1344 resolved_method->name(), 1345 resolved_method->signature(), CHECK); 1346 if (sel_method.is_null() && !check_null_and_abstract) { 1347 // In theory this is a harmless placeholder value, but 1348 // in practice leaving in null affects the nsk default method tests. 1349 // This needs further study. 1350 sel_method = resolved_method; 1351 } 1352 // check if method exists 1353 if (sel_method.is_null()) { 1354 ResourceMark rm(THREAD); 1355 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 1356 Method::name_and_sig_as_C_string(recv_klass(), 1357 resolved_method->name(), 1358 resolved_method->signature())); 1359 } 1360 // check access 1361 // Throw Illegal Access Error if sel_method is not public. 1362 if (!sel_method->is_public()) { 1363 ResourceMark rm(THREAD); 1364 THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), 1365 Method::name_and_sig_as_C_string(recv_klass(), 1366 sel_method->name(), 1367 sel_method->signature())); 1368 } 1369 // check if abstract 1370 if (check_null_and_abstract && sel_method->is_abstract()) { 1371 ResourceMark rm(THREAD); 1372 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 1373 Method::name_and_sig_as_C_string(recv_klass(), 1374 sel_method->name(), 1375 sel_method->signature())); 1376 } 1377 1378 if (log_develop_is_enabled(Trace, itables)) { 1379 trace_method_resolution("invokeinterface selected method: receiver-class", 1380 recv_klass, resolved_klass, sel_method, true); 1381 } 1382 // setup result 1383 if (!resolved_method->has_itable_index()) { 1384 int vtable_index = resolved_method->vtable_index(); 1385 assert(vtable_index == sel_method->vtable_index(), "sanity check"); 1386 result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK); 1387 } else { 1388 int itable_index = resolved_method()->itable_index(); 1389 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); 1390 } 1391 } 1392 1393 1394 methodHandle LinkResolver::linktime_resolve_interface_method_or_null( 1395 const LinkInfo& link_info) { 1396 EXCEPTION_MARK; 1397 methodHandle method_result = linktime_resolve_interface_method(link_info, THREAD); 1398 if (HAS_PENDING_EXCEPTION) { 1399 CLEAR_PENDING_EXCEPTION; 1400 return methodHandle(); 1401 } else { 1402 return method_result; 1403 } 1404 } 1405 1406 methodHandle LinkResolver::linktime_resolve_virtual_method_or_null( 1407 const LinkInfo& link_info) { 1408 EXCEPTION_MARK; 1409 methodHandle method_result = linktime_resolve_virtual_method(link_info, THREAD); 1410 if (HAS_PENDING_EXCEPTION) { 1411 CLEAR_PENDING_EXCEPTION; 1412 return methodHandle(); 1413 } else { 1414 return method_result; 1415 } 1416 } 1417 1418 methodHandle LinkResolver::resolve_virtual_call_or_null( 1419 KlassHandle receiver_klass, 1420 const LinkInfo& link_info) { 1421 EXCEPTION_MARK; 1422 CallInfo info; 1423 resolve_virtual_call(info, Handle(), receiver_klass, link_info, false, THREAD); 1424 if (HAS_PENDING_EXCEPTION) { 1425 CLEAR_PENDING_EXCEPTION; 1426 return methodHandle(); 1427 } 1428 return info.selected_method(); 1429 } 1430 1431 methodHandle LinkResolver::resolve_interface_call_or_null( 1432 KlassHandle receiver_klass, 1433 const LinkInfo& link_info) { 1434 EXCEPTION_MARK; 1435 CallInfo info; 1436 resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD); 1437 if (HAS_PENDING_EXCEPTION) { 1438 CLEAR_PENDING_EXCEPTION; 1439 return methodHandle(); 1440 } 1441 return info.selected_method(); 1442 } 1443 1444 int LinkResolver::resolve_virtual_vtable_index(KlassHandle receiver_klass, 1445 const LinkInfo& link_info) { 1446 EXCEPTION_MARK; 1447 CallInfo info; 1448 resolve_virtual_call(info, Handle(), receiver_klass, link_info, 1449 /*check_null_or_abstract*/false, THREAD); 1450 if (HAS_PENDING_EXCEPTION) { 1451 CLEAR_PENDING_EXCEPTION; 1452 return Method::invalid_vtable_index; 1453 } 1454 return info.vtable_index(); 1455 } 1456 1457 methodHandle LinkResolver::resolve_static_call_or_null(const LinkInfo& link_info) { 1458 EXCEPTION_MARK; 1459 CallInfo info; 1460 resolve_static_call(info, link_info, /*initialize_class*/false, THREAD); 1461 if (HAS_PENDING_EXCEPTION) { 1462 CLEAR_PENDING_EXCEPTION; 1463 return methodHandle(); 1464 } 1465 return info.selected_method(); 1466 } 1467 1468 methodHandle LinkResolver::resolve_special_call_or_null(const LinkInfo& link_info) { 1469 EXCEPTION_MARK; 1470 CallInfo info; 1471 resolve_special_call(info, link_info, THREAD); 1472 if (HAS_PENDING_EXCEPTION) { 1473 CLEAR_PENDING_EXCEPTION; 1474 return methodHandle(); 1475 } 1476 return info.selected_method(); 1477 } 1478 1479 1480 1481 //------------------------------------------------------------------------------------------------------------------------ 1482 // ConstantPool entries 1483 1484 void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { 1485 switch (byte) { 1486 case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break; 1487 case Bytecodes::_invokespecial : resolve_invokespecial (result, pool, index, CHECK); break; 1488 case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break; 1489 case Bytecodes::_invokehandle : resolve_invokehandle (result, pool, index, CHECK); break; 1490 case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; 1491 case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; 1492 } 1493 return; 1494 } 1495 1496 void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv, 1497 const methodHandle& attached_method, 1498 Bytecodes::Code byte, TRAPS) { 1499 KlassHandle defc = attached_method->method_holder(); 1500 Symbol* name = attached_method->name(); 1501 Symbol* type = attached_method->signature(); 1502 LinkInfo link_info(defc, name, type, KlassHandle(), NULL, /*check_access=*/false); 1503 switch(byte) { 1504 case Bytecodes::_invokevirtual: 1505 resolve_virtual_call(result, recv, recv->klass(), link_info, 1506 /*check_null_and_abstract=*/true, CHECK); 1507 break; 1508 case Bytecodes::_invokeinterface: 1509 resolve_interface_call(result, recv, recv->klass(), link_info, 1510 /*check_null_and_abstract=*/true, CHECK); 1511 break; 1512 case Bytecodes::_invokestatic: 1513 resolve_static_call(result, link_info, /*initialize_class=*/false, CHECK); 1514 break; 1515 case Bytecodes::_invokespecial: 1516 resolve_special_call(result, link_info, CHECK); 1517 break; 1518 default: 1519 fatal("bad call: %s", Bytecodes::name(byte)); 1520 } 1521 } 1522 1523 void LinkResolver::resolve_invokestatic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { 1524 LinkInfo link_info(pool, index, NULL, CHECK); 1525 resolve_static_call(result, link_info, /*initialize_class*/true, CHECK); 1526 } 1527 1528 1529 void LinkResolver::resolve_invokespecial(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { 1530 LinkInfo link_info(pool, index, NULL, CHECK); 1531 resolve_special_call(result, link_info, CHECK); 1532 } 1533 1534 1535 void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv, 1536 const constantPoolHandle& pool, int index, 1537 TRAPS) { 1538 1539 LinkInfo link_info(pool, index, NULL, CHECK); 1540 KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); 1541 resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK); 1542 } 1543 1544 1545 void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) { 1546 LinkInfo link_info(pool, index, NULL, CHECK); 1547 KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); 1548 resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK); 1549 } 1550 1551 1552 void LinkResolver::resolve_invokehandle(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { 1553 // This guy is reached from InterpreterRuntime::resolve_invokehandle. 1554 LinkInfo link_info(pool, index, NULL, CHECK); 1555 if (TraceMethodHandles) { 1556 ResourceMark rm(THREAD); 1557 tty->print_cr("resolve_invokehandle %s %s", link_info.name()->as_C_string(), 1558 link_info.signature()->as_C_string()); 1559 } 1560 resolve_handle_call(result, link_info, CHECK); 1561 } 1562 1563 void LinkResolver::resolve_handle_call(CallInfo& result, 1564 const LinkInfo& link_info, 1565 TRAPS) { 1566 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar 1567 KlassHandle resolved_klass = link_info.resolved_klass(); 1568 assert(resolved_klass() == SystemDictionary::MethodHandle_klass() || 1569 resolved_klass() == SystemDictionary::VarHandle_klass(), ""); 1570 assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); 1571 Handle resolved_appendix; 1572 Handle resolved_method_type; 1573 methodHandle resolved_method = lookup_polymorphic_method(link_info, 1574 &resolved_appendix, &resolved_method_type, CHECK); 1575 result.set_handle(resolved_klass, resolved_method, resolved_appendix, resolved_method_type, CHECK); 1576 } 1577 1578 static void wrap_invokedynamic_exception(TRAPS) { 1579 if (HAS_PENDING_EXCEPTION) { 1580 if (TraceMethodHandles) { 1581 tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); 1582 PENDING_EXCEPTION->print(); 1583 } 1584 if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { 1585 // throw these guys, since they are already wrapped 1586 return; 1587 } 1588 if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { 1589 // intercept only LinkageErrors which might have failed to wrap 1590 return; 1591 } 1592 // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. 1593 Handle nested_exception(THREAD, PENDING_EXCEPTION); 1594 CLEAR_PENDING_EXCEPTION; 1595 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) 1596 } 1597 } 1598 1599 void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { 1600 Symbol* method_name = pool->name_ref_at(index); 1601 Symbol* method_signature = pool->signature_ref_at(index); 1602 KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); 1603 1604 // Resolve the bootstrap specifier (BSM + optional arguments). 1605 Handle bootstrap_specifier; 1606 // Check if CallSite has been bound already: 1607 ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); 1608 if (cpce->is_f1_null()) { 1609 int pool_index = cpce->constant_pool_index(); 1610 oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); 1611 wrap_invokedynamic_exception(CHECK); 1612 assert(bsm_info != NULL, ""); 1613 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. 1614 bootstrap_specifier = Handle(THREAD, bsm_info); 1615 } 1616 if (!cpce->is_f1_null()) { 1617 methodHandle method( THREAD, cpce->f1_as_method()); 1618 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); 1619 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); 1620 result.set_handle(method, appendix, method_type, THREAD); 1621 wrap_invokedynamic_exception(CHECK); 1622 return; 1623 } 1624 1625 if (TraceMethodHandles) { 1626 ResourceMark rm(THREAD); 1627 tty->print_cr("resolve_invokedynamic #%d %s %s in %s", 1628 ConstantPool::decode_invokedynamic_index(index), 1629 method_name->as_C_string(), method_signature->as_C_string(), 1630 current_klass->name()->as_C_string()); 1631 tty->print(" BSM info: "); bootstrap_specifier->print(); 1632 } 1633 1634 resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK); 1635 } 1636 1637 void LinkResolver::resolve_dynamic_call(CallInfo& result, 1638 Handle bootstrap_specifier, 1639 Symbol* method_name, Symbol* method_signature, 1640 KlassHandle current_klass, 1641 TRAPS) { 1642 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) 1643 // The appendix argument is likely to be a freshly-created CallSite. 1644 Handle resolved_appendix; 1645 Handle resolved_method_type; 1646 methodHandle resolved_method = 1647 SystemDictionary::find_dynamic_call_site_invoker(current_klass, 1648 bootstrap_specifier, 1649 method_name, method_signature, 1650 &resolved_appendix, 1651 &resolved_method_type, 1652 THREAD); 1653 wrap_invokedynamic_exception(CHECK); 1654 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); 1655 wrap_invokedynamic_exception(CHECK); 1656 }