< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
rev 49271 : 8199852: Print more information about class loaders in LinkageErrors.

*** 4105,4114 **** --- 4105,4155 ---- oop java_lang_ClassLoader::unnamedModule(oop loader) { assert(is_instance(loader), "loader must be oop"); return loader->obj_field(unnamedModule_offset); } + // Caller needs ResourceMark. + const char* java_lang_ClassLoader::describe_external(const oop loader) { + if (loader == NULL) { + return "<bootstrap>"; + } + + const char* name = NULL; + oop nameOop = java_lang_ClassLoader::name(loader); + if (nameOop != NULL) { + name = java_lang_String::as_utf8_string(nameOop); + } + + stringStream ss; + const char *seperator; + // If we have a name set for this loader, display it. Otherwise use + // the class of the loader. + if (name != NULL) { + ss.print("\"%s\" (instance of %s", name, loader->klass()->external_name()); + seperator = ", "; + } else { + ss.print("%s", loader->klass()->external_name()); + seperator = " ("; + } + + oop pl = java_lang_ClassLoader::parent(loader); + if (pl != NULL) { + ss.print("%sparent: ", seperator); + oop parentNameOop = java_lang_ClassLoader::name(pl); + if (parentNameOop != NULL) { + const char* parentName = java_lang_String::as_utf8_string(parentNameOop); + if (parentName != NULL) { + ss.print("\"%s\" ", parentName); + } + } + ss.print("%s)", pl->klass()->external_name()); + } else { + ss.print("%sparent: <bootstrap>)", seperator); + } + return ss.as_string(); + } + // Support for java_lang_System // #define SYSTEM_FIELDS_DO(macro) \ macro(static_in_offset, k, "in", input_stream_signature, true); \ macro(static_out_offset, k, "out", print_stream_signature, true); \
< prev index next >