< prev index next >

src/hotspot/share/oops/constantPool.cpp

Print this page




 983 
 984   case JVM_CONSTANT_MethodHandle:
 985     {
 986       int ref_kind                 = this_cp->method_handle_ref_kind_at(index);
 987       int callee_index             = this_cp->method_handle_klass_index_at(index);
 988       Symbol*  name =      this_cp->method_handle_name_ref_at(index);
 989       Symbol*  signature = this_cp->method_handle_signature_ref_at(index);
 990       constantTag m_tag  = this_cp->tag_at(this_cp->method_handle_index_at(index));
 991       { ResourceMark rm(THREAD);
 992         log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
 993                               ref_kind, index, this_cp->method_handle_index_at(index),
 994                               callee_index, name->as_C_string(), signature->as_C_string());
 995       }
 996 
 997       Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL);
 998 
 999       // Check constant pool method consistency
1000       if ((callee->is_interface() && m_tag.is_method()) ||
1001           ((!callee->is_interface() && m_tag.is_interface_method()))) {
1002         ResourceMark rm(THREAD);
1003         stringStream ss;
1004         ss.print("Inconsistent constant pool data in classfile for class %s. "
1005                  "Method '", callee->name()->as_C_string());
1006         signature->print_as_signature_external_return_type(&ss);
1007         ss.print(" %s(", name->as_C_string());
1008         signature->print_as_signature_external_parameters(&ss);
1009         ss.print(")' at index %d is %s and should be %s",
1010                  index,
1011                  callee->is_interface() ? "CONSTANT_MethodRef" : "CONSTANT_InterfaceMethodRef",
1012                  callee->is_interface() ? "CONSTANT_InterfaceMethodRef" : "CONSTANT_MethodRef");
1013         THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
1014       }
1015 
1016       Klass* klass = this_cp->pool_holder();
1017       Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind,
1018                                                                    callee, name, signature,
1019                                                                    THREAD);
1020       result_oop = value();
1021       if (HAS_PENDING_EXCEPTION) {
1022         save_and_throw_exception(this_cp, index, tag, CHECK_NULL);
1023       }
1024       break;
1025     }
1026 
1027   case JVM_CONSTANT_MethodType:
1028     {
1029       Symbol*  signature = this_cp->method_type_signature_at(index);
1030       { ResourceMark rm(THREAD);
1031         log_debug(class, resolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s",
1032                               index, this_cp->method_type_index_at(index),
1033                               signature->as_C_string());




 983 
 984   case JVM_CONSTANT_MethodHandle:
 985     {
 986       int ref_kind                 = this_cp->method_handle_ref_kind_at(index);
 987       int callee_index             = this_cp->method_handle_klass_index_at(index);
 988       Symbol*  name =      this_cp->method_handle_name_ref_at(index);
 989       Symbol*  signature = this_cp->method_handle_signature_ref_at(index);
 990       constantTag m_tag  = this_cp->tag_at(this_cp->method_handle_index_at(index));
 991       { ResourceMark rm(THREAD);
 992         log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
 993                               ref_kind, index, this_cp->method_handle_index_at(index),
 994                               callee_index, name->as_C_string(), signature->as_C_string());
 995       }
 996 
 997       Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL);
 998 
 999       // Check constant pool method consistency
1000       if ((callee->is_interface() && m_tag.is_method()) ||
1001           ((!callee->is_interface() && m_tag.is_interface_method()))) {
1002         ResourceMark rm(THREAD);
1003         char buf[400];
1004         jio_snprintf(buf, sizeof(buf),
1005           "Inconsistent constant pool data in classfile for class %s. "
1006           "Method %s%s at index %d is %s and should be %s",
1007           callee->name()->as_C_string(), name->as_C_string(), signature->as_C_string(), index,
1008           callee->is_interface() ? "CONSTANT_MethodRef" : "CONSTANT_InterfaceMethodRef",
1009           callee->is_interface() ? "CONSTANT_InterfaceMethodRef" : "CONSTANT_MethodRef");
1010         THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);



1011       }
1012 
1013       Klass* klass = this_cp->pool_holder();
1014       Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind,
1015                                                                    callee, name, signature,
1016                                                                    THREAD);
1017       result_oop = value();
1018       if (HAS_PENDING_EXCEPTION) {
1019         save_and_throw_exception(this_cp, index, tag, CHECK_NULL);
1020       }
1021       break;
1022     }
1023 
1024   case JVM_CONSTANT_MethodType:
1025     {
1026       Symbol*  signature = this_cp->method_type_signature_at(index);
1027       { ResourceMark rm(THREAD);
1028         log_debug(class, resolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s",
1029                               index, this_cp->method_type_index_at(index),
1030                               signature->as_C_string());


< prev index next >