< prev index next >

src/hotspot/share/oops/oop.cpp

Print this page

        

@@ -37,11 +37,19 @@
 #include "utilities/copy.hpp"
 
 bool always_do_update_barrier = false;
 
 void oopDesc::print_on(outputStream* st) const {
-  klass()->oop_print_on(oop(this), st);
+  if (this == NULL) {
+    st->print_cr("NULL");
+  } else if (*((juint*)this) == badHeapWordVal) {
+    st->print("BAD WORD");
+  } else if (*((juint*)this) == badMetaWordVal) {
+    st->print("BAD META WORD");
+  } else {
+    klass()->oop_print_on(oop(this), st);
+  }
 }
 
 void oopDesc::print_address_on(outputStream* st) const {
   st->print("{" INTPTR_FORMAT "}", p2i(this));
 

@@ -67,16 +75,20 @@
   print_value_on(&st);
   return st.as_string();
 }
 
 void oopDesc::print_value_on(outputStream* st) const {
-  oop obj = oop(this);
-  if (java_lang_String::is_instance(obj)) {
-    java_lang_String::print(obj, st);
-    print_address_on(st);
+  if (this == NULL) {
+    st->print("NULL");
   } else {
-    klass()->oop_print_value_on(obj, st);
+    oop obj = oop(this);
+    if (java_lang_String::is_instance(obj)) {
+      java_lang_String::print(obj, st);
+      print_address_on(st);
+    } else {
+      klass()->oop_print_value_on(obj, st);
+    }
   }
 }
 
 
 void oopDesc::verify_on(outputStream* st, oopDesc* oop_desc) {
< prev index next >