Print Java-level method signatures in exception messages
Lindenmaier, Goetz
goetz.lindenmaier at sap.com
Tue Mar 19 13:33:08 UTC 2019
Hi,
Exception messages thrown by the runtime contain method signatures
in the JNI signature format. This is not common to every Java developer.
It would be preferable to print the signatures with Java types.
Example:
Instead of
test/Task.m(I[D)Ltest/Foo;
we should print
test.Foo test.Task.m(int, double[])
So far, Method::name_and_sig_as_C_string() is used in the most
places.
I propose to add something like
Method::external_name(bool printQualifiers, bool printParamTypes, bool printReturnType)
(named according to to Klass::external_name() )
and methods like
Symbol::as_signature_extenal_return_type()
Symbol::as_signature_extenal_parameters()
(named according to Symbol::as_klass_external_name())
See also
http://hg.openjdk.java.net/jdk/jdk12/file/0276cba45aac/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/Test.java line 60
http://hg.openjdk.java.net/jdk/jdk12/file/0276cba45aac/test/hotspot/jtreg/runtime/exceptionMsgs/IllegalAccessError/IllegalAccessErrorTest.java line 144
where such method printouts appear in tests of exception messages.
name_and_sig_as_C_string() is used for exception messages in the following
places:
*** share/interpreter/linkResolver.cpp:
<global>[768] Method::name_and_sig_as_C_string(resolved_klass,
<global>[861] Method::name_and_sig_as_C_string(resolved_klass,
<global>[886] Method::name_and_sig_as_C_string(resolved_klass,
*** share/classfile/verifier.cpp:
class_format_error[2006] ss.print(" in method %s", _method->name_and_sig_as_C_string());
*** share/interpreter/linkResolver.cpp:
method_string[268] return Method::name_and_sig_as_C_string(_resolved_klass, _name, _signature);
<global>[768] Method::name_and_sig_as_C_string(resolved_klass,
<global>[861] Method::name_and_sig_as_C_string(resolved_klass,
<global>[886] Method::name_and_sig_as_C_string(resolved_klass,
linktime_resolve_static_method[1090] jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass,
linktime_resolve_special_method[1159] Method::name_and_sig_as_C_string(resolved_klass,
linktime_resolve_special_method[1173] Method::name_and_sig_as_C_string(resolved_klass,
runtime_resolve_special_method[1223] Method::name_and_sig_as_C_string(resolved_klass,
runtime_resolve_special_method[1258] jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
runtime_resolve_special_method[1268] Method::name_and_sig_as_C_string(resolved_klass,
linktime_resolve_virtual_method[1310] Method::name_and_sig_as_C_string(resolved_klass,
linktime_resolve_virtual_method[1321] jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
runtime_resolve_interface_method[1474] Method::name_and_sig_as_C_string(recv_klass,
throw_abstract_method_error[1821] selected_method->name_and_sig_as_C_string());
*** share/oops/klassVtable.cpp:
update_inherited_vtable[507] target_method()->name_and_sig_as_C_string(),
initialize_itable_for_interface[1235] m->name_and_sig_as_C_string(),
*** share/prims/jni.cpp:
register_native[2959] Method::name_and_sig_as_C_string(k, name, signature));
register_native[2969] Method::name_and_sig_as_C_string(k, name, signature));
*** share/prims/nativeLookup.cpp:
lookup_base[383] method->name_and_sig_as_C_string());
*** share/prims/stackwalk.cpp:
fill_in_frames[155] method->name_and_sig_as_C_string()));
*** share/runtime/reflection.cpp:
invoke[1090] Method::name_and_sig_as_C_string(target_klass,
invoke[1108] Method::name_and_sig_as_C_string(klass,
Best regards,
Goetz.
More information about the hotspot-runtime-dev
mailing list