8143963: improve ClassLoader::trace_class_path to accept an additional outputStream* arg
authorccheung
Tue, 24 Nov 2015 16:58:45 -0800
changeset 34287 06ababebbd58
parent 34279 92de270a7364
child 34288 49b4186f5dce
8143963: improve ClassLoader::trace_class_path to accept an additional outputStream* arg Summary: for fixing a truncation problem on the output from -XX:+TraceClassPaths Reviewed-by: coleenp, jiangli, cjplummer, minqi
hotspot/src/share/vm/classfile/classLoader.cpp
hotspot/src/share/vm/classfile/classLoader.hpp
hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp
hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp
hotspot/src/share/vm/runtime/arguments.cpp
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Tue Nov 24 22:54:30 2015 +0000
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Tue Nov 24 16:58:45 2015 -0800
@@ -414,30 +414,30 @@
 }
 #endif
 
-void ClassLoader::trace_class_path(const char* msg, const char* name) {
+void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
   if (!TraceClassPaths) {
     return;
   }
 
   if (msg) {
-    tty->print("%s", msg);
+    out->print("%s", msg);
   }
   if (name) {
     if (strlen(name) < 256) {
-      tty->print("%s", name);
+      out->print("%s", name);
     } else {
       // For very long paths, we need to print each character separately,
       // as print_cr() has a length limit
       while (name[0] != '\0') {
-        tty->print("%c", name[0]);
+        out->print("%c", name[0]);
         name++;
       }
     }
   }
   if (msg && msg[0] == '[') {
-    tty->print_cr("]");
+    out->print_cr("]");
   } else {
-    tty->cr();
+    out->cr();
   }
 }
 
@@ -466,7 +466,7 @@
     // 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("[Bootstrap loader class path=", sys_class_path);
+    trace_class_path(tty, "[Bootstrap loader class path=", sys_class_path);
   }
 #if INCLUDE_CDS
   if (DumpSharedSpaces) {
--- a/hotspot/src/share/vm/classfile/classLoader.hpp	Tue Nov 24 22:54:30 2015 +0000
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp	Tue Nov 24 16:58:45 2015 -0800
@@ -328,7 +328,7 @@
   static void  exit_with_path_failure(const char* error, const char* message);
 #endif
 
-  static void  trace_class_path(const char* msg, const char* name = NULL);
+  static void  trace_class_path(outputStream* out, const char* msg, const char* name = NULL);
 
   // VM monitoring and management support
   static jlong classloader_time_ms();
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp	Tue Nov 24 22:54:30 2015 +0000
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp	Tue Nov 24 16:58:45 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -67,7 +67,7 @@
 }
 
 bool SharedPathsMiscInfo::fail(const char* msg, const char* name) {
-  ClassLoader::trace_class_path(msg, name);
+  ClassLoader::trace_class_path(tty, msg, name);
   MetaspaceShared::set_archive_loading_failed();
   return false;
 }
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp	Tue Nov 24 22:54:30 2015 +0000
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp	Tue Nov 24 16:58:45 2015 -0800
@@ -65,7 +65,7 @@
   bool read(void* ptr, size_t size);
 
   static void trace_class_path(const char* msg, const char* name = NULL) {
-    ClassLoader::trace_class_path(msg, name);
+    ClassLoader::trace_class_path(tty, msg, name);
   }
 protected:
   static bool fail(const char* msg, const char* name = NULL);
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Tue Nov 24 22:54:30 2015 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Tue Nov 24 16:58:45 2015 -0800
@@ -3425,7 +3425,7 @@
   }
 
   if (!PrintSharedArchiveAndExit) {
-    ClassLoader::trace_class_path("[classpath: ", _java_class_path->value());
+    ClassLoader::trace_class_path(tty, "[classpath: ", _java_class_path->value());
   }
 }