Throwable.java (trace_enabled): New static field.
authorBryce McKinlay <bryce@albatross.co.nz>
Fri, 22 Dec 2000 06:19:24 +0000 (06:19 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Fri, 22 Dec 2000 06:19:24 +0000 (06:19 +0000)
* java/lang/Throwable.java (trace_enabled): New static field.
* java/lang/natThrowable.cc (fillInStackTrace): Do nothing if
trace_enabled not set.
* prims.cc (main_init): Turn off trace_enabled while creating
default exception objects.

From-SVN: r38442

libjava/ChangeLog
libjava/java/lang/Throwable.java
libjava/java/lang/natThrowable.cc
libjava/prims.cc

index 34b917512eb7f6d8624e8d9be244384751870059..f7ce1f3f29da671688d618665748ae7cec7740be 100644 (file)
@@ -1,3 +1,11 @@
+2000-12-22  Bryce McKinlay  <bryce@albatross.co.nz>
+
+       * java/lang/Throwable.java (trace_enabled): New static field.
+       * java/lang/natThrowable.cc (fillInStackTrace): Do nothing if
+       trace_enabled not set.
+       * prims.cc (main_init): Turn off trace_enabled while creating
+       default exception objects.
+
 2000-12-21  Tom Tromey  <tromey@redhat.com>
 
        * java/beans/PropertyChangeListener.java: Extends EventListener.
index 610a499a2cb41b4a23da2a3df01c5a86028733a1..4aa21399c5ab445b259e7bad21aacb1824ba0803 100644 (file)
@@ -164,6 +164,8 @@ public class Throwable implements Serializable
   // Name of this field comes from serialization spec.
   private String detailMessage;
 
+  // Setting this flag to false prevents fillInStackTrace() from running.
+  static boolean trace_enabled = true;
   private transient byte stackTrace[];
   private static final long serialVersionUID = -3042686055658047285L;
 }
index c7f19bec09d2e93aec757a1e90a28d6d43566c42..dab3ba6387a5f707ca7fdfc5f8c22c1ccf68c6d7 100644 (file)
@@ -50,6 +50,8 @@ extern "C" int __ia64_backtrace (void **array, int size);
 java::lang::Throwable *
 java::lang::Throwable::fillInStackTrace (void)
 {
+  if (! trace_enabled)
+    return this;
 #if defined (HAVE_BACKTRACE) || defined (__ia64__)
   void *p[128];
   
index c6b8d2030e1e8133d61b217e0ad0ca645e3ef122..06585749c5f4dd7f6ebd63e41b71b66a22f56a2a 100644 (file)
@@ -687,6 +687,10 @@ win32_exception_handler (LPEXCEPTION_POINTERS e)
 static void
 main_init ()
 {
+  // Turn stack trace generation off while creating exception objects.
+  _Jv_InitClass (&java::lang::Throwable::class$);
+  java::lang::Throwable::trace_enabled = 0;
+  
   INIT_SEGV;
 #ifdef HANDLE_FPE
   INIT_FPE;
@@ -697,6 +701,8 @@ main_init ()
 
   no_memory = new java::lang::OutOfMemoryError;
 
+  java::lang::Throwable::trace_enabled = 1;
+
 #ifdef USE_LTDL
   LTDL_SET_PRELOADED_SYMBOLS ();
 #endif