8152845: Improve PackageEntry and ModuleEntry print methods for future logging
authorrprotacio
Thu, 14 Apr 2016 09:46:03 -0400
changeset 37503 77531df4dad3
parent 37437 f824aabc7af8
child 37504 6bae5fb1b715
8152845: Improve PackageEntry and ModuleEntry print methods for future logging Summary: Changed print methods for PackageEntry and ModuleEntry to take an outputStream Reviewed-by: lfoltan, hseigel, coleenp
hotspot/src/share/vm/classfile/moduleEntry.cpp
hotspot/src/share/vm/classfile/moduleEntry.hpp
hotspot/src/share/vm/classfile/packageEntry.cpp
hotspot/src/share/vm/classfile/packageEntry.hpp
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp	Fri Apr 08 13:14:23 2016 +0200
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp	Thu Apr 14 09:46:03 2016 -0400
@@ -36,6 +36,7 @@
 #include "utilities/events.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/hashtable.inline.hpp"
+#include "utilities/ostream.hpp"
 
 ModuleEntry* ModuleEntryTable::_javabase_module = NULL;
 
@@ -359,31 +360,29 @@
   java_lang_Class::set_fixup_module_field_list(NULL);
 }
 
-#ifndef PRODUCT
-void ModuleEntryTable::print() {
-  tty->print_cr("Module Entry Table (table_size=%d, entries=%d)",
-                table_size(), number_of_entries());
+void ModuleEntryTable::print(outputStream* st) {
+  st->print_cr("Module Entry Table (table_size=%d, entries=%d)",
+               table_size(), number_of_entries());
   for (int i = 0; i < table_size(); i++) {
     for (ModuleEntry* probe = bucket(i);
                               probe != NULL;
                               probe = probe->next()) {
-      probe->print();
+      probe->print(st);
     }
   }
 }
 
-void ModuleEntry::print() {
+void ModuleEntry::print(outputStream* st) {
   ResourceMark rm;
-  tty->print_cr("entry "PTR_FORMAT" name %s module "PTR_FORMAT" loader %s version %s location %s strict %s next "PTR_FORMAT,
-                p2i(this),
-                name() == NULL ? UNNAMED_MODULE : name()->as_C_string(),
-                p2i(module()),
-                loader()->loader_name(),
-                version() != NULL ? version()->as_C_string() : "NULL",
-                location() != NULL ? location()->as_C_string() : "NULL",
-                BOOL_TO_STR(!can_read_all_unnamed()), p2i(next()));
+  st->print_cr("entry "PTR_FORMAT" name %s module "PTR_FORMAT" loader %s version %s location %s strict %s next "PTR_FORMAT,
+               p2i(this),
+               name() == NULL ? UNNAMED_MODULE : name()->as_C_string(),
+               p2i(module()),
+               loader()->loader_name(),
+               version() != NULL ? version()->as_C_string() : "NULL",
+               location() != NULL ? location()->as_C_string() : "NULL",
+               BOOL_TO_STR(!can_read_all_unnamed()), p2i(next()));
 }
-#endif
 
 void ModuleEntryTable::verify() {
   int element_count = 0;
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp	Fri Apr 08 13:14:23 2016 +0200
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp	Thu Apr 14 09:46:03 2016 -0400
@@ -33,6 +33,7 @@
 #include "trace/traceMacros.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/hashtable.hpp"
+#include "utilities/ostream.hpp"
 
 #define UNNAMED_MODULE "Unnamed Module"
 
@@ -141,7 +142,7 @@
   void purge_reads();
   void delete_reads();
 
-  void print() PRODUCT_RETURN;
+  void print(outputStream* st = tty);
   void verify();
 };
 
@@ -223,7 +224,7 @@
   static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
   static void patch_javabase_entries(Handle module_handle);
 
-  void print() PRODUCT_RETURN;
+  void print(outputStream* st = tty);
   void verify();
 };
 
--- a/hotspot/src/share/vm/classfile/packageEntry.cpp	Fri Apr 08 13:14:23 2016 +0200
+++ b/hotspot/src/share/vm/classfile/packageEntry.cpp	Thu Apr 14 09:46:03 2016 -0400
@@ -32,6 +32,7 @@
 #include "utilities/events.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/hashtable.inline.hpp"
+#include "utilities/ostream.hpp"
 
 // Return true if this package is exported to m.
 bool PackageEntry::is_qexported_to(ModuleEntry* m) const {
@@ -265,28 +266,26 @@
   }
 }
 
-#ifndef PRODUCT
-void PackageEntryTable::print() {
-  tty->print_cr("Package Entry Table (table_size=%d, entries=%d)",
-                table_size(), number_of_entries());
+void PackageEntryTable::print(outputStream* st) {
+  st->print_cr("Package Entry Table (table_size=%d, entries=%d)",
+               table_size(), number_of_entries());
   for (int i = 0; i < table_size(); i++) {
     for (PackageEntry* probe = bucket(i);
                        probe != NULL;
                        probe = probe->next()) {
-      probe->print();
+      probe->print(st);
     }
   }
 }
 
-void PackageEntry::print() {
+void PackageEntry::print(outputStream* st) {
   ResourceMark rm;
-  tty->print_cr("package entry "PTR_FORMAT" name %s module %s classpath_index "
-                INT32_FORMAT " is_exported %d is_exported_allUnnamed %d " "next "PTR_FORMAT,
-                p2i(this), name()->as_C_string(),
-                (module()->is_named() ? module()->name()->as_C_string() : UNNAMED_MODULE),
-                _classpath_index, _is_exported, _is_exported_allUnnamed, p2i(next()));
+  st->print_cr("package entry "PTR_FORMAT" name %s module %s classpath_index "
+               INT32_FORMAT " is_exported %d is_exported_allUnnamed %d " "next "PTR_FORMAT,
+               p2i(this), name()->as_C_string(),
+               (module()->is_named() ? module()->name()->as_C_string() : UNNAMED_MODULE),
+               _classpath_index, _is_exported, _is_exported_allUnnamed, p2i(next()));
 }
-#endif
 
 void PackageEntryTable::verify() {
   int element_count = 0;
--- a/hotspot/src/share/vm/classfile/packageEntry.hpp	Fri Apr 08 13:14:23 2016 +0200
+++ b/hotspot/src/share/vm/classfile/packageEntry.hpp	Thu Apr 14 09:46:03 2016 -0400
@@ -29,6 +29,7 @@
 #include "oops/symbol.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/hashtable.hpp"
+#include "utilities/ostream.hpp"
 
 // A PackageEntry basically represents a Java package.  It contains:
 //   - Symbol* containing the package's name.
@@ -144,7 +145,7 @@
   void purge_qualified_exports();
   void delete_qualified_exports();
 
-  void print() PRODUCT_RETURN;
+  void print(outputStream* st = tty);
   void verify();
 };
 
@@ -195,7 +196,7 @@
   // purge dead weak references out of exported list
   void purge_all_package_exports();
 
-  void print() PRODUCT_RETURN;
+  void print(outputStream* st = tty);
   void verify();
 };