--- a/src/hotspot/share/oops/symbol.cpp Thu Apr 04 17:23:05 2019 -0400
+++ b/src/hotspot/share/oops/symbol.cpp Thu Apr 04 09:39:44 2019 +0200
@@ -200,6 +200,66 @@
return str;
}
+static void print_class(outputStream *os, char *class_str, int len) {
+ for (int i = 0; i < len; ++i) {
+ if (class_str[i] == '/') {
+ os->put('.');
+ } else {
+ os->put(class_str[i]);
+ }
+ }
+}
+
+static void print_array(outputStream *os, char *array_str, int len) {
+ int dimensions = 0;
+ for (int i = 0; i < len; ++i) {
+ if (array_str[i] == '[') {
+ dimensions++;
+ } else if (array_str[i] == 'L') {
+ // Expected format: L<type name>;. Skip 'L' and ';' delimiting the type name.
+ print_class(os, array_str+i+1, len-i-2);
+ break;
+ } else {
+ os->print("%s", type2name(char2type(array_str[i])));
+ }
+ }
+ for (int i = 0; i < dimensions; ++i) {
+ os->print("[]");
+ }
+}
+
+void Symbol::print_as_signature_external_return_type(outputStream *os) {
+ for (SignatureStream ss(this); !ss.is_done(); ss.next()) {
+ if (ss.at_return_type()) {
+ if (ss.is_array()) {
+ print_array(os, (char*)ss.raw_bytes(), (int)ss.raw_length());
+ } else if (ss.is_object()) {
+ // Expected format: L<type name>;. Skip 'L' and ';' delimiting the class name.
+ print_class(os, (char*)ss.raw_bytes()+1, (int)ss.raw_length()-2);
+ } else {
+ os->print("%s", type2name(ss.type()));
+ }
+ }
+ }
+}
+
+void Symbol::print_as_signature_external_parameters(outputStream *os) {
+ bool first = true;
+ for (SignatureStream ss(this); !ss.is_done(); ss.next()) {
+ if (ss.at_return_type()) break;
+ if (!first) { os->print(", "); }
+ if (ss.is_array()) {
+ print_array(os, (char*)ss.raw_bytes(), (int)ss.raw_length());
+ } else if (ss.is_object()) {
+ // Skip 'L' and ';'.
+ print_class(os, (char*)ss.raw_bytes()+1, (int)ss.raw_length()-2);
+ } else {
+ os->print("%s", type2name(ss.type()));
+ }
+ first = false;
+ }
+}
+
// Increment refcount while checking for zero. If the Symbol's refcount becomes zero
// a thread could be concurrently removing the Symbol. This is used during SymbolTable
// lookup to avoid reviving a dead Symbol.