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 "interpreter/bytecodeStream.hpp"
|
||||
#include "interpreter/oopMapCache.hpp"
|
||||
#include "logging/logTag.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/filemap.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
|
@ -417,16 +418,15 @@ bool ClassPathImageEntry::is_jrt() {
|
|||
#if INCLUDE_CDS
|
||||
void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
|
||||
if (!TraceClassPaths) {
|
||||
return;
|
||||
}
|
||||
|
||||
void ClassLoader::trace_class_path(const char* msg, const char* name) {
|
||||
if (log_is_enabled(Info, classpath)) {
|
||||
ResourceMark rm;
|
||||
outputStream* out = LogHandle(classpath)::info_stream();
|
||||
if (msg) {
|
||||
out->print("%s", msg);
|
||||
}
|
||||
|
@ -442,9 +442,6 @@ void ClassLoader::trace_class_path(outputStream* out, const char* msg, const cha
|
|||
}
|
||||
}
|
||||
}
|
||||
if (msg && msg[0] == '[') {
|
||||
out->print_cr("]");
|
||||
} else {
|
||||
out->cr();
|
||||
}
|
||||
}
|
||||
|
@ -470,11 +467,13 @@ void ClassLoader::check_shared_classpath(const char *path) {
|
|||
void ClassLoader::setup_bootstrap_search_path() {
|
||||
assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
|
||||
const char* sys_class_path = Arguments::get_sysclasspath();
|
||||
const char* java_class_path = Arguments::get_appclasspath();
|
||||
if (PrintSharedArchiveAndExit) {
|
||||
// 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.
|
||||
} 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 (DumpSharedSpaces) {
|
||||
|
@ -578,9 +577,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str
|
|||
}
|
||||
}
|
||||
}
|
||||
if (TraceClassPaths) {
|
||||
tty->print_cr("[Opened %s]", path);
|
||||
}
|
||||
log_info(classpath)("opened: %s", path);
|
||||
log_info(classload)("opened: %s", path);
|
||||
} else {
|
||||
// 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.
|
||||
*
|
||||
* 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);
|
||||
#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
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,15 +26,15 @@
|
|||
#include "classfile/classLoader.hpp"
|
||||
#include "classfile/classLoaderData.inline.hpp"
|
||||
#include "classfile/sharedPathsMiscInfo.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "runtime/arguments.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
void SharedPathsMiscInfo::add_path(const char* path, int type) {
|
||||
if (TraceClassPaths) {
|
||||
tty->print("[type=%s] ", type_name(type));
|
||||
trace_class_path("[Add misc shared path ", path);
|
||||
}
|
||||
log_info(classpath)("type=%s ", type_name(type));
|
||||
ClassLoader::trace_class_path("add misc shared path ", path);
|
||||
write(path, strlen(path) + 1);
|
||||
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) {
|
||||
ClassLoader::trace_class_path(tty, msg, name);
|
||||
ClassLoader::trace_class_path(msg, name);
|
||||
MetaspaceShared::set_archive_loading_failed();
|
||||
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() {
|
||||
// The whole buffer must be 0 terminated so that we can use strlen and strcmp
|
||||
// without fear.
|
||||
|
@ -90,17 +108,14 @@ bool SharedPathsMiscInfo::check() {
|
|||
if (!read_jint(&type)) {
|
||||
return fail("Corrupted archive file header");
|
||||
}
|
||||
if (TraceClassPaths) {
|
||||
tty->print("[type=%s ", type_name(type));
|
||||
print_path(tty, type, path);
|
||||
tty->print_cr("]");
|
||||
}
|
||||
log_info(classpath)("type=%s ", type_name(type));
|
||||
print_path(type, path);
|
||||
if (!check(type, path)) {
|
||||
if (!PrintSharedArchiveAndExit) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
trace_class_path("[ok");
|
||||
ClassLoader::trace_class_path("ok");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,6 @@ protected:
|
|||
void write(const 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:
|
||||
static bool fail(const char* msg, const char* name = NULL);
|
||||
virtual bool check(jint type, const char* path);
|
||||
|
@ -144,21 +141,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void print_path(outputStream* out, 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();
|
||||
}
|
||||
}
|
||||
virtual void print_path(int type, const char* path);
|
||||
|
||||
bool check();
|
||||
bool read_jint(jint *ptr) {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
LOG_TAG(classload) /* Trace all classes loaded */ \
|
||||
LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \
|
||||
LOG_TAG(classunload) /* Trace unloading of classes */ \
|
||||
LOG_TAG(classpath) \
|
||||
LOG_TAG(compaction) \
|
||||
LOG_TAG(cpu) \
|
||||
LOG_TAG(cset) \
|
||||
|
|
|
@ -208,9 +208,7 @@ void FileMapInfo::allocate_classpath_entry_table() {
|
|||
count ++;
|
||||
bytes += (int)entry_size;
|
||||
bytes += name_bytes;
|
||||
if (TraceClassPaths) {
|
||||
tty->print_cr("[Add main shared path (%s) %s]", (cpe->is_jar_file() ? "jar" : "dir"), name);
|
||||
}
|
||||
log_info(classpath)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name);
|
||||
} else {
|
||||
SharedClassPathEntry* ent = shared_classpath(cur_entry);
|
||||
if (cpe->is_jar_file()) {
|
||||
|
@ -275,9 +273,7 @@ bool FileMapInfo::validate_classpath_entry_table() {
|
|||
struct stat st;
|
||||
const char* name = ent->_name;
|
||||
bool ok = true;
|
||||
if (TraceClassPaths) {
|
||||
tty->print_cr("[Checking shared classpath entry: %s]", name);
|
||||
}
|
||||
log_info(classpath)("checking shared classpath entry: %s", name);
|
||||
if (os::stat(name, &st) != 0) {
|
||||
fail_continue("Required classpath entry does not exist: %s", name);
|
||||
ok = false;
|
||||
|
@ -301,9 +297,7 @@ bool FileMapInfo::validate_classpath_entry_table() {
|
|||
}
|
||||
}
|
||||
if (ok) {
|
||||
if (TraceClassPaths) {
|
||||
tty->print_cr("[ok]");
|
||||
}
|
||||
log_info(classpath)("ok");
|
||||
} else if (!PrintSharedArchiveAndExit) {
|
||||
_validating_classpath_entry_table = false;
|
||||
return false;
|
||||
|
@ -888,10 +882,8 @@ bool FileMapInfo::FileMapHeader::validate() {
|
|||
char header_version[JVM_IDENT_MAX];
|
||||
get_header_version(header_version);
|
||||
if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
|
||||
if (TraceClassPaths) {
|
||||
tty->print_cr("Expected: %s", header_version);
|
||||
tty->print_cr("Actual: %s", _jvm_ident);
|
||||
}
|
||||
log_info(classpath)("expected: %s", header_version);
|
||||
log_info(classpath)("actual: %s", _jvm_ident);
|
||||
FileMapInfo::fail_continue("The shared archive file was created by a different"
|
||||
" version or build of HotSpot");
|
||||
return false;
|
||||
|
@ -919,7 +911,7 @@ bool FileMapInfo::validate_header() {
|
|||
if (status) {
|
||||
if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,8 +405,9 @@ static AliasedFlag const aliased_jvm_flags[] = {
|
|||
|
||||
static AliasedLoggingFlag const aliased_logging_flags[] = {
|
||||
{ "TraceClassLoading", LogLevel::Info, true, LogTag::_classload },
|
||||
{ "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload },
|
||||
{ "TraceClassPaths", LogLevel::Info, true, LogTag::_classpath },
|
||||
{ "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve },
|
||||
{ "TraceClassUnloading", LogLevel::Info, true, LogTag::_classunload },
|
||||
{ "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions },
|
||||
{ "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation },
|
||||
{ "TraceBiasedLocking", LogLevel::Info, true, LogTag::_biasedlocking },
|
||||
|
@ -3255,7 +3256,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
|||
|
||||
// PrintSharedArchiveAndExit will turn on
|
||||
// -Xshare:on
|
||||
// -XX:+TraceClassPaths
|
||||
// -Xlog:classpath=info
|
||||
if (PrintSharedArchiveAndExit) {
|
||||
if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
|
||||
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) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
if (FLAG_SET_CMDLINE(bool, TraceClassPaths, true) != Flag::SUCCESS) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classpath));
|
||||
}
|
||||
|
||||
// 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);
|
||||
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) {
|
||||
|
|
|
@ -2403,9 +2403,6 @@ public:
|
|||
product(bool, IgnoreEmptyClassPaths, false, \
|
||||
"Ignore empty path elements in -classpath") \
|
||||
\
|
||||
product(bool, TraceClassPaths, false, \
|
||||
"Trace processing of class paths") \
|
||||
\
|
||||
product(bool, TraceClassLoadingPreorder, false, \
|
||||
"Trace all classes loaded in order referenced (not loaded)") \
|
||||
\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue