mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 22:04:51 +02:00
8150103: Convert TraceClassPaths to Unified Logging
TraceClassPaths has been reimplemented with Unified Logging Reviewed-by: coleenp, dholmes, iklam
This commit is contained in:
parent
8961912c74
commit
4f6dba1568
8 changed files with 64 additions and 84 deletions
|
@ -37,6 +37,7 @@
|
||||||
#include "gc/shared/generation.hpp"
|
#include "gc/shared/generation.hpp"
|
||||||
#include "interpreter/bytecodeStream.hpp"
|
#include "interpreter/bytecodeStream.hpp"
|
||||||
#include "interpreter/oopMapCache.hpp"
|
#include "interpreter/oopMapCache.hpp"
|
||||||
|
#include "logging/logTag.hpp"
|
||||||
#include "memory/allocation.inline.hpp"
|
#include "memory/allocation.inline.hpp"
|
||||||
#include "memory/filemap.hpp"
|
#include "memory/filemap.hpp"
|
||||||
#include "memory/oopFactory.hpp"
|
#include "memory/oopFactory.hpp"
|
||||||
|
@ -417,34 +418,30 @@ bool ClassPathImageEntry::is_jrt() {
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
|
void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
|
||||||
assert(DumpSharedSpaces, "only called at dump time");
|
assert(DumpSharedSpaces, "only called at dump time");
|
||||||
tty->print_cr("Hint: enable -XX:+TraceClassPaths to diagnose the failure");
|
tty->print_cr("Hint: enable -Xlog:classpath=info to diagnose the failure");
|
||||||
vm_exit_during_initialization(error, message);
|
vm_exit_during_initialization(error, message);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
|
void ClassLoader::trace_class_path(const char* msg, const char* name) {
|
||||||
if (!TraceClassPaths) {
|
if (log_is_enabled(Info, classpath)) {
|
||||||
return;
|
ResourceMark rm;
|
||||||
}
|
outputStream* out = LogHandle(classpath)::info_stream();
|
||||||
|
if (msg) {
|
||||||
if (msg) {
|
out->print("%s", msg);
|
||||||
out->print("%s", msg);
|
}
|
||||||
}
|
if (name) {
|
||||||
if (name) {
|
if (strlen(name) < 256) {
|
||||||
if (strlen(name) < 256) {
|
out->print("%s", name);
|
||||||
out->print("%s", name);
|
} else {
|
||||||
} else {
|
// For very long paths, we need to print each character separately,
|
||||||
// For very long paths, we need to print each character separately,
|
// as print_cr() has a length limit
|
||||||
// as print_cr() has a length limit
|
while (name[0] != '\0') {
|
||||||
while (name[0] != '\0') {
|
out->print("%c", name[0]);
|
||||||
out->print("%c", name[0]);
|
name++;
|
||||||
name++;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (msg && msg[0] == '[') {
|
|
||||||
out->print_cr("]");
|
|
||||||
} else {
|
|
||||||
out->cr();
|
out->cr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,11 +467,13 @@ void ClassLoader::check_shared_classpath(const char *path) {
|
||||||
void ClassLoader::setup_bootstrap_search_path() {
|
void ClassLoader::setup_bootstrap_search_path() {
|
||||||
assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
|
assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
|
||||||
const char* sys_class_path = Arguments::get_sysclasspath();
|
const char* sys_class_path = Arguments::get_sysclasspath();
|
||||||
|
const char* java_class_path = Arguments::get_appclasspath();
|
||||||
if (PrintSharedArchiveAndExit) {
|
if (PrintSharedArchiveAndExit) {
|
||||||
// Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily
|
// Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily
|
||||||
// the same as the bootcp of the shared archive.
|
// the same as the bootcp of the shared archive.
|
||||||
} else {
|
} else {
|
||||||
trace_class_path(tty, "[Bootstrap loader class path=", sys_class_path);
|
trace_class_path("bootstrap loader class path=", sys_class_path);
|
||||||
|
trace_class_path("classpath: ", java_class_path);
|
||||||
}
|
}
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
if (DumpSharedSpaces) {
|
if (DumpSharedSpaces) {
|
||||||
|
@ -578,9 +577,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("opened: %s", path);
|
||||||
tty->print_cr("[Opened %s]", path);
|
|
||||||
}
|
|
||||||
log_info(classload)("opened: %s", path);
|
log_info(classload)("opened: %s", path);
|
||||||
} else {
|
} else {
|
||||||
// Directory
|
// Directory
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2016, 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
|
||||||
|
@ -331,7 +331,7 @@ class ClassLoader: AllStatic {
|
||||||
static void exit_with_path_failure(const char* error, const char* message);
|
static void exit_with_path_failure(const char* error, const char* message);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void trace_class_path(outputStream* out, const char* msg, const char* name = NULL);
|
static void trace_class_path(const char* msg, const char* name = NULL);
|
||||||
|
|
||||||
// VM monitoring and management support
|
// VM monitoring and management support
|
||||||
static jlong classloader_time_ms();
|
static jlong classloader_time_ms();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2016, 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
|
||||||
|
@ -26,15 +26,15 @@
|
||||||
#include "classfile/classLoader.hpp"
|
#include "classfile/classLoader.hpp"
|
||||||
#include "classfile/classLoaderData.inline.hpp"
|
#include "classfile/classLoaderData.inline.hpp"
|
||||||
#include "classfile/sharedPathsMiscInfo.hpp"
|
#include "classfile/sharedPathsMiscInfo.hpp"
|
||||||
|
#include "logging/log.hpp"
|
||||||
#include "memory/allocation.inline.hpp"
|
#include "memory/allocation.inline.hpp"
|
||||||
#include "memory/metaspaceShared.hpp"
|
#include "memory/metaspaceShared.hpp"
|
||||||
#include "runtime/arguments.hpp"
|
#include "runtime/arguments.hpp"
|
||||||
|
#include "utilities/ostream.hpp"
|
||||||
|
|
||||||
void SharedPathsMiscInfo::add_path(const char* path, int type) {
|
void SharedPathsMiscInfo::add_path(const char* path, int type) {
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("type=%s ", type_name(type));
|
||||||
tty->print("[type=%s] ", type_name(type));
|
ClassLoader::trace_class_path("add misc shared path ", path);
|
||||||
trace_class_path("[Add misc shared path ", path);
|
|
||||||
}
|
|
||||||
write(path, strlen(path) + 1);
|
write(path, strlen(path) + 1);
|
||||||
write_jint(jint(type));
|
write_jint(jint(type));
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,29 @@ bool SharedPathsMiscInfo::read(void* ptr, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedPathsMiscInfo::fail(const char* msg, const char* name) {
|
bool SharedPathsMiscInfo::fail(const char* msg, const char* name) {
|
||||||
ClassLoader::trace_class_path(tty, msg, name);
|
ClassLoader::trace_class_path(msg, name);
|
||||||
MetaspaceShared::set_archive_loading_failed();
|
MetaspaceShared::set_archive_loading_failed();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharedPathsMiscInfo::print_path(int type, const char* path) {
|
||||||
|
ResourceMark rm;
|
||||||
|
outputStream* out = LogHandle(classpath)::info_stream();
|
||||||
|
switch (type) {
|
||||||
|
case BOOT:
|
||||||
|
out->print("Expecting -Dsun.boot.class.path=%s", path);
|
||||||
|
break;
|
||||||
|
case NON_EXIST:
|
||||||
|
out->print("Expecting that %s does not exist", path);
|
||||||
|
break;
|
||||||
|
case REQUIRED:
|
||||||
|
out->print("Expecting that file %s must exist and is not altered", path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ShouldNotReachHere();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SharedPathsMiscInfo::check() {
|
bool SharedPathsMiscInfo::check() {
|
||||||
// The whole buffer must be 0 terminated so that we can use strlen and strcmp
|
// The whole buffer must be 0 terminated so that we can use strlen and strcmp
|
||||||
// without fear.
|
// without fear.
|
||||||
|
@ -90,17 +108,14 @@ bool SharedPathsMiscInfo::check() {
|
||||||
if (!read_jint(&type)) {
|
if (!read_jint(&type)) {
|
||||||
return fail("Corrupted archive file header");
|
return fail("Corrupted archive file header");
|
||||||
}
|
}
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("type=%s ", type_name(type));
|
||||||
tty->print("[type=%s ", type_name(type));
|
print_path(type, path);
|
||||||
print_path(tty, type, path);
|
|
||||||
tty->print_cr("]");
|
|
||||||
}
|
|
||||||
if (!check(type, path)) {
|
if (!check(type, path)) {
|
||||||
if (!PrintSharedArchiveAndExit) {
|
if (!PrintSharedArchiveAndExit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trace_class_path("[ok");
|
ClassLoader::trace_class_path("ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,6 @@ protected:
|
||||||
void write(const void* ptr, size_t size);
|
void write(const void* ptr, size_t size);
|
||||||
bool read(void* ptr, size_t size);
|
bool read(void* ptr, size_t size);
|
||||||
|
|
||||||
static void trace_class_path(const char* msg, const char* name = NULL) {
|
|
||||||
ClassLoader::trace_class_path(tty, msg, name);
|
|
||||||
}
|
|
||||||
protected:
|
protected:
|
||||||
static bool fail(const char* msg, const char* name = NULL);
|
static bool fail(const char* msg, const char* name = NULL);
|
||||||
virtual bool check(jint type, const char* path);
|
virtual bool check(jint type, const char* path);
|
||||||
|
@ -144,21 +141,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void print_path(outputStream* out, int type, const char* path) {
|
virtual void print_path(int type, const char* path);
|
||||||
switch (type) {
|
|
||||||
case BOOT:
|
|
||||||
out->print("Expecting -Dsun.boot.class.path=%s", path);
|
|
||||||
break;
|
|
||||||
case NON_EXIST:
|
|
||||||
out->print("Expecting that %s does not exist", path);
|
|
||||||
break;
|
|
||||||
case REQUIRED:
|
|
||||||
out->print("Expecting that file %s must exist and is not altered", path);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ShouldNotReachHere();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool check();
|
bool check();
|
||||||
bool read_jint(jint *ptr) {
|
bool read_jint(jint *ptr) {
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
LOG_TAG(classload) /* Trace all classes loaded */ \
|
LOG_TAG(classload) /* Trace all classes loaded */ \
|
||||||
LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \
|
LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \
|
||||||
LOG_TAG(classunload) /* Trace unloading of classes */ \
|
LOG_TAG(classunload) /* Trace unloading of classes */ \
|
||||||
|
LOG_TAG(classpath) \
|
||||||
LOG_TAG(compaction) \
|
LOG_TAG(compaction) \
|
||||||
LOG_TAG(cpu) \
|
LOG_TAG(cpu) \
|
||||||
LOG_TAG(cset) \
|
LOG_TAG(cset) \
|
||||||
|
|
|
@ -208,9 +208,7 @@ void FileMapInfo::allocate_classpath_entry_table() {
|
||||||
count ++;
|
count ++;
|
||||||
bytes += (int)entry_size;
|
bytes += (int)entry_size;
|
||||||
bytes += name_bytes;
|
bytes += name_bytes;
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name);
|
||||||
tty->print_cr("[Add main shared path (%s) %s]", (cpe->is_jar_file() ? "jar" : "dir"), name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
SharedClassPathEntry* ent = shared_classpath(cur_entry);
|
SharedClassPathEntry* ent = shared_classpath(cur_entry);
|
||||||
if (cpe->is_jar_file()) {
|
if (cpe->is_jar_file()) {
|
||||||
|
@ -275,9 +273,7 @@ bool FileMapInfo::validate_classpath_entry_table() {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char* name = ent->_name;
|
const char* name = ent->_name;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("checking shared classpath entry: %s", name);
|
||||||
tty->print_cr("[Checking shared classpath entry: %s]", name);
|
|
||||||
}
|
|
||||||
if (os::stat(name, &st) != 0) {
|
if (os::stat(name, &st) != 0) {
|
||||||
fail_continue("Required classpath entry does not exist: %s", name);
|
fail_continue("Required classpath entry does not exist: %s", name);
|
||||||
ok = false;
|
ok = false;
|
||||||
|
@ -301,9 +297,7 @@ bool FileMapInfo::validate_classpath_entry_table() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("ok");
|
||||||
tty->print_cr("[ok]");
|
|
||||||
}
|
|
||||||
} else if (!PrintSharedArchiveAndExit) {
|
} else if (!PrintSharedArchiveAndExit) {
|
||||||
_validating_classpath_entry_table = false;
|
_validating_classpath_entry_table = false;
|
||||||
return false;
|
return false;
|
||||||
|
@ -888,10 +882,8 @@ bool FileMapInfo::FileMapHeader::validate() {
|
||||||
char header_version[JVM_IDENT_MAX];
|
char header_version[JVM_IDENT_MAX];
|
||||||
get_header_version(header_version);
|
get_header_version(header_version);
|
||||||
if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
|
if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
|
||||||
if (TraceClassPaths) {
|
log_info(classpath)("expected: %s", header_version);
|
||||||
tty->print_cr("Expected: %s", header_version);
|
log_info(classpath)("actual: %s", _jvm_ident);
|
||||||
tty->print_cr("Actual: %s", _jvm_ident);
|
|
||||||
}
|
|
||||||
FileMapInfo::fail_continue("The shared archive file was created by a different"
|
FileMapInfo::fail_continue("The shared archive file was created by a different"
|
||||||
" version or build of HotSpot");
|
" version or build of HotSpot");
|
||||||
return false;
|
return false;
|
||||||
|
@ -919,7 +911,7 @@ bool FileMapInfo::validate_header() {
|
||||||
if (status) {
|
if (status) {
|
||||||
if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
|
if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
|
||||||
if (!PrintSharedArchiveAndExit) {
|
if (!PrintSharedArchiveAndExit) {
|
||||||
fail_continue("shared class paths mismatch (hint: enable -XX:+TraceClassPaths to diagnose the failure)");
|
fail_continue("shared class paths mismatch (hint: enable -Xlog:classpath=info to diagnose the failure)");
|
||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,8 +405,9 @@ static AliasedFlag const aliased_jvm_flags[] = {
|
||||||
|
|
||||||
static AliasedLoggingFlag const aliased_logging_flags[] = {
|
static AliasedLoggingFlag const aliased_logging_flags[] = {
|
||||||
{ "TraceClassLoading", LogLevel::Info, true, LogTag::_classload },
|
{ "TraceClassLoading", LogLevel::Info, true, LogTag::_classload },
|
||||||
{ "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload },
|
{ "TraceClassPaths", LogLevel::Info, true, LogTag::_classpath },
|
||||||
{ "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve },
|
{ "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve },
|
||||||
|
{ "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload },
|
||||||
{ "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions },
|
{ "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions },
|
||||||
{ "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation },
|
{ "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation },
|
||||||
{ "TraceBiasedLocking", LogLevel::Info, true, LogTag::_biasedlocking },
|
{ "TraceBiasedLocking", LogLevel::Info, true, LogTag::_biasedlocking },
|
||||||
|
@ -3255,7 +3256,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
||||||
|
|
||||||
// PrintSharedArchiveAndExit will turn on
|
// PrintSharedArchiveAndExit will turn on
|
||||||
// -Xshare:on
|
// -Xshare:on
|
||||||
// -XX:+TraceClassPaths
|
// -Xlog:classpath=info
|
||||||
if (PrintSharedArchiveAndExit) {
|
if (PrintSharedArchiveAndExit) {
|
||||||
if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
|
if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
|
||||||
return JNI_EINVAL;
|
return JNI_EINVAL;
|
||||||
|
@ -3263,9 +3264,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
||||||
if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
|
if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
|
||||||
return JNI_EINVAL;
|
return JNI_EINVAL;
|
||||||
}
|
}
|
||||||
if (FLAG_SET_CMDLINE(bool, TraceClassPaths, true) != Flag::SUCCESS) {
|
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classpath));
|
||||||
return JNI_EINVAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the default value for flags which have different default values
|
// Change the default value for flags which have different default values
|
||||||
|
@ -3318,10 +3317,6 @@ void Arguments::fix_appclasspath() {
|
||||||
_java_class_path->set_value(copy);
|
_java_class_path->set_value(copy);
|
||||||
FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
|
FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PrintSharedArchiveAndExit) {
|
|
||||||
ClassLoader::trace_class_path(tty, "[classpath: ", _java_class_path->value());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool has_jar_files(const char* directory) {
|
static bool has_jar_files(const char* directory) {
|
||||||
|
|
|
@ -2403,9 +2403,6 @@ public:
|
||||||
product(bool, IgnoreEmptyClassPaths, false, \
|
product(bool, IgnoreEmptyClassPaths, false, \
|
||||||
"Ignore empty path elements in -classpath") \
|
"Ignore empty path elements in -classpath") \
|
||||||
\
|
\
|
||||||
product(bool, TraceClassPaths, false, \
|
|
||||||
"Trace processing of class paths") \
|
|
||||||
\
|
|
||||||
product(bool, TraceClassLoadingPreorder, false, \
|
product(bool, TraceClassLoadingPreorder, false, \
|
||||||
"Trace all classes loaded in order referenced (not loaded)") \
|
"Trace all classes loaded in order referenced (not loaded)") \
|
||||||
\
|
\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue