summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libjava/ChangeLog16
-rw-r--r--libjava/java/lang/ExceptionInInitializerError.java28
-rw-r--r--libjava/java/lang/Runtime.java6
-rw-r--r--libjava/java/lang/System.java2
-rw-r--r--libjava/java/lang/ThreadGroup.java14
-rw-r--r--libjava/java/lang/natRuntime.cc7
-rw-r--r--libjava/prims.cc2
7 files changed, 65 insertions, 10 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index ce7250e71cb..44a3bd830af 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,19 @@
+2001-03-12 Bryce McKinlay <bryce@albatross.co.nz>
+
+ * java/lang/Runtime.java (_exit): Declare new package-private native.
+ * java/lang/natRuntime.cc (_exit): Implemented. Same as exit() but
+ without a security manager check.
+ (exit): Call _exit after security check.
+ * prims.cc (JvRunMain): Call Runtime._exit to shutdown the runtime
+ "naturally".
+ * java/lang/System.java (setSecurityManager): If a security manager
+ is already in place, call checkPermission.
+ * java/lang/ThreadGroup.java (uncaughtException): If printStackTrace()
+ throws an exception, try to deal with it gracefully.
+ * java/lang/ExceptionInInitializerError.java (printStackTrace):
+ Only try to print the subordinate stack trace if "exception" is set.
+ Print our class name first.
+
2001-03-08 Tom Tromey <tromey@redhat.com>
* java/io/ObjectStreamClass.java (setUID): Don't write interface
diff --git a/libjava/java/lang/ExceptionInInitializerError.java b/libjava/java/lang/ExceptionInInitializerError.java
index 0aad2fc89ea..95b4311c174 100644
--- a/libjava/java/lang/ExceptionInInitializerError.java
+++ b/libjava/java/lang/ExceptionInInitializerError.java
@@ -1,6 +1,6 @@
// ExceptionInInitializerError.java
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj.
@@ -38,7 +38,7 @@ public class ExceptionInInitializerError extends LinkageError
public ExceptionInInitializerError (Throwable e)
{
- super ();
+ super (e.toString());
exception = e;
}
@@ -49,17 +49,35 @@ public class ExceptionInInitializerError extends LinkageError
public void printStackTrace ()
{
- exception.printStackTrace ();
+ if (exception != null)
+ {
+ System.err.print (this.getClass() + ": ");
+ exception.printStackTrace ();
+ }
+ else
+ super.printStackTrace ();
}
public void printStackTrace (PrintStream ps)
{
- exception.printStackTrace (ps);
+ if (exception != null)
+ {
+ ps.print (this.getClass() + ": ");
+ exception.printStackTrace (ps);
+ }
+ else
+ super.printStackTrace (ps);
}
public void printStackTrace (PrintWriter pw)
{
- exception.printStackTrace (pw);
+ if (exception != null)
+ {
+ pw.print (this.getClass() + ": ");
+ exception.printStackTrace (pw);
+ }
+ else
+ super.printStackTrace (pw);
}
// The exception that caused this error.
diff --git a/libjava/java/lang/Runtime.java b/libjava/java/lang/Runtime.java
index e746c60b384..28befc26d19 100644
--- a/libjava/java/lang/Runtime.java
+++ b/libjava/java/lang/Runtime.java
@@ -1,6 +1,6 @@
// Runtime.java - Runtime class.
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj.
@@ -63,6 +63,10 @@ public class Runtime
}
public native void exit (int status);
+
+ // Shutdown the runtime without a SecurityManager check. libgcj uses this
+ // exit function internally.
+ final native void _exit (int status);
public native long freeMemory ();
public native void gc ();
diff --git a/libjava/java/lang/System.java b/libjava/java/lang/System.java
index 162bc1f21eb..0f7bd7ba8b7 100644
--- a/libjava/java/lang/System.java
+++ b/libjava/java/lang/System.java
@@ -230,7 +230,7 @@ public final class System
public static void setSecurityManager (SecurityManager s)
{
if (secman != null)
- throw new SecurityException ();
+ secman.checkPermission(new RuntimePermission("setSecurityManager"));
secman = s;
}
diff --git a/libjava/java/lang/ThreadGroup.java b/libjava/java/lang/ThreadGroup.java
index e8b444682bb..bdf37f9ec9c 100644
--- a/libjava/java/lang/ThreadGroup.java
+++ b/libjava/java/lang/ThreadGroup.java
@@ -511,7 +511,19 @@ public class ThreadGroup
{
if (thread != null)
System.out.print("Exception in thread \"" + thread.getName() + "\" ");
- t.printStackTrace();
+ try
+ {
+ t.printStackTrace();
+ }
+ catch (Throwable x)
+ {
+ // This means that something is badly screwed up with the runtime,
+ // or perhaps someone is messing with the SecurityManager. In any
+ // case, try to deal with it gracefully.
+ System.out.println(t);
+ System.err.println("*** Got " + x.toString() +
+ " while trying to print stack trace");
+ }
had_uncaught_exception = true;
}
}
diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc
index 5ff7d2edacf..3f1a0b335fc 100644
--- a/libjava/java/lang/natRuntime.cc
+++ b/libjava/java/lang/natRuntime.cc
@@ -1,6 +1,6 @@
// natRuntime.cc - Implementation of native side of Runtime class.
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj.
@@ -78,7 +78,12 @@ void
java::lang::Runtime::exit (jint status)
{
checkExit (status);
+ _exit (status);
+}
+void
+java::lang::Runtime::_exit (jint status)
+{
// Make status right for Unix. This is perhaps strange.
if (status < 0 || status > 255)
status = 255;
diff --git a/libjava/prims.cc b/libjava/prims.cc
index 85264bb2cce..f68b2f049ba 100644
--- a/libjava/prims.cc
+++ b/libjava/prims.cc
@@ -850,7 +850,7 @@ JvRunMain (jclass klass, int argc, const char **argv)
int status = (int) java::lang::ThreadGroup::had_uncaught_exception;
- java::lang::Runtime::getRuntime ()->exit (status);
+ java::lang::Runtime::getRuntime ()->_exit (status);
}
void
OpenPOWER on IntegriCloud