mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8154791: Xlog classload too redundant msgs info/debug
Removed redundant information from class+load UL messages, ensured side-by-side printing of different levels for same class, cleaned up code Reviewed-by: iklam, dholmes
This commit is contained in:
parent
a65b58e18d
commit
eb6d311b66
5 changed files with 47 additions and 61 deletions
|
@ -5482,14 +5482,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa
|
||||||
if (log_is_enabled(Info, class, load)) {
|
if (log_is_enabled(Info, class, load)) {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
|
const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
|
||||||
|
ik->print_class_load_logging(_loader_data, module_name, _stream);
|
||||||
if (log_is_enabled(Info, class, load)) {
|
|
||||||
ik->print_loading_log(LogLevel::Info, _loader_data, module_name, _stream);
|
|
||||||
}
|
|
||||||
// No 'else' here as logging levels are not mutually exclusive
|
|
||||||
if (log_is_enabled(Debug, class, load)) {
|
|
||||||
ik->print_loading_log(LogLevel::Debug, _loader_data, module_name, _stream);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_is_enabled(Debug, class, resolve)) {
|
if (log_is_enabled(Debug, class, resolve)) {
|
||||||
|
|
|
@ -1384,14 +1384,7 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
|
||||||
ik->restore_unshareable_info(loader_data, protection_domain, CHECK_NULL);
|
ik->restore_unshareable_info(loader_data, protection_domain, CHECK_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_is_enabled(Info, class, load)) {
|
ik->print_class_load_logging(loader_data, NULL, NULL);
|
||||||
ik->print_loading_log(LogLevel::Info, loader_data, NULL, NULL);
|
|
||||||
}
|
|
||||||
// No 'else' here as logging levels are not mutually exclusive
|
|
||||||
|
|
||||||
if (log_is_enabled(Debug, class, load)) {
|
|
||||||
ik->print_loading_log(LogLevel::Debug, loader_data, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For boot loader, ensure that GetSystemPackage knows that a class in this
|
// For boot loader, ensure that GetSystemPackage knows that a class in this
|
||||||
// package was loaded.
|
// package was loaded.
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "interpreter/rewriter.hpp"
|
#include "interpreter/rewriter.hpp"
|
||||||
#include "jvmtifiles/jvmti.h"
|
#include "jvmtifiles/jvmti.h"
|
||||||
#include "logging/log.hpp"
|
#include "logging/log.hpp"
|
||||||
|
#include "logging/logMessage.hpp"
|
||||||
#include "memory/heapInspection.hpp"
|
#include "memory/heapInspection.hpp"
|
||||||
#include "memory/iterator.inline.hpp"
|
#include "memory/iterator.inline.hpp"
|
||||||
#include "memory/metadataFactory.hpp"
|
#include "memory/metadataFactory.hpp"
|
||||||
|
@ -72,7 +73,6 @@
|
||||||
#include "utilities/dtrace.hpp"
|
#include "utilities/dtrace.hpp"
|
||||||
#include "utilities/macros.hpp"
|
#include "utilities/macros.hpp"
|
||||||
#include "utilities/stringUtils.hpp"
|
#include "utilities/stringUtils.hpp"
|
||||||
#include "logging/log.hpp"
|
|
||||||
#ifdef COMPILER1
|
#ifdef COMPILER1
|
||||||
#include "c1/c1_Compiler.hpp"
|
#include "c1/c1_Compiler.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -3058,37 +3058,31 @@ const char* InstanceKlass::internal_name() const {
|
||||||
return external_name();
|
return external_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceKlass::print_loading_log(LogLevel::type type,
|
void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
|
||||||
ClassLoaderData* loader_data,
|
const char* module_name,
|
||||||
const char* module_name,
|
const ClassFileStream* cfs) const {
|
||||||
const ClassFileStream* cfs) const {
|
if (!log_is_enabled(Info, class, load)) {
|
||||||
ResourceMark rm;
|
return;
|
||||||
outputStream* log;
|
|
||||||
|
|
||||||
assert(type == LogLevel::Info || type == LogLevel::Debug, "sanity");
|
|
||||||
|
|
||||||
if (type == LogLevel::Info) {
|
|
||||||
log = Log(class, load)::info_stream();
|
|
||||||
} else {
|
|
||||||
assert(type == LogLevel::Debug,
|
|
||||||
"print_loading_log supports only Debug and Info levels");
|
|
||||||
log = Log(class, load)::debug_stream();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResourceMark rm;
|
||||||
|
LogMessage(class, load) msg;
|
||||||
|
stringStream info_stream;
|
||||||
|
|
||||||
// Name and class hierarchy info
|
// Name and class hierarchy info
|
||||||
log->print("%s", external_name());
|
info_stream.print("%s", external_name());
|
||||||
|
|
||||||
// Source
|
// Source
|
||||||
if (cfs != NULL) {
|
if (cfs != NULL) {
|
||||||
if (cfs->source() != NULL) {
|
if (cfs->source() != NULL) {
|
||||||
if (module_name != NULL) {
|
if (module_name != NULL) {
|
||||||
if (ClassLoader::is_jrt(cfs->source())) {
|
if (ClassLoader::is_jrt(cfs->source())) {
|
||||||
log->print(" source: jrt:/%s", module_name);
|
info_stream.print(" source: jrt:/%s", module_name);
|
||||||
} else {
|
} else {
|
||||||
log->print(" source: %s", cfs->source());
|
info_stream.print(" source: %s", cfs->source());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log->print(" source: %s", cfs->source());
|
info_stream.print(" source: %s", cfs->source());
|
||||||
}
|
}
|
||||||
} else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
|
} else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
|
||||||
Thread* THREAD = Thread::current();
|
Thread* THREAD = Thread::current();
|
||||||
|
@ -3098,46 +3092,52 @@ void InstanceKlass::print_loading_log(LogLevel::type type,
|
||||||
: NULL;
|
: NULL;
|
||||||
// caller can be NULL, for example, during a JVMTI VM_Init hook
|
// caller can be NULL, for example, during a JVMTI VM_Init hook
|
||||||
if (caller != NULL) {
|
if (caller != NULL) {
|
||||||
log->print(" source: instance of %s", caller->external_name());
|
info_stream.print(" source: instance of %s", caller->external_name());
|
||||||
} else {
|
} else {
|
||||||
// source is unknown
|
// source is unknown
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oop class_loader = loader_data->class_loader();
|
oop class_loader = loader_data->class_loader();
|
||||||
log->print(" source: %s", class_loader->klass()->external_name());
|
info_stream.print(" source: %s", class_loader->klass()->external_name());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log->print(" source: shared objects file");
|
info_stream.print(" source: shared objects file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == LogLevel::Debug) {
|
msg.info("%s", info_stream.as_string());
|
||||||
// Class hierarchy info
|
|
||||||
log->print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT,
|
|
||||||
p2i(this), p2i(superklass()));
|
|
||||||
|
|
||||||
|
if (log_is_enabled(Debug, class, load)) {
|
||||||
|
stringStream debug_stream;
|
||||||
|
|
||||||
|
// Class hierarchy info
|
||||||
|
debug_stream.print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT,
|
||||||
|
p2i(this), p2i(superklass()));
|
||||||
|
|
||||||
|
// Interfaces
|
||||||
if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
|
if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
|
||||||
log->print(" interfaces:");
|
debug_stream.print(" interfaces:");
|
||||||
int length = local_interfaces()->length();
|
int length = local_interfaces()->length();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
log->print(" " INTPTR_FORMAT,
|
debug_stream.print(" " INTPTR_FORMAT,
|
||||||
p2i(InstanceKlass::cast(local_interfaces()->at(i))));
|
p2i(InstanceKlass::cast(local_interfaces()->at(i))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class loader
|
// Class loader
|
||||||
log->print(" loader: [");
|
debug_stream.print(" loader: [");
|
||||||
loader_data->print_value_on(log);
|
loader_data->print_value_on(&debug_stream);
|
||||||
log->print("]");
|
debug_stream.print("]");
|
||||||
|
|
||||||
// Classfile checksum
|
// Classfile checksum
|
||||||
if (cfs) {
|
if (cfs) {
|
||||||
log->print(" bytes: %d checksum: %08x",
|
debug_stream.print(" bytes: %d checksum: %08x",
|
||||||
cfs->length(),
|
cfs->length(),
|
||||||
ClassLoader::crc32(0, (const char*)cfs->buffer(),
|
ClassLoader::crc32(0, (const char*)cfs->buffer(),
|
||||||
cfs->length()));
|
cfs->length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg.debug("%s", debug_stream.as_string());
|
||||||
}
|
}
|
||||||
log->cr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INCLUDE_SERVICES
|
#if INCLUDE_SERVICES
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "classfile/moduleEntry.hpp"
|
#include "classfile/moduleEntry.hpp"
|
||||||
#include "classfile/packageEntry.hpp"
|
#include "classfile/packageEntry.hpp"
|
||||||
#include "gc/shared/specialized_oop_closures.hpp"
|
#include "gc/shared/specialized_oop_closures.hpp"
|
||||||
#include "logging/logLevel.hpp"
|
|
||||||
#include "memory/referenceType.hpp"
|
#include "memory/referenceType.hpp"
|
||||||
#include "oops/annotations.hpp"
|
#include "oops/annotations.hpp"
|
||||||
#include "oops/constMethod.hpp"
|
#include "oops/constMethod.hpp"
|
||||||
|
@ -1369,8 +1368,9 @@ public:
|
||||||
void oop_verify_on(oop obj, outputStream* st);
|
void oop_verify_on(oop obj, outputStream* st);
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
void print_loading_log(LogLevel::type type, ClassLoaderData* loader_data,
|
void print_class_load_logging(ClassLoaderData* loader_data,
|
||||||
const char* module_name, const ClassFileStream* cfs) const;
|
const char* module_name,
|
||||||
|
const ClassFileStream* cfs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// for adding methods
|
// for adding methods
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8069469
|
* @bug 8069469
|
||||||
* @summary Make sure -Xlog:classload=info works properly with "modules" jimage,
|
* @summary Make sure -Xlog:class+load=info works properly with "modules" jimage,
|
||||||
--patch-module, and with -Xbootclasspath/a
|
--patch-module, and with -Xbootclasspath/a
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
|
@ -47,7 +47,7 @@ public class PatchModuleTraceCL {
|
||||||
" } " +
|
" } " +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
// Test -Xlog:classload=info output for --patch-module
|
// Test -Xlog:class+load=info output for --patch-module
|
||||||
ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
|
ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
|
||||||
InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
|
InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
|
||||||
"mods/java.naming");
|
"mods/java.naming");
|
||||||
|
@ -63,7 +63,7 @@ public class PatchModuleTraceCL {
|
||||||
// -cp case.
|
// -cp case.
|
||||||
output.shouldContain("[class,load] PatchModuleMain source: file");
|
output.shouldContain("[class,load] PatchModuleMain source: file");
|
||||||
|
|
||||||
// Test -Xlog:classload=info output for -Xbootclasspath/a
|
// Test -Xlog:class+load=info output for -Xbootclasspath/a
|
||||||
source = "package PatchModuleTraceCL_pkg; " +
|
source = "package PatchModuleTraceCL_pkg; " +
|
||||||
"public class ItIsI { " +
|
"public class ItIsI { " +
|
||||||
" static { " +
|
" static { " +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue