< prev index next >

src/hotspot/share/interpreter/linkResolver.cpp

Print this page

        

@@ -262,10 +262,14 @@
 
   // Coming from the constant pool always checks access
   _check_access  = true;
 }
 
+char* LinkInfo::method_string() const {
+  return Method::name_and_sig_as_C_string(_resolved_klass, _name, _signature);
+}
+
 #ifndef PRODUCT
 void LinkInfo::print() {
   ResourceMark rm;
   tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s",
                 _resolved_klass->name()->as_C_string(),

@@ -587,16 +591,18 @@
     ResourceMark rm(THREAD);
     bool same_module = (sel_klass->module() == ref_klass->module());
     Exceptions::fthrow(
       THREAD_AND_LOCATION,
       vmSymbols::java_lang_IllegalAccessError(),
-      "class %s tried to access %s%s%smethod '%s' (%s%s%s)",
+      "class %s tried to access %s%s%smethod %s.%s%s (%s%s%s)",
       ref_klass->external_name(),
       sel_method->is_abstract()  ? "abstract "  : "",
       sel_method->is_protected() ? "protected " : "",
       sel_method->is_private()   ? "private "   : "",
-      sel_method->external_name(),
+      sel_klass->external_name(),
+      sel_method->name()->as_C_string(),
+      sel_method->signature()->as_C_string(),
       (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
       (same_module) ? "" : "; ",
       (same_module) ? "" : sel_klass->class_in_module_of_loader()
     );
     return;

@@ -662,15 +668,16 @@
     Klass* resolved_method_class = resolved_method->method_holder();
     ClassLoaderData* target_loader_data = resolved_method_class->class_loader_data();
     assert(target_loader_data != NULL, "resolved method's class has no class loader data");
 
     stringStream ss;
-    ss.print("loader constraint violation: when resolving %s '", method_type);
-    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());
-    ss.print("' the class loader %s of the current class, %s,"
+    ss.print("loader constraint violation: when resolving %s"
+             " \"%s\" the class loader %s of the current class, %s,"
              " and the class loader %s for the method's defining class, %s, have"
              " different Class objects for the type %s used in the signature (%s; %s)",
+             method_type,
+             link_info.method_string(),
              current_loader_data->loader_name_and_id(),
              current_class->name()->as_C_string(),
              target_loader_data->loader_name_and_id(),
              resolved_method_class->name()->as_C_string(),
              failed_type_symbol->as_C_string(),

@@ -730,15 +737,13 @@
   }
 
   // 2. check constant pool tag for called method - must be JVM_CONSTANT_Methodref
   if (!link_info.tag().is_invalid() && !link_info.tag().is_method()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Method '");
-    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());
-    ss.print("' must be Methodref constant");
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Method %s must be Methodref constant", link_info.method_string());
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   // 3. lookup method in resolved klass and its super klasses
   methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, true, false));
 

@@ -757,16 +762,15 @@
   }
 
   // 5. method lookup failed
   if (resolved_method.is_null()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("'");
-    Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());
-    ss.print("'");
     THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(),
-                     ss.as_string(), nested_exception, NULL);
+                    Method::name_and_sig_as_C_string(resolved_klass,
+                                                     link_info.name(),
+                                                     link_info.signature()),
+                    nested_exception, NULL);
   }
 
   // 6. access checks, access checking may be turned off when calling from within the VM.
   Klass* current_klass = link_info.current_klass();
   if (link_info.check_access()) {

@@ -834,15 +838,13 @@
   }
 
   // check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref
   if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Method '");
-    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());
-    ss.print("' must be InterfaceMethodref constant");
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Method %s must be InterfaceMethodref constant", link_info.method_string());
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   // lookup method in this interface or its super, java.lang.Object
   // JDK8: also look for static methods
   methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true));

@@ -853,15 +855,14 @@
   }
 
   if (resolved_method.is_null()) {
     // no method found
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("'");
-    Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());
-    ss.print("'");
-    THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), ss.as_string());
+    THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(),
+                   Method::name_and_sig_as_C_string(resolved_klass,
+                                                    link_info.name(),
+                                                    link_info.signature()));
   }
 
   if (link_info.check_access()) {
     // JDK8 adds non-public interface methods, and accessability check requirement
     Klass* current_klass = link_info.current_klass();

@@ -878,16 +879,15 @@
     check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL);
   }
 
   if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Expected instance not static method '");
-    Method::print_external_name(&ss, resolved_klass,
-                                resolved_method->name(), resolved_method->signature());
-    ss.print("'");
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
+                 Method::name_and_sig_as_C_string(resolved_klass,
+                 resolved_method->name(), resolved_method->signature()));
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   if (log_develop_is_enabled(Trace, itables)) {
     char buf[200];
     jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:",

@@ -1084,15 +1084,15 @@
   assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier");
 
   // check if static
   if (!resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Expected static method '");
-    resolved_method()->print_external_name(&ss);
-    ss.print("'");
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass,
+                                                      resolved_method->name(),
+                                                      resolved_method->signature()));
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
   return resolved_method;
 }
 
 

@@ -1125,20 +1125,18 @@
 
   // check if method name is <init>, that it is found in same klass as static type
   if (resolved_method->name() == vmSymbols::object_initializer_name() &&
       resolved_method->method_holder() != resolved_klass) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("%s: method '", resolved_klass->external_name());
-    resolved_method->signature()->print_as_signature_external_return_type(&ss);
-    ss.print(" %s(", resolved_method->name()->as_C_string());
-    resolved_method->signature()->print_as_signature_external_parameters(&ss);
-    ss.print(")' not found");
     Exceptions::fthrow(
       THREAD_AND_LOCATION,
       vmSymbols::java_lang_NoSuchMethodError(),
-      "%s", ss.as_string());
+      "%s: method %s%s not found",
+      resolved_klass->external_name(),
+      resolved_method->name()->as_C_string(),
+      resolved_method->signature()->as_C_string()
+    );
     return NULL;
   }
 
   // ensure that invokespecial's interface method reference is in
   // a direct superinterface, not an indirect superinterface

@@ -1153,27 +1151,31 @@
                         SystemDictionary::reflect_MagicAccessorImpl_klass());
 
     if (!is_reflect &&
         !klass_to_check->is_same_or_direct_interface(resolved_klass)) {
       ResourceMark rm(THREAD);
-      stringStream ss;
-      ss.print("Interface method reference: '");
-      resolved_method->print_external_name(&ss);
-      ss.print("', is in an indirect superinterface of %s",
-               current_klass->external_name());
-      THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+      char buf[200];
+      jio_snprintf(buf, sizeof(buf),
+                   "Interface method reference: %s, is in an indirect superinterface of %s",
+                   Method::name_and_sig_as_C_string(resolved_klass,
+                                                                           resolved_method->name(),
+                                                                           resolved_method->signature()),
+                   current_klass->external_name());
+      THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
     }
   }
 
   // check if not static
   if (resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Expecting non-static method '");
-    resolved_method->print_external_name(&ss);
-    ss.print("'");
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf),
+                 "Expecting non-static method %s",
+                 Method::name_and_sig_as_C_string(resolved_klass,
+                                                  resolved_method->name(),
+                                                  resolved_method->signature()));
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   if (log_develop_is_enabled(Trace, itables)) {
     trace_method_resolution("invokespecial resolved method: caller-class:",
                             current_klass, resolved_klass, resolved_method, true);

@@ -1215,15 +1217,14 @@
                                                      resolved_method->signature(),
                                                      Klass::find_private, CHECK);
       // check if found
       if (sel_method.is_null()) {
         ResourceMark rm(THREAD);
-        stringStream ss;
-        ss.print("'");
-        resolved_method->print_external_name(&ss);
-        ss.print("'");
-        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
+        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
+                  Method::name_and_sig_as_C_string(resolved_klass,
+                                            resolved_method->name(),
+                                            resolved_method->signature()));
       // check loader constraints if found a different method
       } else if (sel_method() != resolved_method()) {
         check_method_loader_constraints(link_info, sel_method, "method", CHECK);
       }
     }

@@ -1241,35 +1242,34 @@
       if (!receiver_klass->is_subtype_of(sender)) {
         ResourceMark rm(THREAD);
         char buf[500];
         jio_snprintf(buf, sizeof(buf),
                      "Receiver class %s must be the current class or a subtype of interface %s",
-                     receiver_klass->external_name(),
-                     sender->external_name());
+                     receiver_klass->name()->as_C_string(),
+                     sender->name()->as_C_string());
         THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);
       }
     }
   }
 
   // check if not static
   if (sel_method->is_static()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Expecting non-static method '");
-    resolved_method->print_external_name(&ss);
-    ss.print("'");
-    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
+                                                                                      resolved_method->name(),
+                                                                                      resolved_method->signature()));
+    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   // check if abstract
   if (sel_method->is_abstract()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("'");
-    Method::print_external_name(&ss, resolved_klass, sel_method->name(), sel_method->signature());
-    ss.print("'");
-    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
+    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
+              Method::name_and_sig_as_C_string(resolved_klass,
+                                               sel_method->name(),
+                                               sel_method->signature()));
   }
 
   if (log_develop_is_enabled(Trace, itables)) {
     trace_method_resolution("invokespecial selected method: resolved-class:",
                             resolved_klass, resolved_klass, sel_method, true);

@@ -1303,26 +1303,27 @@
   Klass* current_klass = link_info.current_klass();
 
   // This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method
   if (resolved_klass->is_interface() && resolved_method->is_private()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("private interface method requires invokespecial, not invokevirtual: method '");
-    resolved_method->print_external_name(&ss);
-    ss.print("', caller-class: %s",
-             (current_klass == NULL ? "<null>" : current_klass->internal_name()));
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s",
+                 Method::name_and_sig_as_C_string(resolved_klass,
+                                                  resolved_method->name(),
+                                                  resolved_method->signature()),
+                   (current_klass == NULL ? "<NULL>" : current_klass->internal_name()));
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   // check if not static
   if (resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    stringStream ss;
-    ss.print("Expecting non-static method '");
-    resolved_method->print_external_name(&ss);
-    ss.print("'");
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
+                                                                                           resolved_method->name(),
+                                                                                           resolved_method->signature()));
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
   if (log_develop_is_enabled(Trace, vtables)) {
     trace_method_resolution("invokevirtual resolved method: caller-class:",
                             current_klass, resolved_klass, resolved_method, false);

@@ -1467,15 +1468,14 @@
     }
     // check access
     // Throw Illegal Access Error if selected_method is not public.
     if (!selected_method->is_public()) {
       ResourceMark rm(THREAD);
-      stringStream ss;
-      ss.print("'");
-      Method::print_external_name(&ss, recv_klass, selected_method->name(), selected_method->signature());
-      ss.print("'");
-      THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
+      THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
+                Method::name_and_sig_as_C_string(recv_klass,
+                                                 selected_method->name(),
+                                                 selected_method->signature()));
     }
     // check if abstract
     if (check_null_and_abstract && selected_method->is_abstract()) {
       throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK);
     }

@@ -1804,25 +1804,22 @@
   } else {
     ss.print("Missing implementation of");
   }
 
   assert(resolved_method.not_null(), "Sanity");
-  ss.print(" resolved method '%s%s",
+  ss.print(" resolved method %s%s%s%s of %s %s.",
            resolved_method->is_abstract() ? "abstract " : "",
-           resolved_method->is_private()  ? "private "  : "");
-  resolved_method->signature()->print_as_signature_external_return_type(&ss);
-  ss.print(" %s(", resolved_method->name()->as_C_string());
-  resolved_method->signature()->print_as_signature_external_parameters(&ss);
-  ss.print(")' of %s %s.",
+           resolved_method->is_private()  ? "private "  : "",
+           resolved_method->name()->as_C_string(),
+           resolved_method->signature()->as_C_string(),
            resolved_klass->external_kind(),
            resolved_klass->external_name());
 
   if (selected_method.not_null() && !(resolved_method == selected_method)) {
-    ss.print(" Selected method is '%s%s",
+    ss.print(" Selected method is %s%s%s.",
              selected_method->is_abstract() ? "abstract " : "",
-             selected_method->is_private()  ? "private "  : "");
-    selected_method->print_external_name(&ss);
-    ss.print("'.");
+             selected_method->is_private()  ? "private "  : "",
+             selected_method->name_and_sig_as_C_string());
   }
 
   THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
 }
< prev index next >