src/share/vm/interpreter/linkResolver.cpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/interpreter/linkResolver.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,1679 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "classfile/defaultMethods.hpp"
    1.30 +#include "classfile/systemDictionary.hpp"
    1.31 +#include "classfile/vmSymbols.hpp"
    1.32 +#include "compiler/compileBroker.hpp"
    1.33 +#include "gc_interface/collectedHeap.inline.hpp"
    1.34 +#include "interpreter/bytecode.hpp"
    1.35 +#include "interpreter/interpreterRuntime.hpp"
    1.36 +#include "interpreter/linkResolver.hpp"
    1.37 +#include "memory/resourceArea.hpp"
    1.38 +#include "memory/universe.inline.hpp"
    1.39 +#include "oops/instanceKlass.hpp"
    1.40 +#include "oops/objArrayOop.hpp"
    1.41 +#include "prims/methodHandles.hpp"
    1.42 +#include "prims/nativeLookup.hpp"
    1.43 +#include "runtime/compilationPolicy.hpp"
    1.44 +#include "runtime/fieldDescriptor.hpp"
    1.45 +#include "runtime/frame.inline.hpp"
    1.46 +#include "runtime/handles.inline.hpp"
    1.47 +#include "runtime/reflection.hpp"
    1.48 +#include "runtime/signature.hpp"
    1.49 +#include "runtime/thread.inline.hpp"
    1.50 +#include "runtime/vmThread.hpp"
    1.51 +
    1.52 +
    1.53 +//------------------------------------------------------------------------------------------------------------------------
    1.54 +// Implementation of CallInfo
    1.55 +
    1.56 +
    1.57 +void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) {
    1.58 +  int vtable_index = Method::nonvirtual_vtable_index;
    1.59 +  set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);
    1.60 +}
    1.61 +
    1.62 +
    1.63 +void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int itable_index, TRAPS) {
    1.64 +  // This is only called for interface methods. If the resolved_method
    1.65 +  // comes from java/lang/Object, it can be the subject of a virtual call, so
    1.66 +  // we should pick the vtable index from the resolved method.
    1.67 +  // In that case, the caller must call set_virtual instead of set_interface.
    1.68 +  assert(resolved_method->method_holder()->is_interface(), "");
    1.69 +  assert(itable_index == resolved_method()->itable_index(), "");
    1.70 +  set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK);
    1.71 +}
    1.72 +
    1.73 +void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) {
    1.74 +  assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index");
    1.75 +  assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), "");
    1.76 +  CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call);
    1.77 +  set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK);
    1.78 +  assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call");
    1.79 +}
    1.80 +
    1.81 +void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS) {
    1.82 +  if (resolved_method.is_null()) {
    1.83 +    THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null");
    1.84 +  }
    1.85 +  KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass();
    1.86 +  assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic ||
    1.87 +         resolved_method->is_compiled_lambda_form(),
    1.88 +         "linkMethod must return one of these");
    1.89 +  int vtable_index = Method::nonvirtual_vtable_index;
    1.90 +  assert(!resolved_method->has_vtable_index(), "");
    1.91 +  set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);
    1.92 +  _resolved_appendix    = resolved_appendix;
    1.93 +  _resolved_method_type = resolved_method_type;
    1.94 +}
    1.95 +
    1.96 +void CallInfo::set_common(KlassHandle resolved_klass,
    1.97 +                          KlassHandle selected_klass,
    1.98 +                          methodHandle resolved_method,
    1.99 +                          methodHandle selected_method,
   1.100 +                          CallKind kind,
   1.101 +                          int index,
   1.102 +                          TRAPS) {
   1.103 +  assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond");
   1.104 +  _resolved_klass  = resolved_klass;
   1.105 +  _selected_klass  = selected_klass;
   1.106 +  _resolved_method = resolved_method;
   1.107 +  _selected_method = selected_method;
   1.108 +  _call_kind       = kind;
   1.109 +  _call_index      = index;
   1.110 +  _resolved_appendix = Handle();
   1.111 +  DEBUG_ONLY(verify());  // verify before making side effects
   1.112 +
   1.113 +  if (CompilationPolicy::must_be_compiled(selected_method)) {
   1.114 +    // This path is unusual, mostly used by the '-Xcomp' stress test mode.
   1.115 +
   1.116 +    // Note: with several active threads, the must_be_compiled may be true
   1.117 +    //       while can_be_compiled is false; remove assert
   1.118 +    // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
   1.119 +    if (THREAD->is_Compiler_thread()) {
   1.120 +      // don't force compilation, resolve was on behalf of compiler
   1.121 +      return;
   1.122 +    }
   1.123 +    if (selected_method->method_holder()->is_not_initialized()) {
   1.124 +      // 'is_not_initialized' means not only '!is_initialized', but also that
   1.125 +      // initialization has not been started yet ('!being_initialized')
   1.126 +      // Do not force compilation of methods in uninitialized classes.
   1.127 +      // Note that doing this would throw an assert later,
   1.128 +      // in CompileBroker::compile_method.
   1.129 +      // We sometimes use the link resolver to do reflective lookups
   1.130 +      // even before classes are initialized.
   1.131 +      return;
   1.132 +    }
   1.133 +    CompileBroker::compile_method(selected_method, InvocationEntryBci,
   1.134 +                                  CompilationPolicy::policy()->initial_compile_level(),
   1.135 +                                  methodHandle(), 0, "must_be_compiled", CHECK);
   1.136 +  }
   1.137 +}
   1.138 +
   1.139 +// utility query for unreflecting a method
   1.140 +CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) {
   1.141 +  Klass* resolved_method_holder = resolved_method->method_holder();
   1.142 +  if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st
   1.143 +    resolved_klass = resolved_method_holder;
   1.144 +  }
   1.145 +  _resolved_klass  = resolved_klass;
   1.146 +  _selected_klass  = resolved_klass;
   1.147 +  _resolved_method = resolved_method;
   1.148 +  _selected_method = resolved_method;
   1.149 +  // classify:
   1.150 +  CallKind kind = CallInfo::unknown_kind;
   1.151 +  int index = resolved_method->vtable_index();
   1.152 +  if (resolved_method->can_be_statically_bound()) {
   1.153 +    kind = CallInfo::direct_call;
   1.154 +  } else if (!resolved_method_holder->is_interface()) {
   1.155 +    // Could be an Object method inherited into an interface, but still a vtable call.
   1.156 +    kind = CallInfo::vtable_call;
   1.157 +  } else if (!resolved_klass->is_interface()) {
   1.158 +    // A default or miranda method.  Compute the vtable index.
   1.159 +    ResourceMark rm;
   1.160 +    klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable();
   1.161 +    index = LinkResolver::vtable_index_of_interface_method(resolved_klass,
   1.162 +                           resolved_method);
   1.163 +    assert(index >= 0 , "we should have valid vtable index at this point");
   1.164 +
   1.165 +    kind = CallInfo::vtable_call;
   1.166 +  } else if (resolved_method->has_vtable_index()) {
   1.167 +    // Can occur if an interface redeclares a method of Object.
   1.168 +
   1.169 +#ifdef ASSERT
   1.170 +    // Ensure that this is really the case.
   1.171 +    KlassHandle object_klass = SystemDictionary::Object_klass();
   1.172 +    Method * object_resolved_method = object_klass()->vtable()->method_at(index);
   1.173 +    assert(object_resolved_method->name() == resolved_method->name(),
   1.174 +      err_msg("Object and interface method names should match at vtable index %d, %s != %s",
   1.175 +      index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()));
   1.176 +    assert(object_resolved_method->signature() == resolved_method->signature(),
   1.177 +      err_msg("Object and interface method signatures should match at vtable index %d, %s != %s",
   1.178 +      index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string()));
   1.179 +#endif // ASSERT
   1.180 +
   1.181 +    kind = CallInfo::vtable_call;
   1.182 +  } else {
   1.183 +    // A regular interface call.
   1.184 +    kind = CallInfo::itable_call;
   1.185 +    index = resolved_method->itable_index();
   1.186 +  }
   1.187 +  assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index));
   1.188 +  _call_kind  = kind;
   1.189 +  _call_index = index;
   1.190 +  _resolved_appendix = Handle();
   1.191 +  DEBUG_ONLY(verify());
   1.192 +}
   1.193 +
   1.194 +#ifdef ASSERT
   1.195 +void CallInfo::verify() {
   1.196 +  switch (call_kind()) {  // the meaning and allowed value of index depends on kind
   1.197 +  case CallInfo::direct_call:
   1.198 +    if (_call_index == Method::nonvirtual_vtable_index)  break;
   1.199 +    // else fall through to check vtable index:
   1.200 +  case CallInfo::vtable_call:
   1.201 +    assert(resolved_klass()->verify_vtable_index(_call_index), "");
   1.202 +    break;
   1.203 +  case CallInfo::itable_call:
   1.204 +    assert(resolved_method()->method_holder()->verify_itable_index(_call_index), "");
   1.205 +    break;
   1.206 +  case CallInfo::unknown_kind:
   1.207 +    assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set");
   1.208 +    break;
   1.209 +  default:
   1.210 +    fatal(err_msg_res("Unexpected call kind %d", call_kind()));
   1.211 +  }
   1.212 +}
   1.213 +#endif //ASSERT
   1.214 +
   1.215 +
   1.216 +
   1.217 +//------------------------------------------------------------------------------------------------------------------------
   1.218 +// Klass resolution
   1.219 +
   1.220 +void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
   1.221 +  if (!Reflection::verify_class_access(ref_klass(),
   1.222 +                                       sel_klass(),
   1.223 +                                       true)) {
   1.224 +    ResourceMark rm(THREAD);
   1.225 +    Exceptions::fthrow(
   1.226 +      THREAD_AND_LOCATION,
   1.227 +      vmSymbols::java_lang_IllegalAccessError(),
   1.228 +      "tried to access class %s from class %s",
   1.229 +      sel_klass->external_name(),
   1.230 +      ref_klass->external_name()
   1.231 +    );
   1.232 +    return;
   1.233 +  }
   1.234 +}
   1.235 +
   1.236 +void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
   1.237 +  Klass* result_oop = pool->klass_ref_at(index, CHECK);
   1.238 +  result = KlassHandle(THREAD, result_oop);
   1.239 +}
   1.240 +
   1.241 +//------------------------------------------------------------------------------------------------------------------------
   1.242 +// Method resolution
   1.243 +//
   1.244 +// According to JVM spec. $5.4.3c & $5.4.3d
   1.245 +
   1.246 +// Look up method in klasses, including static methods
   1.247 +// Then look up local default methods
   1.248 +void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, bool in_imethod_resolve, TRAPS) {
   1.249 +  // Ignore overpasses so statics can be found during resolution
   1.250 +  Method* result_oop = klass->uncached_lookup_method(name, signature, Klass::skip_overpass);
   1.251 +
   1.252 +  if (klass->oop_is_array()) {
   1.253 +    // Only consider klass and super klass for arrays
   1.254 +    result = methodHandle(THREAD, result_oop);
   1.255 +    return;
   1.256 +  }
   1.257 +
   1.258 +  // JDK 8, JVMS 5.4.3.4: Interface method resolution should
   1.259 +  // ignore static and non-public methods of java.lang.Object,
   1.260 +  // like clone, finalize, registerNatives.
   1.261 +  if (in_imethod_resolve &&
   1.262 +      result_oop != NULL &&
   1.263 +      klass->is_interface() &&
   1.264 +      (result_oop->is_static() || !result_oop->is_public()) &&
   1.265 +      result_oop->method_holder() == SystemDictionary::Object_klass()) {
   1.266 +    result_oop = NULL;
   1.267 +  }
   1.268 +
   1.269 +  // Before considering default methods, check for an overpass in the
   1.270 +  // current class if a method has not been found.
   1.271 +  if (result_oop == NULL) {
   1.272 +    result_oop = InstanceKlass::cast(klass())->find_method(name, signature);
   1.273 +  }
   1.274 +
   1.275 +  if (result_oop == NULL) {
   1.276 +    Array<Method*>* default_methods = InstanceKlass::cast(klass())->default_methods();
   1.277 +    if (default_methods != NULL) {
   1.278 +      result_oop = InstanceKlass::find_method(default_methods, name, signature);
   1.279 +    }
   1.280 +  }
   1.281 +
   1.282 +  if (checkpolymorphism && EnableInvokeDynamic && result_oop != NULL) {
   1.283 +    vmIntrinsics::ID iid = result_oop->intrinsic_id();
   1.284 +    if (MethodHandles::is_signature_polymorphic(iid)) {
   1.285 +      // Do not link directly to these.  The VM must produce a synthetic one using lookup_polymorphic_method.
   1.286 +      return;
   1.287 +    }
   1.288 +  }
   1.289 +  result = methodHandle(THREAD, result_oop);
   1.290 +}
   1.291 +
   1.292 +// returns first instance method
   1.293 +// Looks up method in classes, then looks up local default methods
   1.294 +void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
   1.295 +  Method* result_oop = klass->uncached_lookup_method(name, signature, Klass::normal);
   1.296 +  result = methodHandle(THREAD, result_oop);
   1.297 +  while (!result.is_null() && result->is_static() && result->method_holder()->super() != NULL) {
   1.298 +    KlassHandle super_klass = KlassHandle(THREAD, result->method_holder()->super());
   1.299 +    result = methodHandle(THREAD, super_klass->uncached_lookup_method(name, signature, Klass::normal));
   1.300 +  }
   1.301 +
   1.302 +  if (klass->oop_is_array()) {
   1.303 +    // Only consider klass and super klass for arrays
   1.304 +    return;
   1.305 +  }
   1.306 +
   1.307 +  if (result.is_null()) {
   1.308 +    Array<Method*>* default_methods = InstanceKlass::cast(klass())->default_methods();
   1.309 +    if (default_methods != NULL) {
   1.310 +      result = methodHandle(InstanceKlass::find_method(default_methods, name, signature));
   1.311 +      assert(result.is_null() || !result->is_static(), "static defaults not allowed");
   1.312 +    }
   1.313 +  }
   1.314 +}
   1.315 +
   1.316 +int LinkResolver::vtable_index_of_interface_method(KlassHandle klass,
   1.317 +                                          methodHandle resolved_method) {
   1.318 +
   1.319 +  int vtable_index = Method::invalid_vtable_index;
   1.320 +  Symbol* name = resolved_method->name();
   1.321 +  Symbol* signature = resolved_method->signature();
   1.322 +
   1.323 +  // First check in default method array
   1.324 +  if (!resolved_method->is_abstract() &&
   1.325 +    (InstanceKlass::cast(klass())->default_methods() != NULL)) {
   1.326 +    int index = InstanceKlass::find_method_index(InstanceKlass::cast(klass())->default_methods(), name, signature, false);
   1.327 +    if (index >= 0 ) {
   1.328 +      vtable_index = InstanceKlass::cast(klass())->default_vtable_indices()->at(index);
   1.329 +    }
   1.330 +  }
   1.331 +  if (vtable_index == Method::invalid_vtable_index) {
   1.332 +    // get vtable_index for miranda methods
   1.333 +    ResourceMark rm;
   1.334 +    klassVtable *vt = InstanceKlass::cast(klass())->vtable();
   1.335 +    vtable_index = vt->index_of_miranda(name, signature);
   1.336 +  }
   1.337 +  return vtable_index;
   1.338 +}
   1.339 +
   1.340 +void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
   1.341 +  InstanceKlass *ik = InstanceKlass::cast(klass());
   1.342 +
   1.343 +  // Specify 'true' in order to skip default methods when searching the
   1.344 +  // interfaces.  Function lookup_method_in_klasses() already looked for
   1.345 +  // the method in the default methods table.
   1.346 +  result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature, Klass::skip_defaults));
   1.347 +}
   1.348 +
   1.349 +void LinkResolver::lookup_polymorphic_method(methodHandle& result,
   1.350 +                                             KlassHandle klass, Symbol* name, Symbol* full_signature,
   1.351 +                                             KlassHandle current_klass,
   1.352 +                                             Handle *appendix_result_or_null,
   1.353 +                                             Handle *method_type_result,
   1.354 +                                             TRAPS) {
   1.355 +  vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name);
   1.356 +  if (TraceMethodHandles) {
   1.357 +    ResourceMark rm(THREAD);
   1.358 +    tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s",
   1.359 +                  vmIntrinsics::name_at(iid), klass->external_name(),
   1.360 +                  name->as_C_string(), full_signature->as_C_string());
   1.361 +  }
   1.362 +  if (EnableInvokeDynamic &&
   1.363 +      klass() == SystemDictionary::MethodHandle_klass() &&
   1.364 +      iid != vmIntrinsics::_none) {
   1.365 +    if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) {
   1.366 +      // Most of these do not need an up-call to Java to resolve, so can be done anywhere.
   1.367 +      // Do not erase last argument type (MemberName) if it is a static linkTo method.
   1.368 +      bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid);
   1.369 +      TempNewSymbol basic_signature =
   1.370 +        MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK);
   1.371 +      if (TraceMethodHandles) {
   1.372 +        ResourceMark rm(THREAD);
   1.373 +        tty->print_cr("lookup_polymorphic_method %s %s => basic %s",
   1.374 +                      name->as_C_string(),
   1.375 +                      full_signature->as_C_string(),
   1.376 +                      basic_signature->as_C_string());
   1.377 +      }
   1.378 +      result = SystemDictionary::find_method_handle_intrinsic(iid,
   1.379 +                                                              basic_signature,
   1.380 +                                                              CHECK);
   1.381 +      if (result.not_null()) {
   1.382 +        assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic");
   1.383 +        assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this");
   1.384 +        assert(basic_signature == result->signature(), "predict the result signature");
   1.385 +        if (TraceMethodHandles) {
   1.386 +          tty->print("lookup_polymorphic_method => intrinsic ");
   1.387 +          result->print_on(tty);
   1.388 +        }
   1.389 +        return;
   1.390 +      }
   1.391 +    } else if (iid == vmIntrinsics::_invokeGeneric
   1.392 +               && !THREAD->is_Compiler_thread()
   1.393 +               && appendix_result_or_null != NULL) {
   1.394 +      // This is a method with type-checking semantics.
   1.395 +      // We will ask Java code to spin an adapter method for it.
   1.396 +      if (!MethodHandles::enabled()) {
   1.397 +        // Make sure the Java part of the runtime has been booted up.
   1.398 +        Klass* natives = SystemDictionary::MethodHandleNatives_klass();
   1.399 +        if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) {
   1.400 +          SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(),
   1.401 +                                            Handle(),
   1.402 +                                            Handle(),
   1.403 +                                            true,
   1.404 +                                            CHECK);
   1.405 +        }
   1.406 +      }
   1.407 +
   1.408 +      Handle appendix;
   1.409 +      Handle method_type;
   1.410 +      result = SystemDictionary::find_method_handle_invoker(name,
   1.411 +                                                            full_signature,
   1.412 +                                                            current_klass,
   1.413 +                                                            &appendix,
   1.414 +                                                            &method_type,
   1.415 +                                                            CHECK);
   1.416 +      if (TraceMethodHandles) {
   1.417 +        tty->print("lookup_polymorphic_method => (via Java) ");
   1.418 +        result->print_on(tty);
   1.419 +        tty->print("  lookup_polymorphic_method => appendix = ");
   1.420 +        if (appendix.is_null())  tty->print_cr("(none)");
   1.421 +        else                     appendix->print_on(tty);
   1.422 +      }
   1.423 +      if (result.not_null()) {
   1.424 +#ifdef ASSERT
   1.425 +        ResourceMark rm(THREAD);
   1.426 +
   1.427 +        TempNewSymbol basic_signature =
   1.428 +          MethodHandles::lookup_basic_type_signature(full_signature, CHECK);
   1.429 +        int actual_size_of_params = result->size_of_parameters();
   1.430 +        int expected_size_of_params = ArgumentSizeComputer(basic_signature).size();
   1.431 +        // +1 for MethodHandle.this, +1 for trailing MethodType
   1.432 +        if (!MethodHandles::is_signature_polymorphic_static(iid))  expected_size_of_params += 1;
   1.433 +        if (appendix.not_null())                                   expected_size_of_params += 1;
   1.434 +        if (actual_size_of_params != expected_size_of_params) {
   1.435 +          tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string());
   1.436 +          tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid));
   1.437 +          result->print();
   1.438 +        }
   1.439 +        assert(actual_size_of_params == expected_size_of_params,
   1.440 +               err_msg("%d != %d", actual_size_of_params, expected_size_of_params));
   1.441 +#endif //ASSERT
   1.442 +
   1.443 +        assert(appendix_result_or_null != NULL, "");
   1.444 +        (*appendix_result_or_null) = appendix;
   1.445 +        (*method_type_result)      = method_type;
   1.446 +        return;
   1.447 +      }
   1.448 +    }
   1.449 +  }
   1.450 +}
   1.451 +
   1.452 +void LinkResolver::check_method_accessability(KlassHandle ref_klass,
   1.453 +                                              KlassHandle resolved_klass,
   1.454 +                                              KlassHandle sel_klass,
   1.455 +                                              methodHandle sel_method,
   1.456 +                                              TRAPS) {
   1.457 +
   1.458 +  AccessFlags flags = sel_method->access_flags();
   1.459 +
   1.460 +  // Special case:  arrays always override "clone". JVMS 2.15.
   1.461 +  // If the resolved klass is an array class, and the declaring class
   1.462 +  // is java.lang.Object and the method is "clone", set the flags
   1.463 +  // to public.
   1.464 +  //
   1.465 +  // We'll check for the method name first, as that's most likely
   1.466 +  // to be false (so we'll short-circuit out of these tests).
   1.467 +  if (sel_method->name() == vmSymbols::clone_name() &&
   1.468 +      sel_klass() == SystemDictionary::Object_klass() &&
   1.469 +      resolved_klass->oop_is_array()) {
   1.470 +    // We need to change "protected" to "public".
   1.471 +    assert(flags.is_protected(), "clone not protected?");
   1.472 +    jint new_flags = flags.as_int();
   1.473 +    new_flags = new_flags & (~JVM_ACC_PROTECTED);
   1.474 +    new_flags = new_flags | JVM_ACC_PUBLIC;
   1.475 +    flags.set_flags(new_flags);
   1.476 +  }
   1.477 +//  assert(extra_arg_result_or_null != NULL, "must be able to return extra argument");
   1.478 +
   1.479 +  if (!Reflection::verify_field_access(ref_klass(),
   1.480 +                                       resolved_klass(),
   1.481 +                                       sel_klass(),
   1.482 +                                       flags,
   1.483 +                                       true)) {
   1.484 +    ResourceMark rm(THREAD);
   1.485 +    Exceptions::fthrow(
   1.486 +      THREAD_AND_LOCATION,
   1.487 +      vmSymbols::java_lang_IllegalAccessError(),
   1.488 +      "tried to access method %s.%s%s from class %s",
   1.489 +      sel_klass->external_name(),
   1.490 +      sel_method->name()->as_C_string(),
   1.491 +      sel_method->signature()->as_C_string(),
   1.492 +      ref_klass->external_name()
   1.493 +    );
   1.494 +    return;
   1.495 +  }
   1.496 +}
   1.497 +
   1.498 +void LinkResolver::resolve_method_statically(methodHandle& resolved_method, KlassHandle& resolved_klass,
   1.499 +                                             Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS) {
   1.500 +  // This method is used only
   1.501 +  // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
   1.502 +  // and
   1.503 +  // (2) in Bytecode_invoke::static_target
   1.504 +  // It appears to fail when applied to an invokeinterface call site.
   1.505 +  // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
   1.506 +  // resolve klass
   1.507 +  if (code == Bytecodes::_invokedynamic) {
   1.508 +    resolved_klass = SystemDictionary::MethodHandle_klass();
   1.509 +    Symbol* method_name = vmSymbols::invoke_name();
   1.510 +    Symbol* method_signature = pool->signature_ref_at(index);
   1.511 +    KlassHandle  current_klass(THREAD, pool->pool_holder());
   1.512 +    resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, false, CHECK);
   1.513 +    return;
   1.514 +  }
   1.515 +
   1.516 +  resolve_klass(resolved_klass, pool, index, CHECK);
   1.517 +
   1.518 +  Symbol*  method_name       = pool->name_ref_at(index);
   1.519 +  Symbol*  method_signature  = pool->signature_ref_at(index);
   1.520 +  KlassHandle  current_klass(THREAD, pool->pool_holder());
   1.521 +
   1.522 +  if (pool->has_preresolution()
   1.523 +      || (resolved_klass() == SystemDictionary::MethodHandle_klass() &&
   1.524 +          MethodHandles::is_signature_polymorphic_name(resolved_klass(), method_name))) {
   1.525 +    Method* result_oop = ConstantPool::method_at_if_loaded(pool, index);
   1.526 +    if (result_oop != NULL) {
   1.527 +      resolved_method = methodHandle(THREAD, result_oop);
   1.528 +      return;
   1.529 +    }
   1.530 +  }
   1.531 +
   1.532 +  if (code == Bytecodes::_invokeinterface) {
   1.533 +    resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
   1.534 +  } else if (code == Bytecodes::_invokevirtual) {
   1.535 +    resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
   1.536 +  } else if (!resolved_klass->is_interface()) {
   1.537 +    resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, false, CHECK);
   1.538 +  } else {
   1.539 +    bool nostatics = (code == Bytecodes::_invokestatic) ? false : true;
   1.540 +    resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, nostatics, CHECK);
   1.541 +  }
   1.542 +}
   1.543 +
   1.544 +void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle resolved_klass,
   1.545 +                                  Symbol* method_name, Symbol* method_signature,
   1.546 +                                  KlassHandle current_klass, bool check_access,
   1.547 +                                  bool require_methodref, TRAPS) {
   1.548 +
   1.549 +  Handle nested_exception;
   1.550 +
   1.551 +  // 1. check if methodref required, that resolved_klass is not interfacemethodref
   1.552 +  if (require_methodref && resolved_klass->is_interface()) {
   1.553 +    ResourceMark rm(THREAD);
   1.554 +    char buf[200];
   1.555 +    jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected",
   1.556 +        resolved_klass()->external_name());
   1.557 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   1.558 +  }
   1.559 +
   1.560 +  // 2. lookup method in resolved klass and its super klasses
   1.561 +  lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, true, false, CHECK);
   1.562 +
   1.563 +  if (resolved_method.is_null() && !resolved_klass->oop_is_array()) { // not found in the class hierarchy
   1.564 +    // 3. lookup method in all the interfaces implemented by the resolved klass
   1.565 +    lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
   1.566 +
   1.567 +    if (resolved_method.is_null()) {
   1.568 +      // JSR 292:  see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc
   1.569 +      lookup_polymorphic_method(resolved_method, resolved_klass, method_name, method_signature,
   1.570 +                                current_klass, (Handle*)NULL, (Handle*)NULL, THREAD);
   1.571 +      if (HAS_PENDING_EXCEPTION) {
   1.572 +        nested_exception = Handle(THREAD, PENDING_EXCEPTION);
   1.573 +        CLEAR_PENDING_EXCEPTION;
   1.574 +      }
   1.575 +    }
   1.576 +  }
   1.577 +
   1.578 +  if (resolved_method.is_null()) {
   1.579 +    // 4. method lookup failed
   1.580 +    ResourceMark rm(THREAD);
   1.581 +    THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(),
   1.582 +                    Method::name_and_sig_as_C_string(resolved_klass(),
   1.583 +                                                            method_name,
   1.584 +                                                            method_signature),
   1.585 +                    nested_exception);
   1.586 +  }
   1.587 +
   1.588 +  // 5. access checks, access checking may be turned off when calling from within the VM.
   1.589 +  if (check_access) {
   1.590 +    assert(current_klass.not_null() , "current_klass should not be null");
   1.591 +
   1.592 +    // check if method can be accessed by the referring class
   1.593 +    check_method_accessability(current_klass,
   1.594 +                               resolved_klass,
   1.595 +                               KlassHandle(THREAD, resolved_method->method_holder()),
   1.596 +                               resolved_method,
   1.597 +                               CHECK);
   1.598 +
   1.599 +    // check loader constraints
   1.600 +    Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader());
   1.601 +    Handle class_loader (THREAD, resolved_method->method_holder()->class_loader());
   1.602 +    {
   1.603 +      ResourceMark rm(THREAD);
   1.604 +      Symbol* failed_type_symbol =
   1.605 +        SystemDictionary::check_signature_loaders(method_signature, loader,
   1.606 +                                                  class_loader, true, CHECK);
   1.607 +      if (failed_type_symbol != NULL) {
   1.608 +        const char* msg = "loader constraint violation: when resolving method"
   1.609 +          " \"%s\" the class loader (instance of %s) of the current class, %s,"
   1.610 +          " and the class loader (instance of %s) for the method's defining class, %s, have"
   1.611 +          " different Class objects for the type %s used in the signature";
   1.612 +        char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature);
   1.613 +        const char* loader1 = SystemDictionary::loader_name(loader());
   1.614 +        char* current = InstanceKlass::cast(current_klass())->name()->as_C_string();
   1.615 +        const char* loader2 = SystemDictionary::loader_name(class_loader());
   1.616 +        char* target = InstanceKlass::cast(resolved_method->method_holder())
   1.617 +                       ->name()->as_C_string();
   1.618 +        char* failed_type_name = failed_type_symbol->as_C_string();
   1.619 +        size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
   1.620 +          strlen(current) + strlen(loader2) + strlen(target) +
   1.621 +          strlen(failed_type_name) + 1;
   1.622 +        char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
   1.623 +        jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
   1.624 +                     target, failed_type_name);
   1.625 +        THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
   1.626 +      }
   1.627 +    }
   1.628 +  }
   1.629 +}
   1.630 +
   1.631 +void LinkResolver::resolve_interface_method(methodHandle& resolved_method,
   1.632 +                                            KlassHandle resolved_klass,
   1.633 +                                            Symbol* method_name,
   1.634 +                                            Symbol* method_signature,
   1.635 +                                            KlassHandle current_klass,
   1.636 +                                            bool check_access,
   1.637 +                                            bool nostatics, TRAPS) {
   1.638 +
   1.639 +  // check if klass is interface
   1.640 +  if (!resolved_klass->is_interface()) {
   1.641 +    ResourceMark rm(THREAD);
   1.642 +    char buf[200];
   1.643 +    jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name());
   1.644 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   1.645 +  }
   1.646 +
   1.647 +  // lookup method in this interface or its super, java.lang.Object
   1.648 +  // JDK8: also look for static methods
   1.649 +  lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, false, true, CHECK);
   1.650 +
   1.651 +  if (resolved_method.is_null() && !resolved_klass->oop_is_array()) {
   1.652 +    // lookup method in all the super-interfaces
   1.653 +    lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
   1.654 +  }
   1.655 +
   1.656 +  if (resolved_method.is_null()) {
   1.657 +    // no method found
   1.658 +    ResourceMark rm(THREAD);
   1.659 +    THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
   1.660 +              Method::name_and_sig_as_C_string(resolved_klass(),
   1.661 +                                                      method_name,
   1.662 +                                                      method_signature));
   1.663 +  }
   1.664 +
   1.665 +  if (check_access) {
   1.666 +    // JDK8 adds non-public interface methods, and accessability check requirement
   1.667 +    assert(current_klass.not_null() , "current_klass should not be null");
   1.668 +
   1.669 +    // check if method can be accessed by the referring class
   1.670 +    check_method_accessability(current_klass,
   1.671 +                               resolved_klass,
   1.672 +                               KlassHandle(THREAD, resolved_method->method_holder()),
   1.673 +                               resolved_method,
   1.674 +                               CHECK);
   1.675 +
   1.676 +    HandleMark hm(THREAD);
   1.677 +    Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader());
   1.678 +    Handle class_loader (THREAD, resolved_method->method_holder()->class_loader());
   1.679 +    {
   1.680 +      ResourceMark rm(THREAD);
   1.681 +      Symbol* failed_type_symbol =
   1.682 +        SystemDictionary::check_signature_loaders(method_signature, loader,
   1.683 +                                                  class_loader, true, CHECK);
   1.684 +      if (failed_type_symbol != NULL) {
   1.685 +        const char* msg = "loader constraint violation: when resolving "
   1.686 +          "interface method \"%s\" the class loader (instance of %s) of the "
   1.687 +          "current class, %s, and the class loader (instance of %s) for "
   1.688 +          "the method's defining class, %s, have different Class objects for the type %s "
   1.689 +          "used in the signature";
   1.690 +        char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature);
   1.691 +        const char* loader1 = SystemDictionary::loader_name(loader());
   1.692 +        char* current = InstanceKlass::cast(current_klass())->name()->as_C_string();
   1.693 +        const char* loader2 = SystemDictionary::loader_name(class_loader());
   1.694 +        char* target = InstanceKlass::cast(resolved_method->method_holder())
   1.695 +                       ->name()->as_C_string();
   1.696 +        char* failed_type_name = failed_type_symbol->as_C_string();
   1.697 +        size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
   1.698 +          strlen(current) + strlen(loader2) + strlen(target) +
   1.699 +          strlen(failed_type_name) + 1;
   1.700 +        char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
   1.701 +        jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
   1.702 +                     target, failed_type_name);
   1.703 +        THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
   1.704 +      }
   1.705 +    }
   1.706 +  }
   1.707 +
   1.708 +  if (nostatics && resolved_method->is_static()) {
   1.709 +    ResourceMark rm(THREAD);
   1.710 +    char buf[200];
   1.711 +    jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
   1.712 +                 Method::name_and_sig_as_C_string(resolved_klass(),
   1.713 +                 resolved_method->name(), resolved_method->signature()));
   1.714 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   1.715 +  }
   1.716 +
   1.717 +  if (TraceItables && Verbose) {
   1.718 +    ResourceMark rm(THREAD);
   1.719 +    tty->print("invokeinterface resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
   1.720 +                   (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()),
   1.721 +                   (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()),
   1.722 +                   Method::name_and_sig_as_C_string(resolved_klass(),
   1.723 +                                                    resolved_method->name(),
   1.724 +                                                    resolved_method->signature()),
   1.725 +                   resolved_method->method_holder()->internal_name()
   1.726 +                  );
   1.727 +    resolved_method->access_flags().print_on(tty);
   1.728 +    if (resolved_method->is_default_method()) {
   1.729 +      tty->print("default ");
   1.730 +    }
   1.731 +    if (resolved_method->is_overpass()) {
   1.732 +      tty->print("overpass");
   1.733 +    }
   1.734 +    tty->cr();
   1.735 +  }
   1.736 +}
   1.737 +
   1.738 +//------------------------------------------------------------------------------------------------------------------------
   1.739 +// Field resolution
   1.740 +
   1.741 +void LinkResolver::check_field_accessability(KlassHandle ref_klass,
   1.742 +                                             KlassHandle resolved_klass,
   1.743 +                                             KlassHandle sel_klass,
   1.744 +                                             fieldDescriptor& fd,
   1.745 +                                             TRAPS) {
   1.746 +  if (!Reflection::verify_field_access(ref_klass(),
   1.747 +                                       resolved_klass(),
   1.748 +                                       sel_klass(),
   1.749 +                                       fd.access_flags(),
   1.750 +                                       true)) {
   1.751 +    ResourceMark rm(THREAD);
   1.752 +    Exceptions::fthrow(
   1.753 +      THREAD_AND_LOCATION,
   1.754 +      vmSymbols::java_lang_IllegalAccessError(),
   1.755 +      "tried to access field %s.%s from class %s",
   1.756 +      sel_klass->external_name(),
   1.757 +      fd.name()->as_C_string(),
   1.758 +      ref_klass->external_name()
   1.759 +    );
   1.760 +    return;
   1.761 +  }
   1.762 +}
   1.763 +
   1.764 +void LinkResolver::resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) {
   1.765 +  // Load these early in case the resolve of the containing klass fails
   1.766 +  Symbol* field = pool->name_ref_at(index);
   1.767 +  Symbol* sig   = pool->signature_ref_at(index);
   1.768 +
   1.769 +  // resolve specified klass
   1.770 +  KlassHandle resolved_klass;
   1.771 +  resolve_klass(resolved_klass, pool, index, CHECK);
   1.772 +
   1.773 +  KlassHandle  current_klass(THREAD, pool->pool_holder());
   1.774 +  resolve_field(result, resolved_klass, field, sig, current_klass, byte, true, true, CHECK);
   1.775 +}
   1.776 +
   1.777 +void LinkResolver::resolve_field(fieldDescriptor& fd, KlassHandle resolved_klass, Symbol* field, Symbol* sig,
   1.778 +                                 KlassHandle current_klass, Bytecodes::Code byte, bool check_access, bool initialize_class,
   1.779 +                                 TRAPS) {
   1.780 +  assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic ||
   1.781 +         byte == Bytecodes::_getfield  || byte == Bytecodes::_putfield  ||
   1.782 +         (byte == Bytecodes::_nop && !check_access), "bad field access bytecode");
   1.783 +
   1.784 +  bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic);
   1.785 +  bool is_put    = (byte == Bytecodes::_putfield  || byte == Bytecodes::_putstatic);
   1.786 +
   1.787 +  // Check if there's a resolved klass containing the field
   1.788 +  if (resolved_klass.is_null()) {
   1.789 +    ResourceMark rm(THREAD);
   1.790 +    THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
   1.791 +  }
   1.792 +
   1.793 +  // Resolve instance field
   1.794 +  KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd));
   1.795 +  // check if field exists; i.e., if a klass containing the field def has been selected
   1.796 +  if (sel_klass.is_null()) {
   1.797 +    ResourceMark rm(THREAD);
   1.798 +    THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
   1.799 +  }
   1.800 +
   1.801 +  if (!check_access)
   1.802 +    // Access checking may be turned off when calling from within the VM.
   1.803 +    return;
   1.804 +
   1.805 +  // check access
   1.806 +  check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);
   1.807 +
   1.808 +  // check for errors
   1.809 +  if (is_static != fd.is_static()) {
   1.810 +    ResourceMark rm(THREAD);
   1.811 +    char msg[200];
   1.812 +    jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string());
   1.813 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
   1.814 +  }
   1.815 +
   1.816 +  // Final fields can only be accessed from its own class.
   1.817 +  if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) {
   1.818 +    THROW(vmSymbols::java_lang_IllegalAccessError());
   1.819 +  }
   1.820 +
   1.821 +  // initialize resolved_klass if necessary
   1.822 +  // note 1: the klass which declared the field must be initialized (i.e, sel_klass)
   1.823 +  //         according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
   1.824 +  //
   1.825 +  // note 2: we don't want to force initialization if we are just checking
   1.826 +  //         if the field access is legal; e.g., during compilation
   1.827 +  if (is_static && initialize_class) {
   1.828 +    sel_klass->initialize(CHECK);
   1.829 +  }
   1.830 +
   1.831 +  if (sel_klass() != current_klass()) {
   1.832 +    HandleMark hm(THREAD);
   1.833 +    Handle ref_loader (THREAD, InstanceKlass::cast(current_klass())->class_loader());
   1.834 +    Handle sel_loader (THREAD, InstanceKlass::cast(sel_klass())->class_loader());
   1.835 +    {
   1.836 +      ResourceMark rm(THREAD);
   1.837 +      Symbol* failed_type_symbol =
   1.838 +        SystemDictionary::check_signature_loaders(sig,
   1.839 +                                                  ref_loader, sel_loader,
   1.840 +                                                  false,
   1.841 +                                                  CHECK);
   1.842 +      if (failed_type_symbol != NULL) {
   1.843 +        const char* msg = "loader constraint violation: when resolving field"
   1.844 +          " \"%s\" the class loader (instance of %s) of the referring class, "
   1.845 +          "%s, and the class loader (instance of %s) for the field's resolved "
   1.846 +          "type, %s, have different Class objects for that type";
   1.847 +        char* field_name = field->as_C_string();
   1.848 +        const char* loader1 = SystemDictionary::loader_name(ref_loader());
   1.849 +        char* sel = InstanceKlass::cast(sel_klass())->name()->as_C_string();
   1.850 +        const char* loader2 = SystemDictionary::loader_name(sel_loader());
   1.851 +        char* failed_type_name = failed_type_symbol->as_C_string();
   1.852 +        size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) +
   1.853 +          strlen(sel) + strlen(loader2) + strlen(failed_type_name) + 1;
   1.854 +        char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
   1.855 +        jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2,
   1.856 +                     failed_type_name);
   1.857 +        THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
   1.858 +      }
   1.859 +    }
   1.860 +  }
   1.861 +
   1.862 +  // return information. note that the klass is set to the actual klass containing the
   1.863 +  // field, otherwise access of static fields in superclasses will not work.
   1.864 +}
   1.865 +
   1.866 +
   1.867 +//------------------------------------------------------------------------------------------------------------------------
   1.868 +// Invoke resolution
   1.869 +//
   1.870 +// Naming conventions:
   1.871 +//
   1.872 +// resolved_method    the specified method (i.e., static receiver specified via constant pool index)
   1.873 +// sel_method         the selected method  (selected via run-time lookup; e.g., based on dynamic receiver class)
   1.874 +// resolved_klass     the specified klass  (i.e., specified via constant pool index)
   1.875 +// recv_klass         the receiver klass
   1.876 +
   1.877 +
   1.878 +void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, Symbol* method_name,
   1.879 +                                       Symbol* method_signature, KlassHandle current_klass,
   1.880 +                                       bool check_access, bool initialize_class, TRAPS) {
   1.881 +  methodHandle resolved_method;
   1.882 +  linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
   1.883 +  resolved_klass = KlassHandle(THREAD, resolved_method->method_holder());
   1.884 +
   1.885 +  // Initialize klass (this should only happen if everything is ok)
   1.886 +  if (initialize_class && resolved_klass->should_be_initialized()) {
   1.887 +    resolved_klass->initialize(CHECK);
   1.888 +    linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
   1.889 +  }
   1.890 +
   1.891 +  // setup result
   1.892 +  result.set_static(resolved_klass, resolved_method, CHECK);
   1.893 +}
   1.894 +
   1.895 +// throws linktime exceptions
   1.896 +void LinkResolver::linktime_resolve_static_method(methodHandle& resolved_method, KlassHandle resolved_klass,
   1.897 +                                                  Symbol* method_name, Symbol* method_signature,
   1.898 +                                                  KlassHandle current_klass, bool check_access, TRAPS) {
   1.899 +
   1.900 +  if (!resolved_klass->is_interface()) {
   1.901 +    resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK);
   1.902 +  } else {
   1.903 +    resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK);
   1.904 +  }
   1.905 +  assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier");
   1.906 +
   1.907 +  // check if static
   1.908 +  if (!resolved_method->is_static()) {
   1.909 +    ResourceMark rm(THREAD);
   1.910 +    char buf[200];
   1.911 +    jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
   1.912 +                                                      resolved_method->name(),
   1.913 +                                                      resolved_method->signature()));
   1.914 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   1.915 +  }
   1.916 +}
   1.917 +
   1.918 +
   1.919 +void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, Symbol* method_name,
   1.920 +                                        Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
   1.921 +  methodHandle resolved_method;
   1.922 +  linktime_resolve_special_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
   1.923 +  runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, check_access, CHECK);
   1.924 +}
   1.925 +
   1.926 +// throws linktime exceptions
   1.927 +void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method, KlassHandle resolved_klass,
   1.928 +                                                   Symbol* method_name, Symbol* method_signature,
   1.929 +                                                   KlassHandle current_klass, bool check_access, TRAPS) {
   1.930 +
   1.931 +  // Invokespecial is called for multiple special reasons:
   1.932 +  // <init>
   1.933 +  // local private method invocation, for classes and interfaces
   1.934 +  // superclass.method, which can also resolve to a default method
   1.935 +  // and the selected method is recalculated relative to the direct superclass
   1.936 +  // superinterface.method, which explicitly does not check shadowing
   1.937 +
   1.938 +  if (!resolved_klass->is_interface()) {
   1.939 +    resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK);
   1.940 +  } else {
   1.941 +    resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, true, CHECK);
   1.942 +  }
   1.943 +
   1.944 +  // check if method name is <init>, that it is found in same klass as static type
   1.945 +  if (resolved_method->name() == vmSymbols::object_initializer_name() &&
   1.946 +      resolved_method->method_holder() != resolved_klass()) {
   1.947 +    ResourceMark rm(THREAD);
   1.948 +    Exceptions::fthrow(
   1.949 +      THREAD_AND_LOCATION,
   1.950 +      vmSymbols::java_lang_NoSuchMethodError(),
   1.951 +      "%s: method %s%s not found",
   1.952 +      resolved_klass->external_name(),
   1.953 +      resolved_method->name()->as_C_string(),
   1.954 +      resolved_method->signature()->as_C_string()
   1.955 +    );
   1.956 +    return;
   1.957 +  }
   1.958 +
   1.959 +  // check if invokespecial's interface method reference is in an indirect superinterface
   1.960 +  if (!current_klass.is_null() && resolved_klass->is_interface()) {
   1.961 +    Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ?
   1.962 +                                  current_klass() :
   1.963 +                                  InstanceKlass::cast(current_klass())->host_klass();
   1.964 +    // As of the fix for 4486457 we disable verification for all of the
   1.965 +    // dynamically-generated bytecodes associated with the 1.4
   1.966 +    // reflection implementation, not just those associated with
   1.967 +    // sun/reflect/SerializationConstructorAccessor.
   1.968 +    bool is_reflect = JDK_Version::is_gte_jdk14x_version() &&
   1.969 +                      UseNewReflection &&
   1.970 +                      klass_to_check->is_subclass_of(
   1.971 +                        SystemDictionary::reflect_MagicAccessorImpl_klass());
   1.972 +
   1.973 +    if (!is_reflect &&
   1.974 +        !InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) {
   1.975 +      ResourceMark rm(THREAD);
   1.976 +      char buf[200];
   1.977 +      jio_snprintf(buf, sizeof(buf),
   1.978 +                   "Interface method reference: %s, is in an indirect superinterface of %s",
   1.979 +                   Method::name_and_sig_as_C_string(resolved_klass(),
   1.980 +                                                         resolved_method->name(),
   1.981 +                                                         resolved_method->signature()),
   1.982 +                   current_klass->external_name());
   1.983 +      THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   1.984 +    }
   1.985 +  }
   1.986 +
   1.987 +  // check if not static
   1.988 +  if (resolved_method->is_static()) {
   1.989 +    ResourceMark rm(THREAD);
   1.990 +    char buf[200];
   1.991 +    jio_snprintf(buf, sizeof(buf),
   1.992 +                 "Expecting non-static method %s",
   1.993 +                 Method::name_and_sig_as_C_string(resolved_klass(),
   1.994 +                                                         resolved_method->name(),
   1.995 +                                                         resolved_method->signature()));
   1.996 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   1.997 +  }
   1.998 +
   1.999 +  if (TraceItables && Verbose) {
  1.1000 +    ResourceMark rm(THREAD);
  1.1001 +    tty->print("invokespecial resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
  1.1002 +                (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()),
  1.1003 +                (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()),
  1.1004 +                Method::name_and_sig_as_C_string(resolved_klass(),
  1.1005 +                                                 resolved_method->name(),
  1.1006 +                                                 resolved_method->signature()),
  1.1007 +                resolved_method->method_holder()->internal_name()
  1.1008 +               );
  1.1009 +    resolved_method->access_flags().print_on(tty);
  1.1010 +    if (resolved_method->is_default_method()) {
  1.1011 +      tty->print("default ");
  1.1012 +    }
  1.1013 +    if (resolved_method->is_overpass()) {
  1.1014 +      tty->print("overpass");
  1.1015 +    }
  1.1016 +    tty->cr();
  1.1017 +  }
  1.1018 +}
  1.1019 +
  1.1020 +// throws runtime exceptions
  1.1021 +void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
  1.1022 +                                                  KlassHandle current_klass, bool check_access, TRAPS) {
  1.1023 +
  1.1024 +  // resolved method is selected method unless we have an old-style lookup
  1.1025 +  // for a superclass method
  1.1026 +  // Invokespecial for a superinterface, resolved method is selected method,
  1.1027 +  // no checks for shadowing
  1.1028 +  methodHandle sel_method(THREAD, resolved_method());
  1.1029 +
  1.1030 +  // check if this is an old-style super call and do a new lookup if so
  1.1031 +  { KlassHandle method_klass  = KlassHandle(THREAD,
  1.1032 +                                            resolved_method->method_holder());
  1.1033 +
  1.1034 +    if (check_access &&
  1.1035 +        // a) check if ACC_SUPER flag is set for the current class
  1.1036 +        (current_klass->is_super() || !AllowNonVirtualCalls) &&
  1.1037 +        // b) check if the class of the resolved_klass is a superclass
  1.1038 +        // (not supertype in order to exclude interface classes) of the current class.
  1.1039 +        // This check is not performed for super.invoke for interface methods
  1.1040 +        // in super interfaces.
  1.1041 +        current_klass->is_subclass_of(resolved_klass()) &&
  1.1042 +        current_klass() != resolved_klass() &&
  1.1043 +        // c) check if the method is not <init>
  1.1044 +        resolved_method->name() != vmSymbols::object_initializer_name()) {
  1.1045 +      // Lookup super method
  1.1046 +      KlassHandle super_klass(THREAD, current_klass->super());
  1.1047 +      lookup_instance_method_in_klasses(sel_method, super_klass,
  1.1048 +                           resolved_method->name(),
  1.1049 +                           resolved_method->signature(), CHECK);
  1.1050 +      // check if found
  1.1051 +      if (sel_method.is_null()) {
  1.1052 +        ResourceMark rm(THREAD);
  1.1053 +        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
  1.1054 +                  Method::name_and_sig_as_C_string(resolved_klass(),
  1.1055 +                                            resolved_method->name(),
  1.1056 +                                            resolved_method->signature()));
  1.1057 +      }
  1.1058 +    }
  1.1059 +  }
  1.1060 +
  1.1061 +  // check if not static
  1.1062 +  if (sel_method->is_static()) {
  1.1063 +    ResourceMark rm(THREAD);
  1.1064 +    char buf[200];
  1.1065 +    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
  1.1066 +                                                                                                             resolved_method->name(),
  1.1067 +                                                                                                             resolved_method->signature()));
  1.1068 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
  1.1069 +  }
  1.1070 +
  1.1071 +  // check if abstract
  1.1072 +  if (sel_method->is_abstract()) {
  1.1073 +    ResourceMark rm(THREAD);
  1.1074 +    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
  1.1075 +              Method::name_and_sig_as_C_string(resolved_klass(),
  1.1076 +                                                      sel_method->name(),
  1.1077 +                                                      sel_method->signature()));
  1.1078 +  }
  1.1079 +
  1.1080 +  if (TraceItables && Verbose) {
  1.1081 +    ResourceMark rm(THREAD);
  1.1082 +    tty->print("invokespecial selected method: resolved-class:%s, method:%s, method_holder:%s, access_flags: ",
  1.1083 +                 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()),
  1.1084 +                 Method::name_and_sig_as_C_string(resolved_klass(),
  1.1085 +                                                  sel_method->name(),
  1.1086 +                                                  sel_method->signature()),
  1.1087 +                 sel_method->method_holder()->internal_name()
  1.1088 +                );
  1.1089 +    sel_method->access_flags().print_on(tty);
  1.1090 +    if (sel_method->is_default_method()) {
  1.1091 +      tty->print("default ");
  1.1092 +    }
  1.1093 +    if (sel_method->is_overpass()) {
  1.1094 +      tty->print("overpass");
  1.1095 +    }
  1.1096 +    tty->cr();
  1.1097 +  }
  1.1098 +
  1.1099 +  // setup result
  1.1100 +  result.set_static(resolved_klass, sel_method, CHECK);
  1.1101 +}
  1.1102 +
  1.1103 +void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, KlassHandle resolved_klass,
  1.1104 +                                        Symbol* method_name, Symbol* method_signature, KlassHandle current_klass,
  1.1105 +                                        bool check_access, bool check_null_and_abstract, TRAPS) {
  1.1106 +  methodHandle resolved_method;
  1.1107 +  linktime_resolve_virtual_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
  1.1108 +  runtime_resolve_virtual_method(result, resolved_method, resolved_klass, recv, receiver_klass, check_null_and_abstract, CHECK);
  1.1109 +}
  1.1110 +
  1.1111 +// throws linktime exceptions
  1.1112 +void LinkResolver::linktime_resolve_virtual_method(methodHandle &resolved_method, KlassHandle resolved_klass,
  1.1113 +                                                   Symbol* method_name, Symbol* method_signature,
  1.1114 +                                                   KlassHandle current_klass, bool check_access, TRAPS) {
  1.1115 +  // normal method resolution
  1.1116 +  resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, true, CHECK);
  1.1117 +
  1.1118 +  assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
  1.1119 +  assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
  1.1120 +
  1.1121 +  // check if private interface method
  1.1122 +  if (resolved_klass->is_interface() && resolved_method->is_private()) {
  1.1123 +    ResourceMark rm(THREAD);
  1.1124 +    char buf[200];
  1.1125 +    jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s",
  1.1126 +                 Method::name_and_sig_as_C_string(resolved_klass(),
  1.1127 +                                                  resolved_method->name(),
  1.1128 +                                                  resolved_method->signature()),
  1.1129 +                   (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()));
  1.1130 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
  1.1131 +  }
  1.1132 +
  1.1133 +  // check if not static
  1.1134 +  if (resolved_method->is_static()) {
  1.1135 +    ResourceMark rm(THREAD);
  1.1136 +    char buf[200];
  1.1137 +    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
  1.1138 +                                                                                                             resolved_method->name(),
  1.1139 +                                                                                                             resolved_method->signature()));
  1.1140 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
  1.1141 +  }
  1.1142 +
  1.1143 +  if (PrintVtables && Verbose) {
  1.1144 +    ResourceMark rm(THREAD);
  1.1145 +    tty->print("invokevirtual resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
  1.1146 +                   (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()),
  1.1147 +                   (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()),
  1.1148 +                   Method::name_and_sig_as_C_string(resolved_klass(),
  1.1149 +                                                    resolved_method->name(),
  1.1150 +                                                    resolved_method->signature()),
  1.1151 +                   resolved_method->method_holder()->internal_name()
  1.1152 +                  );
  1.1153 +    resolved_method->access_flags().print_on(tty);
  1.1154 +    if (resolved_method->is_default_method()) {
  1.1155 +      tty->print("default ");
  1.1156 +    }
  1.1157 +    if (resolved_method->is_overpass()) {
  1.1158 +      tty->print("overpass");
  1.1159 +    }
  1.1160 +    tty->cr();
  1.1161 +  }
  1.1162 +}
  1.1163 +
  1.1164 +// throws runtime exceptions
  1.1165 +void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
  1.1166 +                                                  methodHandle resolved_method,
  1.1167 +                                                  KlassHandle resolved_klass,
  1.1168 +                                                  Handle recv,
  1.1169 +                                                  KlassHandle recv_klass,
  1.1170 +                                                  bool check_null_and_abstract,
  1.1171 +                                                  TRAPS) {
  1.1172 +
  1.1173 +  // setup default return values
  1.1174 +  int vtable_index = Method::invalid_vtable_index;
  1.1175 +  methodHandle selected_method;
  1.1176 +
  1.1177 +  assert(recv.is_null() || recv->is_oop(), "receiver is not an oop");
  1.1178 +
  1.1179 +  // runtime method resolution
  1.1180 +  if (check_null_and_abstract && recv.is_null()) { // check if receiver exists
  1.1181 +    THROW(vmSymbols::java_lang_NullPointerException());
  1.1182 +  }
  1.1183 +
  1.1184 +  // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s
  1.1185 +  // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since
  1.1186 +  // a missing receiver might result in a bogus lookup.
  1.1187 +  assert(resolved_method->method_holder()->is_linked(), "must be linked");
  1.1188 +
  1.1189 +  // do lookup based on receiver klass using the vtable index
  1.1190 +  if (resolved_method->method_holder()->is_interface()) { // miranda method
  1.1191 +    vtable_index = vtable_index_of_interface_method(resolved_klass,
  1.1192 +                           resolved_method);
  1.1193 +    assert(vtable_index >= 0 , "we should have valid vtable index at this point");
  1.1194 +
  1.1195 +    InstanceKlass* inst = InstanceKlass::cast(recv_klass());
  1.1196 +    selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
  1.1197 +  } else {
  1.1198 +    // at this point we are sure that resolved_method is virtual and not
  1.1199 +    // a miranda method; therefore, it must have a valid vtable index.
  1.1200 +    assert(!resolved_method->has_itable_index(), "");
  1.1201 +    vtable_index = resolved_method->vtable_index();
  1.1202 +    // We could get a negative vtable_index for final methods,
  1.1203 +    // because as an optimization they are they are never put in the vtable,
  1.1204 +    // unless they override an existing method.
  1.1205 +    // If we do get a negative, it means the resolved method is the the selected
  1.1206 +    // method, and it can never be changed by an override.
  1.1207 +    if (vtable_index == Method::nonvirtual_vtable_index) {
  1.1208 +      assert(resolved_method->can_be_statically_bound(), "cannot override this method");
  1.1209 +      selected_method = resolved_method;
  1.1210 +    } else {
  1.1211 +      // recv_klass might be an arrayKlassOop but all vtables start at
  1.1212 +      // the same place. The cast is to avoid virtual call and assertion.
  1.1213 +      InstanceKlass* inst = (InstanceKlass*)recv_klass();
  1.1214 +      selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
  1.1215 +    }
  1.1216 +  }
  1.1217 +
  1.1218 +  // check if method exists
  1.1219 +  if (selected_method.is_null()) {
  1.1220 +    ResourceMark rm(THREAD);
  1.1221 +    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
  1.1222 +              Method::name_and_sig_as_C_string(resolved_klass(),
  1.1223 +                                                      resolved_method->name(),
  1.1224 +                                                      resolved_method->signature()));
  1.1225 +  }
  1.1226 +
  1.1227 +  // check if abstract
  1.1228 +  if (check_null_and_abstract && selected_method->is_abstract()) {
  1.1229 +    ResourceMark rm(THREAD);
  1.1230 +    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
  1.1231 +              Method::name_and_sig_as_C_string(resolved_klass(),
  1.1232 +                                                      selected_method->name(),
  1.1233 +                                                      selected_method->signature()));
  1.1234 +  }
  1.1235 +
  1.1236 +  if (PrintVtables && Verbose) {
  1.1237 +    ResourceMark rm(THREAD);
  1.1238 +    tty->print("invokevirtual selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, vtable_index:%d, access_flags: ",
  1.1239 +                   (recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()),
  1.1240 +                   (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()),
  1.1241 +                   Method::name_and_sig_as_C_string(resolved_klass(),
  1.1242 +                                                    resolved_method->name(),
  1.1243 +                                                    resolved_method->signature()),
  1.1244 +                   selected_method->method_holder()->internal_name(),
  1.1245 +                   vtable_index
  1.1246 +                  );
  1.1247 +    selected_method->access_flags().print_on(tty);
  1.1248 +    if (selected_method->is_default_method()) {
  1.1249 +      tty->print("default ");
  1.1250 +    }
  1.1251 +    if (selected_method->is_overpass()) {
  1.1252 +      tty->print("overpass");
  1.1253 +    }
  1.1254 +    tty->cr();
  1.1255 +  }
  1.1256 +  // setup result
  1.1257 +  result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK);
  1.1258 +}
  1.1259 +
  1.1260 +void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass,
  1.1261 +                                          Symbol* method_name, Symbol* method_signature, KlassHandle current_klass,
  1.1262 +                                          bool check_access, bool check_null_and_abstract, TRAPS) {
  1.1263 +  methodHandle resolved_method;
  1.1264 +  linktime_resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
  1.1265 +  runtime_resolve_interface_method(result, resolved_method, resolved_klass, recv, recv_klass, check_null_and_abstract, CHECK);
  1.1266 +}
  1.1267 +
  1.1268 +// throws linktime exceptions
  1.1269 +void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name,
  1.1270 +                                                     Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
  1.1271 +  // normal interface method resolution
  1.1272 +  resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, true, CHECK);
  1.1273 +
  1.1274 +  assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
  1.1275 +  assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
  1.1276 +}
  1.1277 +
  1.1278 +// throws runtime exceptions
  1.1279 +void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
  1.1280 +                                                    Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS) {
  1.1281 +  // check if receiver exists
  1.1282 +  if (check_null_and_abstract && recv.is_null()) {
  1.1283 +    THROW(vmSymbols::java_lang_NullPointerException());
  1.1284 +  }
  1.1285 +
  1.1286 +  // check if private interface method
  1.1287 +  if (resolved_klass->is_interface() && resolved_method->is_private()) {
  1.1288 +    ResourceMark rm(THREAD);
  1.1289 +    char buf[200];
  1.1290 +    jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s",
  1.1291 +                 Method::name_and_sig_as_C_string(resolved_klass(),
  1.1292 +                                                  resolved_method->name(),
  1.1293 +                                                  resolved_method->signature()));
  1.1294 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
  1.1295 +  }
  1.1296 +
  1.1297 +  // check if receiver klass implements the resolved interface
  1.1298 +  if (!recv_klass->is_subtype_of(resolved_klass())) {
  1.1299 +    ResourceMark rm(THREAD);
  1.1300 +    char buf[200];
  1.1301 +    jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",
  1.1302 +                 recv_klass()->external_name(),
  1.1303 +                 resolved_klass()->external_name());
  1.1304 +    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
  1.1305 +  }
  1.1306 +
  1.1307 +  // do lookup based on receiver klass
  1.1308 +  methodHandle sel_method;
  1.1309 +  // This search must match the linktime preparation search for itable initialization
  1.1310 +  // to correctly enforce loader constraints for interface method inheritance
  1.1311 +  lookup_instance_method_in_klasses(sel_method, recv_klass,
  1.1312 +            resolved_method->name(),
  1.1313 +            resolved_method->signature(), CHECK);
  1.1314 +  if (sel_method.is_null() && !check_null_and_abstract) {
  1.1315 +    // In theory this is a harmless placeholder value, but
  1.1316 +    // in practice leaving in null affects the nsk default method tests.
  1.1317 +    // This needs further study.
  1.1318 +    sel_method = resolved_method;
  1.1319 +  }
  1.1320 +  // check if method exists
  1.1321 +  if (sel_method.is_null()) {
  1.1322 +    ResourceMark rm(THREAD);
  1.1323 +    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
  1.1324 +              Method::name_and_sig_as_C_string(recv_klass(),
  1.1325 +                                                      resolved_method->name(),
  1.1326 +                                                      resolved_method->signature()));
  1.1327 +  }
  1.1328 +  // check access
  1.1329 +  // Throw Illegal Access Error if sel_method is not public.
  1.1330 +  if (!sel_method->is_public()) {
  1.1331 +    ResourceMark rm(THREAD);
  1.1332 +    THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
  1.1333 +              Method::name_and_sig_as_C_string(recv_klass(),
  1.1334 +                                               sel_method->name(),
  1.1335 +                                               sel_method->signature()));
  1.1336 +  }
  1.1337 +  // check if abstract
  1.1338 +  if (check_null_and_abstract && sel_method->is_abstract()) {
  1.1339 +    ResourceMark rm(THREAD);
  1.1340 +    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
  1.1341 +              Method::name_and_sig_as_C_string(recv_klass(),
  1.1342 +                                                      sel_method->name(),
  1.1343 +                                                      sel_method->signature()));
  1.1344 +  }
  1.1345 +
  1.1346 +  if (TraceItables && Verbose) {
  1.1347 +    ResourceMark rm(THREAD);
  1.1348 +    tty->print("invokeinterface selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, access_flags: ",
  1.1349 +                   (recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()),
  1.1350 +                   (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()),
  1.1351 +                   Method::name_and_sig_as_C_string(resolved_klass(),
  1.1352 +                                                    resolved_method->name(),
  1.1353 +                                                    resolved_method->signature()),
  1.1354 +                   sel_method->method_holder()->internal_name()
  1.1355 +                  );
  1.1356 +    sel_method->access_flags().print_on(tty);
  1.1357 +    if (sel_method->is_default_method()) {
  1.1358 +      tty->print("default ");
  1.1359 +    }
  1.1360 +    if (sel_method->is_overpass()) {
  1.1361 +      tty->print("overpass");
  1.1362 +    }
  1.1363 +    tty->cr();
  1.1364 +  }
  1.1365 +  // setup result
  1.1366 +  if (!resolved_method->has_itable_index()) {
  1.1367 +    int vtable_index = resolved_method->vtable_index();
  1.1368 +    assert(vtable_index == sel_method->vtable_index(), "sanity check");
  1.1369 +    result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK);
  1.1370 +  } else {
  1.1371 +    int itable_index = resolved_method()->itable_index();
  1.1372 +    result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK);
  1.1373 +  }
  1.1374 +}
  1.1375 +
  1.1376 +
  1.1377 +methodHandle LinkResolver::linktime_resolve_interface_method_or_null(
  1.1378 +                                                 KlassHandle resolved_klass,
  1.1379 +                                                 Symbol* method_name,
  1.1380 +                                                 Symbol* method_signature,
  1.1381 +                                                 KlassHandle current_klass,
  1.1382 +                                                 bool check_access) {
  1.1383 +  EXCEPTION_MARK;
  1.1384 +  methodHandle method_result;
  1.1385 +  linktime_resolve_interface_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD);
  1.1386 +  if (HAS_PENDING_EXCEPTION) {
  1.1387 +    CLEAR_PENDING_EXCEPTION;
  1.1388 +    return methodHandle();
  1.1389 +  } else {
  1.1390 +    return method_result;
  1.1391 +  }
  1.1392 +}
  1.1393 +
  1.1394 +methodHandle LinkResolver::linktime_resolve_virtual_method_or_null(
  1.1395 +                                                 KlassHandle resolved_klass,
  1.1396 +                                                 Symbol* method_name,
  1.1397 +                                                 Symbol* method_signature,
  1.1398 +                                                 KlassHandle current_klass,
  1.1399 +                                                 bool check_access) {
  1.1400 +  EXCEPTION_MARK;
  1.1401 +  methodHandle method_result;
  1.1402 +  linktime_resolve_virtual_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD);
  1.1403 +  if (HAS_PENDING_EXCEPTION) {
  1.1404 +    CLEAR_PENDING_EXCEPTION;
  1.1405 +    return methodHandle();
  1.1406 +  } else {
  1.1407 +    return method_result;
  1.1408 +  }
  1.1409 +}
  1.1410 +
  1.1411 +methodHandle LinkResolver::resolve_virtual_call_or_null(
  1.1412 +                                                 KlassHandle receiver_klass,
  1.1413 +                                                 KlassHandle resolved_klass,
  1.1414 +                                                 Symbol* name,
  1.1415 +                                                 Symbol* signature,
  1.1416 +                                                 KlassHandle current_klass) {
  1.1417 +  EXCEPTION_MARK;
  1.1418 +  CallInfo info;
  1.1419 +  resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
  1.1420 +  if (HAS_PENDING_EXCEPTION) {
  1.1421 +    CLEAR_PENDING_EXCEPTION;
  1.1422 +    return methodHandle();
  1.1423 +  }
  1.1424 +  return info.selected_method();
  1.1425 +}
  1.1426 +
  1.1427 +methodHandle LinkResolver::resolve_interface_call_or_null(
  1.1428 +                                                 KlassHandle receiver_klass,
  1.1429 +                                                 KlassHandle resolved_klass,
  1.1430 +                                                 Symbol* name,
  1.1431 +                                                 Symbol* signature,
  1.1432 +                                                 KlassHandle current_klass) {
  1.1433 +  EXCEPTION_MARK;
  1.1434 +  CallInfo info;
  1.1435 +  resolve_interface_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
  1.1436 +  if (HAS_PENDING_EXCEPTION) {
  1.1437 +    CLEAR_PENDING_EXCEPTION;
  1.1438 +    return methodHandle();
  1.1439 +  }
  1.1440 +  return info.selected_method();
  1.1441 +}
  1.1442 +
  1.1443 +int LinkResolver::resolve_virtual_vtable_index(
  1.1444 +                                               KlassHandle receiver_klass,
  1.1445 +                                               KlassHandle resolved_klass,
  1.1446 +                                               Symbol* name,
  1.1447 +                                               Symbol* signature,
  1.1448 +                                               KlassHandle current_klass) {
  1.1449 +  EXCEPTION_MARK;
  1.1450 +  CallInfo info;
  1.1451 +  resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
  1.1452 +  if (HAS_PENDING_EXCEPTION) {
  1.1453 +    CLEAR_PENDING_EXCEPTION;
  1.1454 +    return Method::invalid_vtable_index;
  1.1455 +  }
  1.1456 +  return info.vtable_index();
  1.1457 +}
  1.1458 +
  1.1459 +methodHandle LinkResolver::resolve_static_call_or_null(
  1.1460 +                                                  KlassHandle resolved_klass,
  1.1461 +                                                  Symbol* name,
  1.1462 +                                                  Symbol* signature,
  1.1463 +                                                  KlassHandle current_klass) {
  1.1464 +  EXCEPTION_MARK;
  1.1465 +  CallInfo info;
  1.1466 +  resolve_static_call(info, resolved_klass, name, signature, current_klass, true, false, THREAD);
  1.1467 +  if (HAS_PENDING_EXCEPTION) {
  1.1468 +    CLEAR_PENDING_EXCEPTION;
  1.1469 +    return methodHandle();
  1.1470 +  }
  1.1471 +  return info.selected_method();
  1.1472 +}
  1.1473 +
  1.1474 +methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, Symbol* name, Symbol* signature,
  1.1475 +                                                        KlassHandle current_klass) {
  1.1476 +  EXCEPTION_MARK;
  1.1477 +  CallInfo info;
  1.1478 +  resolve_special_call(info, resolved_klass, name, signature, current_klass, true, THREAD);
  1.1479 +  if (HAS_PENDING_EXCEPTION) {
  1.1480 +    CLEAR_PENDING_EXCEPTION;
  1.1481 +    return methodHandle();
  1.1482 +  }
  1.1483 +  return info.selected_method();
  1.1484 +}
  1.1485 +
  1.1486 +
  1.1487 +
  1.1488 +//------------------------------------------------------------------------------------------------------------------------
  1.1489 +// ConstantPool entries
  1.1490 +
  1.1491 +void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) {
  1.1492 +  switch (byte) {
  1.1493 +    case Bytecodes::_invokestatic   : resolve_invokestatic   (result,       pool, index, CHECK); break;
  1.1494 +    case Bytecodes::_invokespecial  : resolve_invokespecial  (result,       pool, index, CHECK); break;
  1.1495 +    case Bytecodes::_invokevirtual  : resolve_invokevirtual  (result, recv, pool, index, CHECK); break;
  1.1496 +    case Bytecodes::_invokehandle   : resolve_invokehandle   (result,       pool, index, CHECK); break;
  1.1497 +    case Bytecodes::_invokedynamic  : resolve_invokedynamic  (result,       pool, index, CHECK); break;
  1.1498 +    case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break;
  1.1499 +  }
  1.1500 +  return;
  1.1501 +}
  1.1502 +
  1.1503 +void LinkResolver::resolve_pool(KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature,
  1.1504 +                                KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS) {
  1.1505 +   // resolve klass
  1.1506 +  resolve_klass(resolved_klass, pool, index, CHECK);
  1.1507 +
  1.1508 +  // Get name, signature, and static klass
  1.1509 +  method_name      = pool->name_ref_at(index);
  1.1510 +  method_signature = pool->signature_ref_at(index);
  1.1511 +  current_klass    = KlassHandle(THREAD, pool->pool_holder());
  1.1512 +}
  1.1513 +
  1.1514 +
  1.1515 +void LinkResolver::resolve_invokestatic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
  1.1516 +  KlassHandle  resolved_klass;
  1.1517 +  Symbol* method_name = NULL;
  1.1518 +  Symbol* method_signature = NULL;
  1.1519 +  KlassHandle  current_klass;
  1.1520 +  resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
  1.1521 +  resolve_static_call(result, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
  1.1522 +}
  1.1523 +
  1.1524 +
  1.1525 +void LinkResolver::resolve_invokespecial(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
  1.1526 +  KlassHandle  resolved_klass;
  1.1527 +  Symbol* method_name = NULL;
  1.1528 +  Symbol* method_signature = NULL;
  1.1529 +  KlassHandle  current_klass;
  1.1530 +  resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
  1.1531 +  resolve_special_call(result, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
  1.1532 +}
  1.1533 +
  1.1534 +
  1.1535 +void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv,
  1.1536 +                                          constantPoolHandle pool, int index,
  1.1537 +                                          TRAPS) {
  1.1538 +
  1.1539 +  KlassHandle  resolved_klass;
  1.1540 +  Symbol* method_name = NULL;
  1.1541 +  Symbol* method_signature = NULL;
  1.1542 +  KlassHandle  current_klass;
  1.1543 +  resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
  1.1544 +  KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass());
  1.1545 +  resolve_virtual_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
  1.1546 +}
  1.1547 +
  1.1548 +
  1.1549 +void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) {
  1.1550 +  KlassHandle  resolved_klass;
  1.1551 +  Symbol* method_name = NULL;
  1.1552 +  Symbol* method_signature = NULL;
  1.1553 +  KlassHandle  current_klass;
  1.1554 +  resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
  1.1555 +  KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass());
  1.1556 +  resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
  1.1557 +}
  1.1558 +
  1.1559 +
  1.1560 +void LinkResolver::resolve_invokehandle(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
  1.1561 +  assert(EnableInvokeDynamic, "");
  1.1562 +  // This guy is reached from InterpreterRuntime::resolve_invokehandle.
  1.1563 +  KlassHandle  resolved_klass;
  1.1564 +  Symbol* method_name = NULL;
  1.1565 +  Symbol* method_signature = NULL;
  1.1566 +  KlassHandle  current_klass;
  1.1567 +  resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
  1.1568 +  if (TraceMethodHandles) {
  1.1569 +    ResourceMark rm(THREAD);
  1.1570 +    tty->print_cr("resolve_invokehandle %s %s", method_name->as_C_string(), method_signature->as_C_string());
  1.1571 +  }
  1.1572 +  resolve_handle_call(result, resolved_klass, method_name, method_signature, current_klass, CHECK);
  1.1573 +}
  1.1574 +
  1.1575 +void LinkResolver::resolve_handle_call(CallInfo& result, KlassHandle resolved_klass,
  1.1576 +                                       Symbol* method_name, Symbol* method_signature,
  1.1577 +                                       KlassHandle current_klass,
  1.1578 +                                       TRAPS) {
  1.1579 +  // JSR 292:  this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar
  1.1580 +  assert(resolved_klass() == SystemDictionary::MethodHandle_klass(), "");
  1.1581 +  assert(MethodHandles::is_signature_polymorphic_name(method_name), "");
  1.1582 +  methodHandle resolved_method;
  1.1583 +  Handle       resolved_appendix;
  1.1584 +  Handle       resolved_method_type;
  1.1585 +  lookup_polymorphic_method(resolved_method, resolved_klass,
  1.1586 +                            method_name, method_signature,
  1.1587 +                            current_klass, &resolved_appendix, &resolved_method_type, CHECK);
  1.1588 +  result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK);
  1.1589 +}
  1.1590 +
  1.1591 +
  1.1592 +void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
  1.1593 +  assert(EnableInvokeDynamic, "");
  1.1594 +
  1.1595 +  //resolve_pool(<resolved_klass>, method_name, method_signature, current_klass, pool, index, CHECK);
  1.1596 +  Symbol* method_name       = pool->name_ref_at(index);
  1.1597 +  Symbol* method_signature  = pool->signature_ref_at(index);
  1.1598 +  KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder());
  1.1599 +
  1.1600 +  // Resolve the bootstrap specifier (BSM + optional arguments).
  1.1601 +  Handle bootstrap_specifier;
  1.1602 +  // Check if CallSite has been bound already:
  1.1603 +  ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index);
  1.1604 +  if (cpce->is_f1_null()) {
  1.1605 +    int pool_index = cpce->constant_pool_index();
  1.1606 +    oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, CHECK);
  1.1607 +    assert(bsm_info != NULL, "");
  1.1608 +    // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic.
  1.1609 +    bootstrap_specifier = Handle(THREAD, bsm_info);
  1.1610 +  }
  1.1611 +  if (!cpce->is_f1_null()) {
  1.1612 +    methodHandle method(     THREAD, cpce->f1_as_method());
  1.1613 +    Handle       appendix(   THREAD, cpce->appendix_if_resolved(pool));
  1.1614 +    Handle       method_type(THREAD, cpce->method_type_if_resolved(pool));
  1.1615 +    result.set_handle(method, appendix, method_type, CHECK);
  1.1616 +    return;
  1.1617 +  }
  1.1618 +
  1.1619 +  if (TraceMethodHandles) {
  1.1620 +      ResourceMark rm(THREAD);
  1.1621 +      tty->print_cr("resolve_invokedynamic #%d %s %s",
  1.1622 +                  ConstantPool::decode_invokedynamic_index(index),
  1.1623 +                  method_name->as_C_string(), method_signature->as_C_string());
  1.1624 +    tty->print("  BSM info: "); bootstrap_specifier->print();
  1.1625 +  }
  1.1626 +
  1.1627 +  resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK);
  1.1628 +}
  1.1629 +
  1.1630 +void LinkResolver::resolve_dynamic_call(CallInfo& result,
  1.1631 +                                        Handle bootstrap_specifier,
  1.1632 +                                        Symbol* method_name, Symbol* method_signature,
  1.1633 +                                        KlassHandle current_klass,
  1.1634 +                                        TRAPS) {
  1.1635 +  // JSR 292:  this must resolve to an implicitly generated method MH.linkToCallSite(*...)
  1.1636 +  // The appendix argument is likely to be a freshly-created CallSite.
  1.1637 +  Handle       resolved_appendix;
  1.1638 +  Handle       resolved_method_type;
  1.1639 +  methodHandle resolved_method =
  1.1640 +    SystemDictionary::find_dynamic_call_site_invoker(current_klass,
  1.1641 +                                                     bootstrap_specifier,
  1.1642 +                                                     method_name, method_signature,
  1.1643 +                                                     &resolved_appendix,
  1.1644 +                                                     &resolved_method_type,
  1.1645 +                                                     THREAD);
  1.1646 +  if (HAS_PENDING_EXCEPTION) {
  1.1647 +    if (TraceMethodHandles) {
  1.1648 +      tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION));
  1.1649 +      PENDING_EXCEPTION->print();
  1.1650 +    }
  1.1651 +    if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) {
  1.1652 +      // throw these guys, since they are already wrapped
  1.1653 +      return;
  1.1654 +    }
  1.1655 +    if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {
  1.1656 +      // intercept only LinkageErrors which might have failed to wrap
  1.1657 +      return;
  1.1658 +    }
  1.1659 +    // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS.
  1.1660 +    Handle nested_exception(THREAD, PENDING_EXCEPTION);
  1.1661 +    CLEAR_PENDING_EXCEPTION;
  1.1662 +    THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception)
  1.1663 +  }
  1.1664 +  result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK);
  1.1665 +}
  1.1666 +
  1.1667 +//------------------------------------------------------------------------------------------------------------------------
  1.1668 +#ifndef PRODUCT
  1.1669 +
  1.1670 +void CallInfo::print() {
  1.1671 +  ResourceMark rm;
  1.1672 +  const char* kindstr = "unknown";
  1.1673 +  switch (_call_kind) {
  1.1674 +  case direct_call: kindstr = "direct"; break;
  1.1675 +  case vtable_call: kindstr = "vtable"; break;
  1.1676 +  case itable_call: kindstr = "itable"; break;
  1.1677 +  }
  1.1678 +  tty->print_cr("Call %s@%d %s", kindstr, _call_index,
  1.1679 +                _resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string());
  1.1680 +}
  1.1681 +
  1.1682 +#endif

mercurial