< prev index next >

src/hotspot/share/interpreter/linkResolver.cpp

Print this page




 801     st = &lsi;
 802   } else {
 803     st = &lsv;
 804   }
 805   st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
 806             prefix,
 807             (klass == NULL ? "<NULL>" : klass->internal_name()),
 808             (resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()),
 809             Method::name_and_sig_as_C_string(resolved_klass,
 810                                              method->name(),
 811                                              method->signature()),
 812             method->method_holder()->internal_name());
 813   method->print_linkage_flags(st);
 814   if (index != -1) {
 815     st->print("vtable_index:%d", index);
 816   }
 817   st->cr();
 818 #endif // PRODUCT
 819 }
 820 
 821 // FIXME: update to correct version
 822 #define VIRTUAL_PRIVATE_ACCESS_VERSION 53
 823 
 824 // Do linktime resolution of a method in the interface within the context of the specied bytecode.
 825 methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) {
 826 
 827   Klass* resolved_klass = link_info.resolved_klass();
 828 
 829   // check if klass is interface
 830   if (!resolved_klass->is_interface()) {
 831     ResourceMark rm(THREAD);
 832     char buf[200];
 833     jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass->external_name());
 834     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 835   }
 836 
 837   // check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref
 838   if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {
 839     ResourceMark rm(THREAD);
 840     char buf[200];
 841     jio_snprintf(buf, sizeof(buf), "Method %s must be InterfaceMethodref constant", link_info.method_string());
 842     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 843   }


 866 
 867     assert(current_klass != NULL , "current_klass should not be null");
 868 
 869     // check if method can be accessed by the referring class
 870     check_method_accessability(current_klass,
 871                                resolved_klass,
 872                                resolved_method->method_holder(),
 873                                resolved_method,
 874                                CHECK_NULL);
 875 
 876     check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL);
 877   }
 878 
 879   if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {
 880     ResourceMark rm(THREAD);
 881     char buf[200];
 882     jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
 883                  Method::name_and_sig_as_C_string(resolved_klass,
 884                  resolved_method->name(), resolved_method->signature()));
 885     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 886   }
 887 
 888   if (code == Bytecodes::_invokeinterface && resolved_method->is_private()) {
 889     Klass* current_klass = link_info.current_klass();
 890     assert(current_klass != NULL, "current_klass should not be null for invokeinterface");
 891     if (InstanceKlass::cast(current_klass)->major_version() < VIRTUAL_PRIVATE_ACCESS_VERSION) {
 892       ResourceMark rm(THREAD);
 893       char buf[200];
 894       jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s, caller-class:%s",
 895                    Method::name_and_sig_as_C_string(resolved_klass,
 896                                                     resolved_method->name(),
 897                                                     resolved_method->signature()),
 898                    current_klass->internal_name());
 899       THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 900     }
 901   }
 902 
 903   if (log_develop_is_enabled(Trace, itables)) {
 904     char buf[200];
 905     jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:",
 906                  Bytecodes::name(code));
 907     trace_method_resolution(buf, link_info.current_klass(), resolved_klass,
 908                             resolved_method, true);
 909   }
 910 
 911   return resolved_method;
 912 }
 913 
 914 //------------------------------------------------------------------------------------------------------------------------
 915 // Field resolution
 916 
 917 void LinkResolver::check_field_accessability(Klass* ref_klass,
 918                                              Klass* resolved_klass,
 919                                              Klass* sel_klass,
 920                                              const fieldDescriptor& fd,




 801     st = &lsi;
 802   } else {
 803     st = &lsv;
 804   }
 805   st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
 806             prefix,
 807             (klass == NULL ? "<NULL>" : klass->internal_name()),
 808             (resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()),
 809             Method::name_and_sig_as_C_string(resolved_klass,
 810                                              method->name(),
 811                                              method->signature()),
 812             method->method_holder()->internal_name());
 813   method->print_linkage_flags(st);
 814   if (index != -1) {
 815     st->print("vtable_index:%d", index);
 816   }
 817   st->cr();
 818 #endif // PRODUCT
 819 }
 820 



 821 // Do linktime resolution of a method in the interface within the context of the specied bytecode.
 822 methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) {
 823 
 824   Klass* resolved_klass = link_info.resolved_klass();
 825 
 826   // check if klass is interface
 827   if (!resolved_klass->is_interface()) {
 828     ResourceMark rm(THREAD);
 829     char buf[200];
 830     jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass->external_name());
 831     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 832   }
 833 
 834   // check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref
 835   if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {
 836     ResourceMark rm(THREAD);
 837     char buf[200];
 838     jio_snprintf(buf, sizeof(buf), "Method %s must be InterfaceMethodref constant", link_info.method_string());
 839     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
 840   }


 863 
 864     assert(current_klass != NULL , "current_klass should not be null");
 865 
 866     // check if method can be accessed by the referring class
 867     check_method_accessability(current_klass,
 868                                resolved_klass,
 869                                resolved_method->method_holder(),
 870                                resolved_method,
 871                                CHECK_NULL);
 872 
 873     check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL);
 874   }
 875 
 876   if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {
 877     ResourceMark rm(THREAD);
 878     char buf[200];
 879     jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
 880                  Method::name_and_sig_as_C_string(resolved_klass,
 881                  resolved_method->name(), resolved_method->signature()));
 882     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);















 883   }
 884 
 885   if (log_develop_is_enabled(Trace, itables)) {
 886     char buf[200];
 887     jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:",
 888                  Bytecodes::name(code));
 889     trace_method_resolution(buf, link_info.current_klass(), resolved_klass,
 890                             resolved_method, true);
 891   }
 892 
 893   return resolved_method;
 894 }
 895 
 896 //------------------------------------------------------------------------------------------------------------------------
 897 // Field resolution
 898 
 899 void LinkResolver::check_field_accessability(Klass* ref_klass,
 900                                              Klass* resolved_klass,
 901                                              Klass* sel_klass,
 902                                              const fieldDescriptor& fd,


< prev index next >