< prev index next >

src/share/vm/classfile/javaClasses.cpp

Print this page

        

@@ -1491,22 +1491,10 @@
 void java_lang_Throwable::clear_stacktrace(oop throwable) {
   set_stacktrace(throwable, NULL);
 }
 
 
-void java_lang_Throwable::print(oop throwable, outputStream* st) {
-  ResourceMark rm;
-  Klass* k = throwable->klass();
-  assert(k != NULL, "just checking");
-  st->print("%s", k->external_name());
-  oop msg = message(throwable);
-  if (msg != NULL) {
-    st->print(": %s", java_lang_String::as_utf8_string(msg));
-  }
-}
-
-
 void java_lang_Throwable::print(Handle throwable, outputStream* st) {
   ResourceMark rm;
   Klass* k = throwable->klass();
   assert(k != NULL, "just checking");
   st->print("%s", k->external_name());

@@ -1731,16 +1719,19 @@
 const char* java_lang_Throwable::no_stack_trace_message() {
   return "\t<<no stack trace available>>";
 }
 
 
-// Currently used only for exceptions occurring during startup
-void java_lang_Throwable::print_stack_trace(oop throwable, outputStream* st) {
-  Thread *THREAD = Thread::current();
-  Handle h_throwable(THREAD, throwable);
-  while (h_throwable.not_null()) {
-    objArrayHandle result (THREAD, objArrayOop(backtrace(h_throwable())));
+void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st) {
+  // First, print the message.
+  print(throwable, st);
+  st->cr();
+
+  // Now print the stack trace.
+  Thread* THREAD = Thread::current();
+  while (throwable.not_null()) {
+    objArrayHandle result (THREAD, objArrayOop(backtrace(throwable())));
     if (result.is_null()) {
       st->print_raw_cr(no_stack_trace_message());
       return;
     }
 

@@ -1768,24 +1759,24 @@
   handle_cause:
     {
       EXCEPTION_MARK;
       JavaValue cause(T_OBJECT);
       JavaCalls::call_virtual(&cause,
-                              h_throwable,
-                              KlassHandle(THREAD, h_throwable->klass()),
+                              throwable,
+                              KlassHandle(THREAD, throwable->klass()),
                               vmSymbols::getCause_name(),
                               vmSymbols::void_throwable_signature(),
                               THREAD);
       // Ignore any exceptions. we are in the middle of exception handling. Same as classic VM.
       if (HAS_PENDING_EXCEPTION) {
         CLEAR_PENDING_EXCEPTION;
-        h_throwable = Handle();
+        throwable = Handle();
       } else {
-        h_throwable = Handle(THREAD, (oop) cause.get_jobject());
-        if (h_throwable.not_null()) {
+        throwable = Handle(THREAD, (oop) cause.get_jobject());
+        if (throwable.not_null()) {
           st->print("Caused by: ");
-          print(h_throwable, st);
+          print(throwable, st);
           st->cr();
         }
       }
     }
   }
< prev index next >