Path: blob/master/src/hotspot/share/interpreter/linkResolver.cpp
64440 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "jvm.h"26#include "cds/archiveUtils.hpp"27#include "classfile/defaultMethods.hpp"28#include "classfile/javaClasses.hpp"29#include "classfile/resolutionErrors.hpp"30#include "classfile/symbolTable.hpp"31#include "classfile/systemDictionary.hpp"32#include "classfile/vmClasses.hpp"33#include "classfile/vmSymbols.hpp"34#include "compiler/compilationPolicy.hpp"35#include "compiler/compileBroker.hpp"36#include "gc/shared/collectedHeap.inline.hpp"37#include "interpreter/bootstrapInfo.hpp"38#include "interpreter/bytecode.hpp"39#include "interpreter/interpreterRuntime.hpp"40#include "interpreter/linkResolver.hpp"41#include "logging/log.hpp"42#include "logging/logStream.hpp"43#include "memory/resourceArea.hpp"44#include "oops/constantPool.hpp"45#include "oops/cpCache.inline.hpp"46#include "oops/instanceKlass.inline.hpp"47#include "oops/klass.inline.hpp"48#include "oops/method.hpp"49#include "oops/objArrayKlass.hpp"50#include "oops/objArrayOop.hpp"51#include "oops/oop.inline.hpp"52#include "prims/methodHandles.hpp"53#include "runtime/fieldDescriptor.inline.hpp"54#include "runtime/frame.inline.hpp"55#include "runtime/handles.inline.hpp"56#include "runtime/reflection.hpp"57#include "runtime/safepointVerifiers.hpp"58#include "runtime/signature.hpp"59#include "runtime/thread.inline.hpp"60#include "runtime/vmThread.hpp"6162//------------------------------------------------------------------------------------------------------------------------63// Implementation of CallInfo646566void CallInfo::set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS) {67int vtable_index = Method::nonvirtual_vtable_index;68set_common(resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);69}707172void CallInfo::set_interface(Klass* resolved_klass,73const methodHandle& resolved_method,74const methodHandle& selected_method,75int itable_index, TRAPS) {76// This is only called for interface methods. If the resolved_method77// comes from java/lang/Object, it can be the subject of a virtual call, so78// we should pick the vtable index from the resolved method.79// In that case, the caller must call set_virtual instead of set_interface.80assert(resolved_method->method_holder()->is_interface(), "");81assert(itable_index == resolved_method()->itable_index(), "");82set_common(resolved_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK);83}8485void CallInfo::set_virtual(Klass* resolved_klass,86const methodHandle& resolved_method,87const methodHandle& selected_method,88int vtable_index, TRAPS) {89assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index");90assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), "");91CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call);92set_common(resolved_klass, resolved_method, selected_method, kind, vtable_index, CHECK);93assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call");94}9596void CallInfo::set_handle(Klass* resolved_klass,97const methodHandle& resolved_method,98Handle resolved_appendix, TRAPS) {99guarantee(resolved_method.not_null(), "resolved method is null");100assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic ||101resolved_method->is_compiled_lambda_form(),102"linkMethod must return one of these");103int vtable_index = Method::nonvirtual_vtable_index;104assert(!resolved_method->has_vtable_index(), "");105set_common(resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);106_resolved_appendix = resolved_appendix;107}108109void CallInfo::set_common(Klass* resolved_klass,110const methodHandle& resolved_method,111const methodHandle& selected_method,112CallKind kind,113int index,114TRAPS) {115assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond");116_resolved_klass = resolved_klass;117_resolved_method = resolved_method;118_selected_method = selected_method;119_call_kind = kind;120_call_index = index;121_resolved_appendix = Handle();122DEBUG_ONLY(verify()); // verify before making side effects123124CompilationPolicy::compile_if_required(selected_method, THREAD);125}126127// utility query for unreflecting a method128CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS) {129Klass* resolved_method_holder = resolved_method->method_holder();130if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st131resolved_klass = resolved_method_holder;132}133_resolved_klass = resolved_klass;134_resolved_method = methodHandle(THREAD, resolved_method);135_selected_method = methodHandle(THREAD, resolved_method);136// classify:137CallKind kind = CallInfo::unknown_kind;138int index = resolved_method->vtable_index();139if (resolved_method->can_be_statically_bound()) {140kind = CallInfo::direct_call;141} else if (!resolved_method_holder->is_interface()) {142// Could be an Object method inherited into an interface, but still a vtable call.143kind = CallInfo::vtable_call;144} else if (!resolved_klass->is_interface()) {145// A default or miranda method. Compute the vtable index.146index = LinkResolver::vtable_index_of_interface_method(resolved_klass, _resolved_method);147assert(index >= 0 , "we should have valid vtable index at this point");148149kind = CallInfo::vtable_call;150} else if (resolved_method->has_vtable_index()) {151// Can occur if an interface redeclares a method of Object.152153#ifdef ASSERT154// Ensure that this is really the case.155Klass* object_klass = vmClasses::Object_klass();156Method * object_resolved_method = object_klass->vtable().method_at(index);157assert(object_resolved_method->name() == resolved_method->name(),158"Object and interface method names should match at vtable index %d, %s != %s",159index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string());160assert(object_resolved_method->signature() == resolved_method->signature(),161"Object and interface method signatures should match at vtable index %d, %s != %s",162index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string());163#endif // ASSERT164165kind = CallInfo::vtable_call;166} else {167// A regular interface call.168kind = CallInfo::itable_call;169index = resolved_method->itable_index();170}171assert(index == Method::nonvirtual_vtable_index || index >= 0, "bad index %d", index);172_call_kind = kind;173_call_index = index;174_resolved_appendix = Handle();175// Find or create a ResolvedMethod instance for this Method*176set_resolved_method_name(CHECK);177178DEBUG_ONLY(verify());179}180181void CallInfo::set_resolved_method_name(TRAPS) {182assert(_resolved_method() != NULL, "Should already have a Method*");183oop rmethod_name = java_lang_invoke_ResolvedMethodName::find_resolved_method(_resolved_method, CHECK);184_resolved_method_name = Handle(THREAD, rmethod_name);185}186187#ifdef ASSERT188void CallInfo::verify() {189switch (call_kind()) { // the meaning and allowed value of index depends on kind190case CallInfo::direct_call:191if (_call_index == Method::nonvirtual_vtable_index) break;192// else fall through to check vtable index:193case CallInfo::vtable_call:194assert(resolved_klass()->verify_vtable_index(_call_index), "");195break;196case CallInfo::itable_call:197assert(resolved_method()->method_holder()->verify_itable_index(_call_index), "");198break;199case CallInfo::unknown_kind:200assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set");201break;202default:203fatal("Unexpected call kind %d", call_kind());204}205}206#endif // ASSERT207208#ifndef PRODUCT209void CallInfo::print() {210ResourceMark rm;211const char* kindstr;212switch (_call_kind) {213case direct_call: kindstr = "direct"; break;214case vtable_call: kindstr = "vtable"; break;215case itable_call: kindstr = "itable"; break;216default : kindstr = "unknown"; break;217}218tty->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#endif222223//------------------------------------------------------------------------------------------------------------------------224// Implementation of LinkInfo225226LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS) {227// resolve klass228_resolved_klass = pool->klass_ref_at(index, CHECK);229230// Get name, signature, and static klass231_name = pool->name_ref_at(index);232_signature = pool->signature_ref_at(index);233_tag = pool->tag_ref_at(index);234_current_klass = pool->pool_holder();235_current_method = current_method;236237// Coming from the constant pool always checks access238_check_access = true;239_check_loader_constraints = true;240}241242LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {243// resolve klass244_resolved_klass = pool->klass_ref_at(index, CHECK);245246// Get name, signature, and static klass247_name = pool->name_ref_at(index);248_signature = pool->signature_ref_at(index);249_tag = pool->tag_ref_at(index);250_current_klass = pool->pool_holder();251_current_method = methodHandle();252253// Coming from the constant pool always checks access254_check_access = true;255_check_loader_constraints = true;256}257258#ifndef PRODUCT259void LinkInfo::print() {260ResourceMark rm;261tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s check_loader_constraints=%s",262_resolved_klass->name()->as_C_string(),263_name->as_C_string(),264_signature->as_C_string(),265_current_klass == NULL ? "(none)" : _current_klass->name()->as_C_string(),266_check_access ? "true" : "false",267_check_loader_constraints ? "true" : "false");268269}270#endif // PRODUCT271//------------------------------------------------------------------------------------------------------------------------272// Klass resolution273274void LinkResolver::check_klass_accessibility(Klass* ref_klass, Klass* sel_klass, TRAPS) {275Klass* base_klass = sel_klass;276if (sel_klass->is_objArray_klass()) {277base_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();278}279// The element type could be a typeArray - we only need the access280// check if it is a reference to another class.281if (!base_klass->is_instance_klass()) {282return; // no relevant check to do283}284285Reflection::VerifyClassAccessResults vca_result =286Reflection::verify_class_access(ref_klass, InstanceKlass::cast(base_klass), true);287if (vca_result != Reflection::ACCESS_OK) {288ResourceMark rm(THREAD);289char* msg = Reflection::verify_class_access_msg(ref_klass,290InstanceKlass::cast(base_klass),291vca_result);292bool same_module = (base_klass->module() == ref_klass->module());293if (msg == NULL) {294Exceptions::fthrow(295THREAD_AND_LOCATION,296vmSymbols::java_lang_IllegalAccessError(),297"failed to access class %s from class %s (%s%s%s)",298base_klass->external_name(),299ref_klass->external_name(),300(same_module) ? base_klass->joint_in_module_of_loader(ref_klass) : base_klass->class_in_module_of_loader(),301(same_module) ? "" : "; ",302(same_module) ? "" : ref_klass->class_in_module_of_loader());303} else {304// Use module specific message returned by verify_class_access_msg().305Exceptions::fthrow(306THREAD_AND_LOCATION,307vmSymbols::java_lang_IllegalAccessError(),308"%s", msg);309}310}311}312313//------------------------------------------------------------------------------------------------------------------------314// Method resolution315//316// According to JVM spec. $5.4.3c & $5.4.3d317318// Look up method in klasses, including static methods319// Then look up local default methods320Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,321bool checkpolymorphism,322bool in_imethod_resolve) {323NoSafepointVerifier nsv; // Method* returned may not be reclaimed324325Klass* klass = link_info.resolved_klass();326Symbol* name = link_info.name();327Symbol* signature = link_info.signature();328329// Ignore overpasses so statics can be found during resolution330Method* result = klass->uncached_lookup_method(name, signature, Klass::OverpassLookupMode::skip);331332if (klass->is_array_klass()) {333// Only consider klass and super klass for arrays334return result;335}336337InstanceKlass* ik = InstanceKlass::cast(klass);338339// JDK 8, JVMS 5.4.3.4: Interface method resolution should340// ignore static and non-public methods of java.lang.Object,341// like clone and finalize.342if (in_imethod_resolve &&343result != NULL &&344ik->is_interface() &&345(result->is_static() || !result->is_public()) &&346result->method_holder() == vmClasses::Object_klass()) {347result = NULL;348}349350// Before considering default methods, check for an overpass in the351// current class if a method has not been found.352if (result == NULL) {353result = ik->find_method(name, signature);354}355356if (result == NULL) {357Array<Method*>* default_methods = ik->default_methods();358if (default_methods != NULL) {359result = InstanceKlass::find_method(default_methods, name, signature);360}361}362363if (checkpolymorphism && result != NULL) {364vmIntrinsics::ID iid = result->intrinsic_id();365if (MethodHandles::is_signature_polymorphic(iid)) {366// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method.367return NULL;368}369}370return result;371}372373// returns first instance method374// Looks up method in classes, then looks up local default methods375Method* LinkResolver::lookup_instance_method_in_klasses(Klass* klass,376Symbol* name,377Symbol* signature,378Klass::PrivateLookupMode private_mode) {379Method* result = klass->uncached_lookup_method(name, signature, Klass::OverpassLookupMode::find, private_mode);380381while (result != NULL && result->is_static() && result->method_holder()->super() != NULL) {382Klass* super_klass = result->method_holder()->super();383result = super_klass->uncached_lookup_method(name, signature, Klass::OverpassLookupMode::find, private_mode);384}385386if (klass->is_array_klass()) {387// Only consider klass and super klass for arrays388return result;389}390391if (result == NULL) {392Array<Method*>* default_methods = InstanceKlass::cast(klass)->default_methods();393if (default_methods != NULL) {394result = InstanceKlass::find_method(default_methods, name, signature);395assert(result == NULL || !result->is_static(), "static defaults not allowed");396}397}398return result;399}400401int LinkResolver::vtable_index_of_interface_method(Klass* klass, const methodHandle& resolved_method) {402InstanceKlass* ik = InstanceKlass::cast(klass);403return ik->vtable_index_of_interface_method(resolved_method());404}405406Method* LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info) {407InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass());408409// Specify 'true' in order to skip default methods when searching the410// interfaces. Function lookup_method_in_klasses() already looked for411// the method in the default methods table.412return ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), Klass::DefaultsLookupMode::skip);413}414415Method* LinkResolver::lookup_polymorphic_method(const LinkInfo& link_info,416Handle *appendix_result_or_null,417TRAPS) {418ResourceMark rm(THREAD);419Klass* klass = link_info.resolved_klass();420Symbol* name = link_info.name();421Symbol* full_signature = link_info.signature();422LogTarget(Info, methodhandles) lt_mh;423424vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name);425log_info(methodhandles)("lookup_polymorphic_method iid=%s %s.%s%s",426vmIntrinsics::name_at(iid), klass->external_name(),427name->as_C_string(), full_signature->as_C_string());428if ((klass == vmClasses::MethodHandle_klass() ||429klass == vmClasses::VarHandle_klass()) &&430iid != vmIntrinsics::_none) {431if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) {432// Most of these do not need an up-call to Java to resolve, so can be done anywhere.433// Do not erase last argument type (MemberName) if it is a static linkTo method.434bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid);435TempNewSymbol basic_signature =436MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg);437log_info(methodhandles)("lookup_polymorphic_method %s %s => basic %s",438name->as_C_string(),439full_signature->as_C_string(),440basic_signature->as_C_string());441Method* result = SystemDictionary::find_method_handle_intrinsic(iid,442basic_signature,443CHECK_NULL);444if (result != NULL) {445assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic");446assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this");447assert(basic_signature == result->signature(), "predict the result signature");448if (lt_mh.is_enabled()) {449LogStream ls(lt_mh);450ls.print("lookup_polymorphic_method => intrinsic ");451result->print_on(&ls);452}453}454return result;455} else if (iid == vmIntrinsics::_invokeGeneric456&& THREAD->can_call_java()457&& appendix_result_or_null != NULL) {458// This is a method with type-checking semantics.459// We will ask Java code to spin an adapter method for it.460if (!MethodHandles::enabled()) {461// Make sure the Java part of the runtime has been booted up.462Klass* natives = vmClasses::MethodHandleNatives_klass();463if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) {464SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(),465Handle(),466Handle(),467true,468CHECK_NULL);469}470}471472Handle appendix;473Method* result = SystemDictionary::find_method_handle_invoker(klass,474name,475full_signature,476link_info.current_klass(),477&appendix,478CHECK_NULL);479if (lt_mh.is_enabled()) {480LogStream ls(lt_mh);481ls.print("lookup_polymorphic_method => (via Java) ");482result->print_on(&ls);483ls.print(" lookup_polymorphic_method => appendix = ");484appendix.is_null() ? ls.print_cr("(none)") : appendix->print_on(&ls);485}486if (result != NULL) {487#ifdef ASSERT488ResourceMark rm(THREAD);489490TempNewSymbol basic_signature =491MethodHandles::lookup_basic_type_signature(full_signature);492int actual_size_of_params = result->size_of_parameters();493int expected_size_of_params = ArgumentSizeComputer(basic_signature).size();494// +1 for MethodHandle.this, +1 for trailing MethodType495if (!MethodHandles::is_signature_polymorphic_static(iid)) expected_size_of_params += 1;496if (appendix.not_null()) expected_size_of_params += 1;497if (actual_size_of_params != expected_size_of_params) {498tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string());499tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid));500result->print();501}502assert(actual_size_of_params == expected_size_of_params,503"%d != %d", actual_size_of_params, expected_size_of_params);504#endif //ASSERT505506assert(appendix_result_or_null != NULL, "");507(*appendix_result_or_null) = appendix;508}509return result;510}511}512return NULL;513}514515static void print_nest_host_error_on(stringStream* ss, Klass* ref_klass, Klass* sel_klass) {516assert(ref_klass->is_instance_klass(), "must be");517assert(sel_klass->is_instance_klass(), "must be");518InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);519InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);520const char* nest_host_error_1 = ref_ik->nest_host_error();521const char* nest_host_error_2 = sel_ik->nest_host_error();522if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {523ss->print(", (%s%s%s)",524(nest_host_error_1 != NULL) ? nest_host_error_1 : "",525(nest_host_error_1 != NULL && nest_host_error_2 != NULL) ? ", " : "",526(nest_host_error_2 != NULL) ? nest_host_error_2 : "");527}528}529530void LinkResolver::check_method_accessability(Klass* ref_klass,531Klass* resolved_klass,532Klass* sel_klass,533const methodHandle& sel_method,534TRAPS) {535536AccessFlags flags = sel_method->access_flags();537538// Special case: arrays always override "clone". JVMS 2.15.539// If the resolved klass is an array class, and the declaring class540// is java.lang.Object and the method is "clone", set the flags541// to public.542//543// We'll check for the method name first, as that's most likely544// to be false (so we'll short-circuit out of these tests).545if (sel_method->name() == vmSymbols::clone_name() &&546sel_klass == vmClasses::Object_klass() &&547resolved_klass->is_array_klass()) {548// We need to change "protected" to "public".549assert(flags.is_protected(), "clone not protected?");550jint new_flags = flags.as_int();551new_flags = new_flags & (~JVM_ACC_PROTECTED);552new_flags = new_flags | JVM_ACC_PUBLIC;553flags.set_flags(new_flags);554}555// assert(extra_arg_result_or_null != NULL, "must be able to return extra argument");556557bool can_access = Reflection::verify_member_access(ref_klass,558resolved_klass,559sel_klass,560flags,561true, false, CHECK);562// Any existing exceptions that may have been thrown563// have been allowed to propagate.564if (!can_access) {565ResourceMark rm(THREAD);566stringStream ss;567bool same_module = (sel_klass->module() == ref_klass->module());568ss.print("class %s tried to access %s%s%smethod '%s' (%s%s%s)",569ref_klass->external_name(),570sel_method->is_abstract() ? "abstract " : "",571sel_method->is_protected() ? "protected " : "",572sel_method->is_private() ? "private " : "",573sel_method->external_name(),574(same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),575(same_module) ? "" : "; ",576(same_module) ? "" : sel_klass->class_in_module_of_loader()577);578579// For private access see if there was a problem with nest host580// resolution, and if so report that as part of the message.581if (sel_method->is_private()) {582print_nest_host_error_on(&ss, ref_klass, sel_klass);583}584585Exceptions::fthrow(THREAD_AND_LOCATION,586vmSymbols::java_lang_IllegalAccessError(),587"%s",588ss.as_string()589);590return;591}592}593594Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,595const constantPoolHandle& pool, int index, TRAPS) {596// This method is used only597// (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),598// and599// (2) in Bytecode_invoke::static_target600// It appears to fail when applied to an invokeinterface call site.601// FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.602// resolve klass603if (code == Bytecodes::_invokedynamic) {604Klass* resolved_klass = vmClasses::MethodHandle_klass();605Symbol* method_name = vmSymbols::invoke_name();606Symbol* method_signature = pool->signature_ref_at(index);607Klass* current_klass = pool->pool_holder();608LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);609return resolve_method(link_info, code, THREAD);610}611612LinkInfo link_info(pool, index, methodHandle(), CHECK_NULL);613Klass* resolved_klass = link_info.resolved_klass();614615if (pool->has_preresolution()616|| ((resolved_klass == vmClasses::MethodHandle_klass() || resolved_klass == vmClasses::VarHandle_klass()) &&617MethodHandles::is_signature_polymorphic_name(resolved_klass, link_info.name()))) {618Method* result = ConstantPool::method_at_if_loaded(pool, index);619if (result != NULL) {620return result;621}622}623624if (code == Bytecodes::_invokeinterface) {625return resolve_interface_method(link_info, code, THREAD);626} else if (code == Bytecodes::_invokevirtual) {627return resolve_method(link_info, code, THREAD);628} else if (!resolved_klass->is_interface()) {629return resolve_method(link_info, code, THREAD);630} else {631return resolve_interface_method(link_info, code, THREAD);632}633}634635// Check and print a loader constraint violation message for method or interface method636void LinkResolver::check_method_loader_constraints(const LinkInfo& link_info,637const methodHandle& resolved_method,638const char* method_type, TRAPS) {639Handle current_loader(THREAD, link_info.current_klass()->class_loader());640Handle resolved_loader(THREAD, resolved_method->method_holder()->class_loader());641642ResourceMark rm(THREAD);643Symbol* failed_type_symbol =644SystemDictionary::check_signature_loaders(link_info.signature(),645/*klass_being_linked*/ NULL, // We are not linking class646current_loader,647resolved_loader, true);648if (failed_type_symbol != NULL) {649Klass* current_class = link_info.current_klass();650ClassLoaderData* current_loader_data = current_class->class_loader_data();651assert(current_loader_data != NULL, "current class has no class loader data");652Klass* resolved_method_class = resolved_method->method_holder();653ClassLoaderData* target_loader_data = resolved_method_class->class_loader_data();654assert(target_loader_data != NULL, "resolved method's class has no class loader data");655656stringStream ss;657ss.print("loader constraint violation: when resolving %s '", method_type);658Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());659ss.print("' the class loader %s of the current class, %s,"660" and the class loader %s for the method's defining class, %s, have"661" different Class objects for the type %s used in the signature (%s; %s)",662current_loader_data->loader_name_and_id(),663current_class->name()->as_C_string(),664target_loader_data->loader_name_and_id(),665resolved_method_class->name()->as_C_string(),666failed_type_symbol->as_C_string(),667current_class->class_in_module_of_loader(false, true),668resolved_method_class->class_in_module_of_loader(false, true));669THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());670}671}672673void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig,674Klass* current_klass,675Klass* sel_klass, TRAPS) {676Handle ref_loader(THREAD, current_klass->class_loader());677Handle sel_loader(THREAD, sel_klass->class_loader());678679ResourceMark rm(THREAD); // needed for check_signature_loaders680Symbol* failed_type_symbol =681SystemDictionary::check_signature_loaders(sig,682/*klass_being_linked*/ NULL, // We are not linking class683ref_loader, sel_loader,684false);685if (failed_type_symbol != NULL) {686stringStream ss;687const char* failed_type_name = failed_type_symbol->as_klass_external_name();688689ss.print("loader constraint violation: when resolving field \"%s\" of type %s, "690"the class loader %s of the current class, %s, "691"and the class loader %s for the field's defining %s, %s, "692"have different Class objects for type %s (%s; %s)",693field->as_C_string(),694failed_type_name,695current_klass->class_loader_data()->loader_name_and_id(),696current_klass->external_name(),697sel_klass->class_loader_data()->loader_name_and_id(),698sel_klass->external_kind(),699sel_klass->external_name(),700failed_type_name,701current_klass->class_in_module_of_loader(false, true),702sel_klass->class_in_module_of_loader(false, true));703THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());704}705}706707Method* LinkResolver::resolve_method(const LinkInfo& link_info,708Bytecodes::Code code, TRAPS) {709710Handle nested_exception;711Klass* resolved_klass = link_info.resolved_klass();712713// 1. For invokevirtual, cannot call an interface method714if (code == Bytecodes::_invokevirtual && resolved_klass->is_interface()) {715ResourceMark rm(THREAD);716char buf[200];717jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected",718resolved_klass->external_name());719THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);720}721722// 2. check constant pool tag for called method - must be JVM_CONSTANT_Methodref723if (!link_info.tag().is_invalid() && !link_info.tag().is_method()) {724ResourceMark rm(THREAD);725stringStream ss;726ss.print("Method '");727Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());728ss.print("' must be Methodref constant");729THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());730}731732// 3. lookup method in resolved klass and its super klasses733methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, true, false));734735// 4. lookup method in all the interfaces implemented by the resolved klass736if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy737resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));738739if (resolved_method.is_null()) {740// JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc741Method* method = lookup_polymorphic_method(link_info, (Handle*)NULL, THREAD);742resolved_method = methodHandle(THREAD, method);743if (HAS_PENDING_EXCEPTION) {744nested_exception = Handle(THREAD, PENDING_EXCEPTION);745CLEAR_PENDING_EXCEPTION;746}747}748}749750// 5. method lookup failed751if (resolved_method.is_null()) {752ResourceMark rm(THREAD);753stringStream ss;754ss.print("'");755Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());756ss.print("'");757THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(),758ss.as_string(), nested_exception, NULL);759}760761// 6. access checks, access checking may be turned off when calling from within the VM.762Klass* current_klass = link_info.current_klass();763if (link_info.check_access()) {764assert(current_klass != NULL , "current_klass should not be null");765766// check if method can be accessed by the referring class767check_method_accessability(current_klass,768resolved_klass,769resolved_method->method_holder(),770resolved_method,771CHECK_NULL);772}773if (link_info.check_loader_constraints()) {774// check loader constraints775check_method_loader_constraints(link_info, resolved_method, "method", CHECK_NULL);776}777778return resolved_method();779}780781static void trace_method_resolution(const char* prefix,782Klass* klass,783Klass* resolved_klass,784Method* method,785bool logitables,786int index = -1) {787#ifndef PRODUCT788ResourceMark rm;789Log(itables) logi;790LogStream lsi(logi.trace());791Log(vtables) logv;792LogStream lsv(logv.trace());793outputStream* st;794if (logitables) {795st = &lsi;796} else {797st = &lsv;798}799st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",800prefix,801(klass == NULL ? "<NULL>" : klass->internal_name()),802(resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()),803Method::name_and_sig_as_C_string(resolved_klass,804method->name(),805method->signature()),806method->method_holder()->internal_name());807method->print_linkage_flags(st);808if (index != -1) {809st->print("vtable_index:%d", index);810}811st->cr();812#endif // PRODUCT813}814815// Do linktime resolution of a method in the interface within the context of the specied bytecode.816Method* LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) {817818Klass* resolved_klass = link_info.resolved_klass();819820// check if klass is interface821if (!resolved_klass->is_interface()) {822ResourceMark rm(THREAD);823char buf[200];824jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass->external_name());825THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);826}827828// check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref829if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {830ResourceMark rm(THREAD);831stringStream ss;832ss.print("Method '");833Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());834ss.print("' must be InterfaceMethodref constant");835THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());836}837838// lookup method in this interface or its super, java.lang.Object839// JDK8: also look for static methods840methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true));841842if (resolved_method.is_null() && !resolved_klass->is_array_klass()) {843// lookup method in all the super-interfaces844resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));845}846847if (resolved_method.is_null()) {848// no method found849ResourceMark rm(THREAD);850stringStream ss;851ss.print("'");852Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());853ss.print("'");854THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), ss.as_string());855}856857if (link_info.check_access()) {858// JDK8 adds non-public interface methods, and accessability check requirement859Klass* current_klass = link_info.current_klass();860861assert(current_klass != NULL , "current_klass should not be null");862863// check if method can be accessed by the referring class864check_method_accessability(current_klass,865resolved_klass,866resolved_method->method_holder(),867resolved_method,868CHECK_NULL);869}870if (link_info.check_loader_constraints()) {871check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL);872}873874if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {875ResourceMark rm(THREAD);876stringStream ss;877ss.print("Expected instance not static method '");878Method::print_external_name(&ss, resolved_klass,879resolved_method->name(), resolved_method->signature());880ss.print("'");881THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());882}883884if (log_develop_is_enabled(Trace, itables)) {885char buf[200];886jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:",887Bytecodes::name(code));888trace_method_resolution(buf, link_info.current_klass(), resolved_klass, resolved_method(), true);889}890891return resolved_method();892}893894//------------------------------------------------------------------------------------------------------------------------895// Field resolution896897void LinkResolver::check_field_accessability(Klass* ref_klass,898Klass* resolved_klass,899Klass* sel_klass,900const fieldDescriptor& fd,901TRAPS) {902bool can_access = Reflection::verify_member_access(ref_klass,903resolved_klass,904sel_klass,905fd.access_flags(),906true, false, CHECK);907// Any existing exceptions that may have been thrown, for example LinkageErrors908// from nest-host resolution, have been allowed to propagate.909if (!can_access) {910bool same_module = (sel_klass->module() == ref_klass->module());911ResourceMark rm(THREAD);912stringStream ss;913ss.print("class %s tried to access %s%sfield %s.%s (%s%s%s)",914ref_klass->external_name(),915fd.is_protected() ? "protected " : "",916fd.is_private() ? "private " : "",917sel_klass->external_name(),918fd.name()->as_C_string(),919(same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),920(same_module) ? "" : "; ",921(same_module) ? "" : sel_klass->class_in_module_of_loader()922);923// For private access see if there was a problem with nest host924// resolution, and if so report that as part of the message.925if (fd.is_private()) {926print_nest_host_error_on(&ss, ref_klass, sel_klass);927}928Exceptions::fthrow(THREAD_AND_LOCATION,929vmSymbols::java_lang_IllegalAccessError(),930"%s",931ss.as_string()932);933return;934}935}936937void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {938LinkInfo link_info(pool, index, method, CHECK);939resolve_field(fd, link_info, byte, true, CHECK);940}941942void LinkResolver::resolve_field(fieldDescriptor& fd,943const LinkInfo& link_info,944Bytecodes::Code byte, bool initialize_class,945TRAPS) {946assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic ||947byte == Bytecodes::_getfield || byte == Bytecodes::_putfield ||948byte == Bytecodes::_nofast_getfield || byte == Bytecodes::_nofast_putfield ||949(byte == Bytecodes::_nop && !link_info.check_access()), "bad field access bytecode");950951bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic);952bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield);953// Check if there's a resolved klass containing the field954Klass* resolved_klass = link_info.resolved_klass();955Symbol* field = link_info.name();956Symbol* sig = link_info.signature();957958if (resolved_klass == NULL) {959ResourceMark rm(THREAD);960THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());961}962963// Resolve instance field964Klass* sel_klass = resolved_klass->find_field(field, sig, &fd);965// check if field exists; i.e., if a klass containing the field def has been selected966if (sel_klass == NULL) {967ResourceMark rm(THREAD);968THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());969}970971// Access checking may be turned off when calling from within the VM.972Klass* current_klass = link_info.current_klass();973if (link_info.check_access()) {974975// check access976check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);977978// check for errors979if (is_static != fd.is_static()) {980ResourceMark rm(THREAD);981char msg[200];982jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string());983THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);984}985986// A final field can be modified only987// (1) by methods declared in the class declaring the field and988// (2) by the <clinit> method (in case of a static field)989// or by the <init> method (in case of an instance field).990if (is_put && fd.access_flags().is_final()) {991992if (sel_klass != current_klass) {993ResourceMark rm(THREAD);994stringStream ss;995ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class",996is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(),997current_klass->external_name());998THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());999}10001001if (fd.constants()->pool_holder()->major_version() >= 53) {1002Method* m = link_info.current_method();1003assert(m != NULL, "information about the current method must be available for 'put' bytecodes");1004bool is_initialized_static_final_update = (byte == Bytecodes::_putstatic &&1005fd.is_static() &&1006!m->is_static_initializer());1007bool is_initialized_instance_final_update = ((byte == Bytecodes::_putfield || byte == Bytecodes::_nofast_putfield) &&1008!fd.is_static() &&1009!m->is_object_initializer());10101011if (is_initialized_static_final_update || is_initialized_instance_final_update) {1012ResourceMark rm(THREAD);1013stringStream ss;1014ss.print("Update to %s final field %s.%s attempted from a different method (%s) than the initializer method %s ",1015is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(),1016m->name()->as_C_string(),1017is_static ? "<clinit>" : "<init>");1018THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());1019}1020}1021}10221023// initialize resolved_klass if necessary1024// note 1: the klass which declared the field must be initialized (i.e, sel_klass)1025// according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)1026//1027// note 2: we don't want to force initialization if we are just checking1028// if the field access is legal; e.g., during compilation1029if (is_static && initialize_class) {1030sel_klass->initialize(CHECK);1031}1032}10331034if (link_info.check_loader_constraints() && (sel_klass != current_klass) && (current_klass != NULL)) {1035check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK);1036}10371038// return information. note that the klass is set to the actual klass containing the1039// field, otherwise access of static fields in superclasses will not work.1040}104110421043//------------------------------------------------------------------------------------------------------------------------1044// Invoke resolution1045//1046// Naming conventions:1047//1048// resolved_method the specified method (i.e., static receiver specified via constant pool index)1049// sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class)1050// resolved_klass the specified klass (i.e., specified via constant pool index)1051// recv_klass the receiver klass105210531054void LinkResolver::resolve_static_call(CallInfo& result,1055const LinkInfo& link_info,1056bool initialize_class, TRAPS) {1057Method* resolved_method = linktime_resolve_static_method(link_info, CHECK);10581059// The resolved class can change as a result of this resolution.1060Klass* resolved_klass = resolved_method->method_holder();10611062// Initialize klass (this should only happen if everything is ok)1063if (initialize_class && resolved_klass->should_be_initialized()) {1064resolved_klass->initialize(CHECK);1065// Use updated LinkInfo to reresolve with resolved method holder1066LinkInfo new_info(resolved_klass, link_info.name(), link_info.signature(),1067link_info.current_klass(),1068link_info.check_access() ? LinkInfo::AccessCheck::required : LinkInfo::AccessCheck::skip,1069link_info.check_loader_constraints() ? LinkInfo::LoaderConstraintCheck::required : LinkInfo::LoaderConstraintCheck::skip);1070resolved_method = linktime_resolve_static_method(new_info, CHECK);1071}10721073// setup result1074result.set_static(resolved_klass, methodHandle(THREAD, resolved_method), CHECK);1075}10761077// throws linktime exceptions1078Method* LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) {10791080Klass* resolved_klass = link_info.resolved_klass();1081Method* resolved_method;1082if (!resolved_klass->is_interface()) {1083resolved_method = resolve_method(link_info, Bytecodes::_invokestatic, CHECK_NULL);1084} else {1085resolved_method = resolve_interface_method(link_info, Bytecodes::_invokestatic, CHECK_NULL);1086}1087assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier");10881089// check if static1090if (!resolved_method->is_static()) {1091ResourceMark rm(THREAD);1092stringStream ss;1093ss.print("Expected static method '");1094resolved_method->print_external_name(&ss);1095ss.print("'");1096THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());1097}1098return resolved_method;1099}110011011102void LinkResolver::resolve_special_call(CallInfo& result,1103Handle recv,1104const LinkInfo& link_info,1105TRAPS) {1106Method* resolved_method = linktime_resolve_special_method(link_info, CHECK);1107runtime_resolve_special_method(result, link_info, methodHandle(THREAD, resolved_method), recv, CHECK);1108}11091110// throws linktime exceptions1111Method* LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, TRAPS) {11121113// Invokespecial is called for multiple special reasons:1114// <init>1115// local private method invocation, for classes and interfaces1116// superclass.method, which can also resolve to a default method1117// and the selected method is recalculated relative to the direct superclass1118// superinterface.method, which explicitly does not check shadowing1119Klass* resolved_klass = link_info.resolved_klass();1120Method* resolved_method = NULL;11211122if (!resolved_klass->is_interface()) {1123resolved_method = resolve_method(link_info, Bytecodes::_invokespecial, CHECK_NULL);1124} else {1125resolved_method = resolve_interface_method(link_info, Bytecodes::_invokespecial, CHECK_NULL);1126}11271128// check if method name is <init>, that it is found in same klass as static type1129if (resolved_method->name() == vmSymbols::object_initializer_name() &&1130resolved_method->method_holder() != resolved_klass) {1131ResourceMark rm(THREAD);1132stringStream ss;1133ss.print("%s: method '", resolved_klass->external_name());1134resolved_method->signature()->print_as_signature_external_return_type(&ss);1135ss.print(" %s(", resolved_method->name()->as_C_string());1136resolved_method->signature()->print_as_signature_external_parameters(&ss);1137ss.print(")' not found");1138Exceptions::fthrow(1139THREAD_AND_LOCATION,1140vmSymbols::java_lang_NoSuchMethodError(),1141"%s", ss.as_string());1142return NULL;1143}11441145// ensure that invokespecial's interface method reference is in1146// a direct superinterface, not an indirect superinterface1147Klass* current_klass = link_info.current_klass();1148if (current_klass != NULL && resolved_klass->is_interface()) {1149InstanceKlass* klass_to_check = InstanceKlass::cast(current_klass);1150// Disable verification for the dynamically-generated reflection bytecodes.1151bool is_reflect = klass_to_check->is_subclass_of(1152vmClasses::reflect_MagicAccessorImpl_klass());11531154if (!is_reflect &&1155!klass_to_check->is_same_or_direct_interface(resolved_klass)) {1156ResourceMark rm(THREAD);1157stringStream ss;1158ss.print("Interface method reference: '");1159resolved_method->print_external_name(&ss);1160ss.print("', is in an indirect superinterface of %s",1161current_klass->external_name());1162THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());1163}1164}11651166// check if not static1167if (resolved_method->is_static()) {1168ResourceMark rm(THREAD);1169stringStream ss;1170ss.print("Expecting non-static method '");1171resolved_method->print_external_name(&ss);1172ss.print("'");1173THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());1174}11751176if (log_develop_is_enabled(Trace, itables)) {1177trace_method_resolution("invokespecial resolved method: caller-class:",1178current_klass, resolved_klass, resolved_method, true);1179}11801181return resolved_method;1182}11831184// throws runtime exceptions1185void LinkResolver::runtime_resolve_special_method(CallInfo& result,1186const LinkInfo& link_info,1187const methodHandle& resolved_method,1188Handle recv, TRAPS) {11891190Klass* resolved_klass = link_info.resolved_klass();11911192// resolved method is selected method unless we have an old-style lookup1193// for a superclass method1194// Invokespecial for a superinterface, resolved method is selected method,1195// no checks for shadowing1196methodHandle sel_method(THREAD, resolved_method());11971198if (link_info.check_access() &&1199// check if the method is not <init>1200resolved_method->name() != vmSymbols::object_initializer_name()) {12011202Klass* current_klass = link_info.current_klass();12031204// Check if the class of the resolved_klass is a superclass1205// (not supertype in order to exclude interface classes) of the current class.1206// This check is not performed for super.invoke for interface methods1207// in super interfaces.1208if (current_klass->is_subclass_of(resolved_klass) &&1209current_klass != resolved_klass) {1210// Lookup super method1211Klass* super_klass = current_klass->super();1212Method* instance_method = lookup_instance_method_in_klasses(super_klass,1213resolved_method->name(),1214resolved_method->signature(),1215Klass::PrivateLookupMode::find);1216sel_method = methodHandle(THREAD, instance_method);12171218// check if found1219if (sel_method.is_null()) {1220ResourceMark rm(THREAD);1221stringStream ss;1222ss.print("'");1223resolved_method->print_external_name(&ss);1224ss.print("'");1225THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());1226// check loader constraints if found a different method1227} else if (link_info.check_loader_constraints() && sel_method() != resolved_method()) {1228check_method_loader_constraints(link_info, sel_method, "method", CHECK);1229}1230}12311232// Check that the class of objectref (the receiver) is the current class or interface,1233// or a subtype of the current class or interface (the sender), otherwise invokespecial1234// throws IllegalAccessError.1235// The verifier checks that the sender is a subtype of the class in the I/MR operand.1236// The verifier also checks that the receiver is a subtype of the sender, if the sender is1237// a class. If the sender is an interface, the check has to be performed at runtime.1238InstanceKlass* sender = InstanceKlass::cast(current_klass);1239if (sender->is_interface() && recv.not_null()) {1240Klass* receiver_klass = recv->klass();1241if (!receiver_klass->is_subtype_of(sender)) {1242ResourceMark rm(THREAD);1243char buf[500];1244jio_snprintf(buf, sizeof(buf),1245"Receiver class %s must be the current class or a subtype of interface %s",1246receiver_klass->external_name(),1247sender->external_name());1248THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);1249}1250}1251}12521253// check if not static1254if (sel_method->is_static()) {1255ResourceMark rm(THREAD);1256stringStream ss;1257ss.print("Expecting non-static method '");1258resolved_method->print_external_name(&ss);1259ss.print("'");1260THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());1261}12621263// check if abstract1264if (sel_method->is_abstract()) {1265ResourceMark rm(THREAD);1266stringStream ss;1267ss.print("'");1268Method::print_external_name(&ss, resolved_klass, sel_method->name(), sel_method->signature());1269ss.print("'");1270THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());1271}12721273if (log_develop_is_enabled(Trace, itables)) {1274trace_method_resolution("invokespecial selected method: resolved-class:",1275resolved_klass, resolved_klass, sel_method(), true);1276}12771278// setup result1279result.set_static(resolved_klass, sel_method, CHECK);1280}12811282void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, Klass* receiver_klass,1283const LinkInfo& link_info,1284bool check_null_and_abstract, TRAPS) {1285Method* resolved_method = linktime_resolve_virtual_method(link_info, CHECK);1286runtime_resolve_virtual_method(result, methodHandle(THREAD, resolved_method),1287link_info.resolved_klass(),1288recv, receiver_klass,1289check_null_and_abstract, CHECK);1290}12911292// throws linktime exceptions1293Method* LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_info,1294TRAPS) {1295// normal method resolution1296Method* resolved_method = resolve_method(link_info, Bytecodes::_invokevirtual, CHECK_NULL);12971298assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");1299assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");13001301// check if private interface method1302Klass* resolved_klass = link_info.resolved_klass();1303Klass* current_klass = link_info.current_klass();13041305// This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method1306if (resolved_klass->is_interface() && resolved_method->is_private()) {1307ResourceMark rm(THREAD);1308stringStream ss;1309ss.print("private interface method requires invokespecial, not invokevirtual: method '");1310resolved_method->print_external_name(&ss);1311ss.print("', caller-class: %s",1312(current_klass == NULL ? "<null>" : current_klass->internal_name()));1313THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());1314}13151316// check if not static1317if (resolved_method->is_static()) {1318ResourceMark rm(THREAD);1319stringStream ss;1320ss.print("Expecting non-static method '");1321resolved_method->print_external_name(&ss);1322ss.print("'");1323THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());1324}13251326if (log_develop_is_enabled(Trace, vtables)) {1327trace_method_resolution("invokevirtual resolved method: caller-class:",1328current_klass, resolved_klass, resolved_method, false);1329}13301331return resolved_method;1332}13331334// throws runtime exceptions1335void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,1336const methodHandle& resolved_method,1337Klass* resolved_klass,1338Handle recv,1339Klass* recv_klass,1340bool check_null_and_abstract,1341TRAPS) {13421343// setup default return values1344int vtable_index = Method::invalid_vtable_index;1345methodHandle selected_method;13461347// runtime method resolution1348if (check_null_and_abstract && recv.is_null()) { // check if receiver exists1349THROW(vmSymbols::java_lang_NullPointerException());1350}13511352// Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s1353// has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since1354// a missing receiver might result in a bogus lookup.1355assert(resolved_method->method_holder()->is_linked(), "must be linked");13561357// do lookup based on receiver klass using the vtable index1358if (resolved_method->method_holder()->is_interface()) { // default or miranda method1359vtable_index = vtable_index_of_interface_method(resolved_klass, resolved_method);1360assert(vtable_index >= 0 , "we should have valid vtable index at this point");13611362selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));1363} else {1364// at this point we are sure that resolved_method is virtual and not1365// a default or miranda method; therefore, it must have a valid vtable index.1366assert(!resolved_method->has_itable_index(), "");1367vtable_index = resolved_method->vtable_index();1368// We could get a negative vtable_index of nonvirtual_vtable_index for private1369// methods, or for final methods. Private methods never appear in the vtable1370// and never override other methods. As an optimization, final methods are1371// never put in the vtable, unless they override an existing method.1372// So if we do get nonvirtual_vtable_index, it means the selected method is the1373// resolved method, and it can never be changed by an override.1374if (vtable_index == Method::nonvirtual_vtable_index) {1375assert(resolved_method->can_be_statically_bound(), "cannot override this method");1376selected_method = resolved_method;1377} else {1378selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));1379}1380}13811382// check if method exists1383if (selected_method.is_null()) {1384throw_abstract_method_error(resolved_method, recv_klass, CHECK);1385}13861387// check if abstract1388if (check_null_and_abstract && selected_method->is_abstract()) {1389// Pass arguments for generating a verbose error message.1390throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK);1391}13921393if (log_develop_is_enabled(Trace, vtables)) {1394trace_method_resolution("invokevirtual selected method: receiver-class:",1395recv_klass, resolved_klass, selected_method(),1396false, vtable_index);1397}1398// setup result1399result.set_virtual(resolved_klass, resolved_method, selected_method, vtable_index, CHECK);1400}14011402void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass,1403const LinkInfo& link_info,1404bool check_null_and_abstract, TRAPS) {1405// throws linktime exceptions1406Method* resolved_method = linktime_resolve_interface_method(link_info, CHECK);1407methodHandle mh(THREAD, resolved_method);1408runtime_resolve_interface_method(result, mh, link_info.resolved_klass(),1409recv, recv_klass, check_null_and_abstract, CHECK);1410}14111412Method* LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info,1413TRAPS) {1414// normal interface method resolution1415Method* resolved_method = resolve_interface_method(link_info, Bytecodes::_invokeinterface, CHECK_NULL);1416assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");1417assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");14181419return resolved_method;1420}14211422// throws runtime exceptions1423void LinkResolver::runtime_resolve_interface_method(CallInfo& result,1424const methodHandle& resolved_method,1425Klass* resolved_klass,1426Handle recv,1427Klass* recv_klass,1428bool check_null_and_abstract, TRAPS) {14291430// check if receiver exists1431if (check_null_and_abstract && recv.is_null()) {1432THROW(vmSymbols::java_lang_NullPointerException());1433}14341435// check if receiver klass implements the resolved interface1436if (!recv_klass->is_subtype_of(resolved_klass)) {1437ResourceMark rm(THREAD);1438char buf[200];1439jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",1440recv_klass->external_name(),1441resolved_klass->external_name());1442THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);1443}14441445methodHandle selected_method = resolved_method;14461447// resolve the method in the receiver class, unless it is private1448if (!resolved_method()->is_private()) {1449// do lookup based on receiver klass1450// This search must match the linktime preparation search for itable initialization1451// to correctly enforce loader constraints for interface method inheritance.1452// Private methods are skipped as the resolved method was not private.1453Method* method = lookup_instance_method_in_klasses(recv_klass,1454resolved_method->name(),1455resolved_method->signature(),1456Klass::PrivateLookupMode::skip);1457selected_method = methodHandle(THREAD, method);14581459if (selected_method.is_null() && !check_null_and_abstract) {1460// In theory this is a harmless placeholder value, but1461// in practice leaving in null affects the nsk default method tests.1462// This needs further study.1463selected_method = resolved_method;1464}1465// check if method exists1466if (selected_method.is_null()) {1467// Pass arguments for generating a verbose error message.1468throw_abstract_method_error(resolved_method, recv_klass, CHECK);1469}1470// check access1471// Throw Illegal Access Error if selected_method is not public.1472if (!selected_method->is_public()) {1473ResourceMark rm(THREAD);1474stringStream ss;1475ss.print("'");1476Method::print_external_name(&ss, recv_klass, selected_method->name(), selected_method->signature());1477ss.print("'");1478THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());1479}1480// check if abstract1481if (check_null_and_abstract && selected_method->is_abstract()) {1482throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK);1483}1484}14851486if (log_develop_is_enabled(Trace, itables)) {1487trace_method_resolution("invokeinterface selected method: receiver-class:",1488recv_klass, resolved_klass, selected_method(), true);1489}1490// setup result1491if (resolved_method->has_vtable_index()) {1492int vtable_index = resolved_method->vtable_index();1493log_develop_trace(itables)(" -- vtable index: %d", vtable_index);1494assert(vtable_index == selected_method->vtable_index(), "sanity check");1495result.set_virtual(resolved_klass, resolved_method, selected_method, vtable_index, CHECK);1496} else if (resolved_method->has_itable_index()) {1497int itable_index = resolved_method()->itable_index();1498log_develop_trace(itables)(" -- itable index: %d", itable_index);1499result.set_interface(resolved_klass, resolved_method, selected_method, itable_index, CHECK);1500} else {1501int index = resolved_method->vtable_index();1502log_develop_trace(itables)(" -- non itable/vtable index: %d", index);1503assert(index == Method::nonvirtual_vtable_index, "Oops hit another case!");1504assert(resolved_method()->is_private() ||1505(resolved_method()->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()),1506"Should only have non-virtual invokeinterface for private or final-Object methods!");1507assert(resolved_method()->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!");1508// This sets up the nonvirtual form of "virtual" call (as needed for final and private methods)1509result.set_virtual(resolved_klass, resolved_method, resolved_method, index, CHECK);1510}1511}151215131514Method* LinkResolver::linktime_resolve_interface_method_or_null(1515const LinkInfo& link_info) {1516EXCEPTION_MARK;1517Method* method_result = linktime_resolve_interface_method(link_info, THREAD);1518if (HAS_PENDING_EXCEPTION) {1519CLEAR_PENDING_EXCEPTION;1520return NULL;1521} else {1522return method_result;1523}1524}15251526Method* LinkResolver::linktime_resolve_virtual_method_or_null(1527const LinkInfo& link_info) {1528EXCEPTION_MARK;1529Method* method_result = linktime_resolve_virtual_method(link_info, THREAD);1530if (HAS_PENDING_EXCEPTION) {1531CLEAR_PENDING_EXCEPTION;1532return NULL;1533} else {1534return method_result;1535}1536}15371538Method* LinkResolver::resolve_virtual_call_or_null(1539Klass* receiver_klass,1540const LinkInfo& link_info) {1541EXCEPTION_MARK;1542CallInfo info;1543resolve_virtual_call(info, Handle(), receiver_klass, link_info, false, THREAD);1544if (HAS_PENDING_EXCEPTION) {1545CLEAR_PENDING_EXCEPTION;1546return NULL;1547}1548return info.selected_method();1549}15501551Method* LinkResolver::resolve_interface_call_or_null(1552Klass* receiver_klass,1553const LinkInfo& link_info) {1554EXCEPTION_MARK;1555CallInfo info;1556resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD);1557if (HAS_PENDING_EXCEPTION) {1558CLEAR_PENDING_EXCEPTION;1559return NULL;1560}1561return info.selected_method();1562}15631564int LinkResolver::resolve_virtual_vtable_index(Klass* receiver_klass,1565const LinkInfo& link_info) {1566EXCEPTION_MARK;1567CallInfo info;1568resolve_virtual_call(info, Handle(), receiver_klass, link_info,1569/*check_null_or_abstract*/false, THREAD);1570if (HAS_PENDING_EXCEPTION) {1571CLEAR_PENDING_EXCEPTION;1572return Method::invalid_vtable_index;1573}1574return info.vtable_index();1575}15761577Method* LinkResolver::resolve_static_call_or_null(const LinkInfo& link_info) {1578EXCEPTION_MARK;1579CallInfo info;1580resolve_static_call(info, link_info, /*initialize_class*/false, THREAD);1581if (HAS_PENDING_EXCEPTION) {1582CLEAR_PENDING_EXCEPTION;1583return NULL;1584}1585return info.selected_method();1586}15871588Method* LinkResolver::resolve_special_call_or_null(const LinkInfo& link_info) {1589EXCEPTION_MARK;1590CallInfo info;1591resolve_special_call(info, Handle(), link_info, THREAD);1592if (HAS_PENDING_EXCEPTION) {1593CLEAR_PENDING_EXCEPTION;1594return NULL;1595}1596return info.selected_method();1597}1598159916001601//------------------------------------------------------------------------------------------------------------------------1602// ConstantPool entries16031604void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) {1605switch (byte) {1606case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break;1607case Bytecodes::_invokespecial : resolve_invokespecial (result, recv, pool, index, CHECK); break;1608case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break;1609case Bytecodes::_invokehandle : resolve_invokehandle (result, pool, index, CHECK); break;1610case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break;1611case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break;1612default : break;1613}1614return;1615}16161617void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv,1618const methodHandle& attached_method,1619Bytecodes::Code byte, TRAPS) {1620Klass* defc = attached_method->method_holder();1621Symbol* name = attached_method->name();1622Symbol* type = attached_method->signature();1623LinkInfo link_info(defc, name, type);1624switch(byte) {1625case Bytecodes::_invokevirtual:1626resolve_virtual_call(result, recv, recv->klass(), link_info,1627/*check_null_and_abstract=*/true, CHECK);1628break;1629case Bytecodes::_invokeinterface:1630resolve_interface_call(result, recv, recv->klass(), link_info,1631/*check_null_and_abstract=*/true, CHECK);1632break;1633case Bytecodes::_invokestatic:1634resolve_static_call(result, link_info, /*initialize_class=*/false, CHECK);1635break;1636case Bytecodes::_invokespecial:1637resolve_special_call(result, recv, link_info, CHECK);1638break;1639default:1640fatal("bad call: %s", Bytecodes::name(byte));1641break;1642}1643}16441645void LinkResolver::resolve_invokestatic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {1646LinkInfo link_info(pool, index, CHECK);1647resolve_static_call(result, link_info, /*initialize_class*/true, CHECK);1648}164916501651void LinkResolver::resolve_invokespecial(CallInfo& result, Handle recv,1652const constantPoolHandle& pool, int index, TRAPS) {1653LinkInfo link_info(pool, index, CHECK);1654resolve_special_call(result, recv, link_info, CHECK);1655}165616571658void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv,1659const constantPoolHandle& pool, int index,1660TRAPS) {16611662LinkInfo link_info(pool, index, CHECK);1663Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass();1664resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK);1665}166616671668void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) {1669LinkInfo link_info(pool, index, CHECK);1670Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass();1671resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK);1672}16731674bool LinkResolver::resolve_previously_linked_invokehandle(CallInfo& result, const LinkInfo& link_info, const constantPoolHandle& pool, int index, TRAPS) {1675int cache_index = ConstantPool::decode_cpcache_index(index, true);1676ConstantPoolCacheEntry* cpce = pool->cache()->entry_at(cache_index);1677if (!cpce->is_f1_null()) {1678Klass* resolved_klass = link_info.resolved_klass();1679methodHandle method(THREAD, cpce->f1_as_method());1680Handle appendix(THREAD, cpce->appendix_if_resolved(pool));1681result.set_handle(resolved_klass, method, appendix, CHECK_false);1682return true;1683} else {1684return false;1685}1686}16871688void LinkResolver::resolve_invokehandle(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {1689LinkInfo link_info(pool, index, CHECK);1690if (log_is_enabled(Info, methodhandles)) {1691ResourceMark rm(THREAD);1692log_info(methodhandles)("resolve_invokehandle %s %s", link_info.name()->as_C_string(),1693link_info.signature()->as_C_string());1694}1695{ // Check if the call site has been bound already, and short circuit:1696bool is_done = resolve_previously_linked_invokehandle(result, link_info, pool, index, CHECK);1697if (is_done) return;1698}1699resolve_handle_call(result, link_info, CHECK);1700}17011702void LinkResolver::resolve_handle_call(CallInfo& result,1703const LinkInfo& link_info,1704TRAPS) {1705// JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar1706Klass* resolved_klass = link_info.resolved_klass();1707assert(resolved_klass == vmClasses::MethodHandle_klass() ||1708resolved_klass == vmClasses::VarHandle_klass(), "");1709assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), "");1710Handle resolved_appendix;1711Method* m = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK);1712methodHandle resolved_method(THREAD, m);17131714if (link_info.check_access()) {1715Symbol* name = link_info.name();1716vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name);1717if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) {1718// Check if method can be accessed by the referring class.1719// MH.linkTo* invocations are not rewritten to invokehandle.1720assert(iid == vmIntrinsicID::_invokeBasic, "%s", vmIntrinsics::name_at(iid));17211722Klass* current_klass = link_info.current_klass();1723assert(current_klass != NULL , "current_klass should not be null");1724check_method_accessability(current_klass,1725resolved_klass,1726resolved_method->method_holder(),1727resolved_method,1728CHECK);1729} else {1730// Java code is free to arbitrarily link signature-polymorphic invokers.1731assert(iid == vmIntrinsics::_invokeGeneric, "not an invoker: %s", vmIntrinsics::name_at(iid));1732assert(MethodHandles::is_signature_polymorphic_public_name(resolved_klass, name), "not public");1733}1734}1735result.set_handle(resolved_klass, resolved_method, resolved_appendix, CHECK);1736}17371738void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int indy_index, TRAPS) {1739ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(indy_index);1740int pool_index = cpce->constant_pool_index();17411742// Resolve the bootstrap specifier (BSM + optional arguments).1743BootstrapInfo bootstrap_specifier(pool, pool_index, indy_index);17441745// Check if CallSite has been bound already or failed already, and short circuit:1746{1747bool is_done = bootstrap_specifier.resolve_previously_linked_invokedynamic(result, CHECK);1748if (is_done) return;1749}17501751// The initial step in Call Site Specifier Resolution is to resolve the symbolic1752// reference to a method handle which will be the bootstrap method for a dynamic1753// call site. If resolution for the java.lang.invoke.MethodHandle for the bootstrap1754// method fails, then a MethodHandleInError is stored at the corresponding bootstrap1755// method's CP index for the CONSTANT_MethodHandle_info. So, there is no need to1756// set the indy_rf flag since any subsequent invokedynamic instruction which shares1757// this bootstrap method will encounter the resolution of MethodHandleInError.17581759resolve_dynamic_call(result, bootstrap_specifier, CHECK);17601761LogTarget(Debug, methodhandles, indy) lt_indy;1762if (lt_indy.is_enabled()) {1763LogStream ls(lt_indy);1764bootstrap_specifier.print_msg_on(&ls, "resolve_invokedynamic");1765}17661767// The returned linkage result is provisional up to the moment1768// the interpreter or runtime performs a serialized check of1769// the relevant CPCE::f1 field. This is done by the caller1770// of this method, via CPCE::set_dynamic_call, which uses1771// an ObjectLocker to do the final serialization of updates1772// to CPCE state, including f1.17731774// Log dynamic info to CDS classlist.1775ArchiveUtils::log_to_classlist(&bootstrap_specifier, CHECK);1776}17771778void LinkResolver::resolve_dynamic_call(CallInfo& result,1779BootstrapInfo& bootstrap_specifier,1780TRAPS) {1781// JSR 292: this must resolve to an implicitly generated method1782// such as MH.linkToCallSite(*...) or some other call-site shape.1783// The appendix argument is likely to be a freshly-created CallSite.1784// It may also be a MethodHandle from an unwrapped ConstantCallSite,1785// or any other reference. The resolved_method as well as the appendix1786// are both recorded together via CallInfo::set_handle.1787SystemDictionary::invoke_bootstrap_method(bootstrap_specifier, THREAD);1788Exceptions::wrap_dynamic_exception(/* is_indy */ true, THREAD);17891790if (HAS_PENDING_EXCEPTION) {1791if (!PENDING_EXCEPTION->is_a(vmClasses::LinkageError_klass())) {1792// Let any random low-level IE or SOE or OOME just bleed through.1793// Basically we pretend that the bootstrap method was never called,1794// if it fails this way: We neither record a successful linkage,1795// nor do we memorize a LE for posterity.1796return;1797}1798// JVMS 5.4.3 says: If an attempt by the Java Virtual Machine to resolve1799// a symbolic reference fails because an error is thrown that is an1800// instance of LinkageError (or a subclass), then subsequent attempts to1801// resolve the reference always fail with the same error that was thrown1802// as a result of the initial resolution attempt.1803bool recorded_res_status = bootstrap_specifier.save_and_throw_indy_exc(CHECK);1804if (!recorded_res_status) {1805// Another thread got here just before we did. So, either use the method1806// that it resolved or throw the LinkageError exception that it threw.1807bool is_done = bootstrap_specifier.resolve_previously_linked_invokedynamic(result, CHECK);1808if (is_done) return;1809}1810assert(bootstrap_specifier.invokedynamic_cp_cache_entry()->indy_resolution_failed(),1811"Resolution failure flag wasn't set");1812}18131814bootstrap_specifier.resolve_newly_linked_invokedynamic(result, CHECK);1815// Exceptions::wrap_dynamic_exception not used because1816// set_handle doesn't throw linkage errors1817}18181819// Selected method is abstract.1820void LinkResolver::throw_abstract_method_error(const methodHandle& resolved_method,1821const methodHandle& selected_method,1822Klass *recv_klass, TRAPS) {1823Klass *resolved_klass = resolved_method->method_holder();1824ResourceMark rm(THREAD);1825stringStream ss;18261827if (recv_klass != NULL) {1828ss.print("Receiver class %s does not define or inherit an "1829"implementation of the",1830recv_klass->external_name());1831} else {1832ss.print("Missing implementation of");1833}18341835assert(resolved_method.not_null(), "Sanity");1836ss.print(" resolved method '%s%s",1837resolved_method->is_abstract() ? "abstract " : "",1838resolved_method->is_private() ? "private " : "");1839resolved_method->signature()->print_as_signature_external_return_type(&ss);1840ss.print(" %s(", resolved_method->name()->as_C_string());1841resolved_method->signature()->print_as_signature_external_parameters(&ss);1842ss.print(")' of %s %s.",1843resolved_klass->external_kind(),1844resolved_klass->external_name());18451846if (selected_method.not_null() && !(resolved_method == selected_method)) {1847ss.print(" Selected method is '%s%s",1848selected_method->is_abstract() ? "abstract " : "",1849selected_method->is_private() ? "private " : "");1850selected_method->print_external_name(&ss);1851ss.print("'.");1852}18531854THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());1855}185618571858