< prev index next >

src/hotspot/share/interpreter/linkResolver.cpp

Print this page




 571   // We'll check for the method name first, as that's most likely
 572   // to be false (so we'll short-circuit out of these tests).
 573   if (sel_method->name() == vmSymbols::clone_name() &&
 574       sel_klass == SystemDictionary::Object_klass() &&
 575       resolved_klass->is_array_klass()) {
 576     // We need to change "protected" to "public".
 577     assert(flags.is_protected(), "clone not protected?");
 578     jint new_flags = flags.as_int();
 579     new_flags = new_flags & (~JVM_ACC_PROTECTED);
 580     new_flags = new_flags | JVM_ACC_PUBLIC;
 581     flags.set_flags(new_flags);
 582   }
 583 //  assert(extra_arg_result_or_null != NULL, "must be able to return extra argument");
 584 
 585   if (!Reflection::verify_field_access(ref_klass,
 586                                        resolved_klass,
 587                                        sel_klass,
 588                                        flags,
 589                                        true)) {
 590     ResourceMark rm(THREAD);

 591     Exceptions::fthrow(
 592       THREAD_AND_LOCATION,
 593       vmSymbols::java_lang_IllegalAccessError(),
 594       "tried to access method %s.%s%s from class %s",

 595       sel_klass->external_name(),
 596       sel_method->name()->as_C_string(),
 597       sel_method->signature()->as_C_string(),
 598       ref_klass->external_name()


 599     );
 600     return;
 601   }
 602 }
 603 
 604 methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code,
 605                                                      const constantPoolHandle& pool, int index, TRAPS) {
 606   // This method is used only
 607   // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
 608   // and
 609   // (2) in Bytecode_invoke::static_target
 610   // It appears to fail when applied to an invokeinterface call site.
 611   // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
 612   // resolve klass
 613   if (code == Bytecodes::_invokedynamic) {
 614     Klass* resolved_klass = SystemDictionary::MethodHandle_klass();
 615     Symbol* method_name = vmSymbols::invoke_name();
 616     Symbol* method_signature = pool->signature_ref_at(index);
 617     Klass*  current_klass = pool->pool_holder();
 618     LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);




 571   // We'll check for the method name first, as that's most likely
 572   // to be false (so we'll short-circuit out of these tests).
 573   if (sel_method->name() == vmSymbols::clone_name() &&
 574       sel_klass == SystemDictionary::Object_klass() &&
 575       resolved_klass->is_array_klass()) {
 576     // We need to change "protected" to "public".
 577     assert(flags.is_protected(), "clone not protected?");
 578     jint new_flags = flags.as_int();
 579     new_flags = new_flags & (~JVM_ACC_PROTECTED);
 580     new_flags = new_flags | JVM_ACC_PUBLIC;
 581     flags.set_flags(new_flags);
 582   }
 583 //  assert(extra_arg_result_or_null != NULL, "must be able to return extra argument");
 584 
 585   if (!Reflection::verify_field_access(ref_klass,
 586                                        resolved_klass,
 587                                        sel_klass,
 588                                        flags,
 589                                        true)) {
 590     ResourceMark rm(THREAD);
 591     bool same_module = (sel_klass->module() == ref_klass->module());
 592     Exceptions::fthrow(
 593       THREAD_AND_LOCATION,
 594       vmSymbols::java_lang_IllegalAccessError(),
 595       "class %s tried to access method %s.%s%s (%s%s%s)",
 596       ref_klass->external_name(),
 597       sel_klass->external_name(),
 598       sel_method->name()->as_C_string(),
 599       sel_method->signature()->as_C_string(),
 600       (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
 601       (same_module) ? "" : "; ",
 602       (same_module) ? "" : sel_klass->class_in_module_of_loader()
 603     );
 604     return;
 605   }
 606 }
 607 
 608 methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code,
 609                                                      const constantPoolHandle& pool, int index, TRAPS) {
 610   // This method is used only
 611   // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
 612   // and
 613   // (2) in Bytecode_invoke::static_target
 614   // It appears to fail when applied to an invokeinterface call site.
 615   // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
 616   // resolve klass
 617   if (code == Bytecodes::_invokedynamic) {
 618     Klass* resolved_klass = SystemDictionary::MethodHandle_klass();
 619     Symbol* method_name = vmSymbols::invoke_name();
 620     Symbol* method_signature = pool->signature_ref_at(index);
 621     Klass*  current_klass = pool->pool_holder();
 622     LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);


< prev index next >