8186988: use log_warning() and log_error() instead of tty->print_cr for CDS warning and error messages

Reviewed-by: stuefe, iklam, dholmes
This commit is contained in:
Calvin Cheung 2019-09-12 09:59:19 -07:00
parent e9eaba3d53
commit e8ee2800f5
4 changed files with 8 additions and 7 deletions

@ -1325,7 +1325,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
THREAD); THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
if (DumpSharedSpaces) { if (DumpSharedSpaces) {
tty->print_cr("Preload Error: Failed to load %s", class_name); log_error(cds)("Preload Error: Failed to load %s", class_name);
} }
return NULL; return NULL;
} }

@ -32,6 +32,7 @@
#include "classfile/modules.hpp" #include "classfile/modules.hpp"
#include "classfile/systemDictionaryShared.hpp" #include "classfile/systemDictionaryShared.hpp"
#include "classfile/vmSymbols.hpp" #include "classfile/vmSymbols.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/filemap.hpp" #include "memory/filemap.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
@ -146,7 +147,7 @@ char* ClassLoaderExt::get_class_path_attr(const char* jar_path, char* manifest,
if (found != NULL) { if (found != NULL) {
// Same behavior as jdk/src/share/classes/java/util/jar/Attributes.java // Same behavior as jdk/src/share/classes/java/util/jar/Attributes.java
// If duplicated entries are found, the last one is used. // If duplicated entries are found, the last one is used.
tty->print_cr("Warning: Duplicate name in Manifest: %s.\n" log_warning(cds)("Warning: Duplicate name in Manifest: %s.\n"
"Ensure that the manifest does not have duplicate entries, and\n" "Ensure that the manifest does not have duplicate entries, and\n"
"that blank lines separate individual sections in both your\n" "that blank lines separate individual sections in both your\n"
"manifest and in the META-INF/MANIFEST.MF entry in the jar file:\n%s\n", tag, jar_path); "manifest and in the META-INF/MANIFEST.MF entry in the jar file:\n%s\n", tag, jar_path);
@ -276,7 +277,7 @@ InstanceKlass* ClassLoaderExt::load_class(Symbol* name, const char* path, TRAPS)
} }
if (NULL == stream) { if (NULL == stream) {
tty->print_cr("Preload Warning: Cannot find %s", class_name); log_warning(cds)("Preload Warning: Cannot find %s", class_name);
return NULL; return NULL;
} }
@ -295,7 +296,7 @@ InstanceKlass* ClassLoaderExt::load_class(Symbol* name, const char* path, TRAPS)
THREAD); THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
tty->print_cr("Preload Error: Failed to load %s", class_name); log_error(cds)("Preload Error: Failed to load %s", class_name);
return NULL; return NULL;
} }
return result; return result;

@ -459,7 +459,7 @@ void FileMapInfo::check_nonempty_dir_in_shared_path_table() {
if (e->is_dir()) { if (e->is_dir()) {
const char* path = e->name(); const char* path = e->name();
if (!os::dir_is_empty(path)) { if (!os::dir_is_empty(path)) {
tty->print_cr("Error: non-empty directory '%s'", path); log_error(cds)("Error: non-empty directory '%s'", path);
has_nonempty_dir = true; has_nonempty_dir = true;
} }
} }

@ -1814,7 +1814,7 @@ int MetaspaceShared::preload_classes(const char* class_list_path, TRAPS) {
if (klass == NULL && if (klass == NULL &&
(PENDING_EXCEPTION->klass()->name() == vmSymbols::java_lang_ClassNotFoundException())) { (PENDING_EXCEPTION->klass()->name() == vmSymbols::java_lang_ClassNotFoundException())) {
// print a warning only when the pending exception is class not found // print a warning only when the pending exception is class not found
tty->print_cr("Preload Warning: Cannot find %s", parser.current_class_name()); log_warning(cds)("Preload Warning: Cannot find %s", parser.current_class_name());
} }
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
} }
@ -1860,7 +1860,7 @@ bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) {
ik->link_class(THREAD); ik->link_class(THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
ResourceMark rm; ResourceMark rm;
tty->print_cr("Preload Warning: Verification failed for %s", log_warning(cds)("Preload Warning: Verification failed for %s",
ik->external_name()); ik->external_name());
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
ik->set_in_error_state(); ik->set_in_error_state();