8157490: JCK test vm/jni/DefineClass/dfcl001/dfcl00101m1/dfcl00101m1 crashes when run with -Xlog:classload=info
Summary: null stream->source() no longer causes error with -Xlog:class+load
Reviewed-by: lfoltan, coleenp
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jun 13 14:00:26 2016 +0000
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jun 13 13:47:21 2016 -0400
@@ -5356,15 +5356,7 @@
if (!is_internal()) {
if (log_is_enabled(Info, class, load)) {
ResourceMark rm;
- const char* module_name = NULL;
- static const size_t modules_image_name_len = strlen(MODULES_IMAGE_NAME);
- size_t stream_len = strlen(_stream->source());
- // See if _stream->source() ends in "modules"
- if (module_entry->is_named() && modules_image_name_len < stream_len &&
- (strncmp(_stream->source() + stream_len - modules_image_name_len,
- MODULES_IMAGE_NAME, modules_image_name_len) == 0)) {
- module_name = module_entry->name()->as_C_string();
- }
+ const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
if (log_is_enabled(Info, class, load)) {
ik->print_loading_log(LogLevel::Info, _loader_data, module_name, _stream);
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Mon Jun 13 14:00:26 2016 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Mon Jun 13 13:47:21 2016 -0400
@@ -3004,7 +3004,11 @@
if (cfs != NULL) {
if (cfs->source() != NULL) {
if (module_name != NULL) {
- log->print(" source: jrt:/%s", module_name);
+ if (ClassLoader::is_jrt(cfs->source())) {
+ log->print(" source: jrt:/%s", module_name);
+ } else {
+ log->print(" source: %s", cfs->source());
+ }
} else {
log->print(" source: %s", cfs->source());
}