8186988: use log_warning() and log_error() instead of tty->print_cr for CDS warning and error messages
authorccheung
Thu, 12 Sep 2019 09:59:19 -0700
changeset 58110 85e1de070bef
parent 58108 5302477c8285
child 58111 f63f50a4bf43
8186988: use log_warning() and log_error() instead of tty->print_cr for CDS warning and error messages Reviewed-by: stuefe, iklam, dholmes
src/hotspot/share/classfile/classLoader.cpp
src/hotspot/share/classfile/classLoaderExt.cpp
src/hotspot/share/memory/filemap.cpp
src/hotspot/share/memory/metaspaceShared.cpp
--- a/src/hotspot/share/classfile/classLoader.cpp	Thu Sep 12 15:46:11 2019 +0100
+++ b/src/hotspot/share/classfile/classLoader.cpp	Thu Sep 12 09:59:19 2019 -0700
@@ -1325,7 +1325,7 @@
                                                            THREAD);
   if (HAS_PENDING_EXCEPTION) {
     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;
   }
--- a/src/hotspot/share/classfile/classLoaderExt.cpp	Thu Sep 12 15:46:11 2019 +0100
+++ b/src/hotspot/share/classfile/classLoaderExt.cpp	Thu Sep 12 09:59:19 2019 -0700
@@ -32,6 +32,7 @@
 #include "classfile/modules.hpp"
 #include "classfile/systemDictionaryShared.hpp"
 #include "classfile/vmSymbols.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/filemap.hpp"
 #include "memory/resourceArea.hpp"
@@ -146,7 +147,7 @@
       if (found != NULL) {
         // Same behavior as jdk/src/share/classes/java/util/jar/Attributes.java
         // 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"
                       "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);
@@ -276,7 +277,7 @@
   }
 
   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;
   }
 
@@ -295,7 +296,7 @@
                                                            THREAD);
 
   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 result;
--- a/src/hotspot/share/memory/filemap.cpp	Thu Sep 12 15:46:11 2019 +0100
+++ b/src/hotspot/share/memory/filemap.cpp	Thu Sep 12 09:59:19 2019 -0700
@@ -459,7 +459,7 @@
     if (e->is_dir()) {
       const char* path = e->name();
       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;
       }
     }
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Thu Sep 12 15:46:11 2019 +0100
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Thu Sep 12 09:59:19 2019 -0700
@@ -1814,7 +1814,7 @@
       if (klass == NULL &&
           (PENDING_EXCEPTION->klass()->name() == vmSymbols::java_lang_ClassNotFoundException())) {
         // 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;
     }
@@ -1860,7 +1860,7 @@
     ik->link_class(THREAD);
     if (HAS_PENDING_EXCEPTION) {
       ResourceMark rm;
-      tty->print_cr("Preload Warning: Verification failed for %s",
+      log_warning(cds)("Preload Warning: Verification failed for %s",
                     ik->external_name());
       CLEAR_PENDING_EXCEPTION;
       ik->set_in_error_state();