Commit 119afc37 by Tom Tromey Committed by Tom Tromey

re PR classpath/26990 (SecurityManager.checkExit() problem)

	PR libgcj/26990:
	* prims.cc (_Jv_RunMain): Use exitNoChecksAccessor.
	* gnu/java/lang/natMainThread.cc (call_main): Use
	exitNoChecksAccessor.
	* testsuite/libjava.lang/pr26990.out: New file.
	* testsuite/libjava.lang/pr26990.java: New file.
	* java/lang/Runtime.java (exitNoChecks): New method.
	(exitNoChecksAccessor): Likewise.
	(exit): Call exitNoChecks.

From-SVN: r112685
parent 4b1c1f6f
2006-04-04 Tom Tromey <tromey@redhat.com>
PR libgcj/26990:
* prims.cc (_Jv_RunMain): Use exitNoChecksAccessor.
* gnu/java/lang/natMainThread.cc (call_main): Use
exitNoChecksAccessor.
* testsuite/libjava.lang/pr26990.out: New file.
* testsuite/libjava.lang/pr26990.java: New file.
* java/lang/Runtime.java (exitNoChecks): New method.
(exitNoChecksAccessor): Likewise.
(exit): Call exitNoChecks.
2006-04-03 Tom Tromey <tromey@redhat.com> 2006-04-03 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt. * Makefile.in: Rebuilt.
......
...@@ -57,6 +57,5 @@ gnu::java::lang::MainThread::call_main (void) ...@@ -57,6 +57,5 @@ gnu::java::lang::MainThread::call_main (void)
_Jv_ThreadWait (); _Jv_ThreadWait ();
int status = (int) ::java::lang::ThreadGroup::had_uncaught_exception; int status = (int) ::java::lang::ThreadGroup::had_uncaught_exception;
::java::lang::Runtime *runtime = ::java::lang::Runtime::getRuntime (); ::java::lang::Runtime::exitNoChecksAccessor (status);
runtime->exit (status);
} }
...@@ -146,9 +146,20 @@ public class Runtime ...@@ -146,9 +146,20 @@ public class Runtime
SecurityManager sm = SecurityManager.current; // Be thread-safe! SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null) if (sm != null)
sm.checkExit(status); sm.checkExit(status);
exitNoChecks(status);
}
// Accessor to avoid adding a vtable slot.
static void exitNoChecksAccessor(int status)
{
current.exitNoChecks(status);
}
// Private since we can't add a vtable slot in 4.1.x.
private void exitNoChecks(int status)
{
if (runShutdownHooks()) if (runShutdownHooks())
halt(status); exitInternal(status);
// Someone else already called runShutdownHooks(). // Someone else already called runShutdownHooks().
// Make sure we are not/no longer in the shutdownHooks set. // Make sure we are not/no longer in the shutdownHooks set.
...@@ -171,7 +182,7 @@ public class Runtime ...@@ -171,7 +182,7 @@ public class Runtime
// while finalization for exit is going on and the status is non-zero // while finalization for exit is going on and the status is non-zero
// we halt immediately. // we halt immediately.
if (status != 0) if (status != 0)
halt(status); exitInternal(status);
while (true) while (true)
try try
......
...@@ -1525,7 +1525,7 @@ _Jv_RunMain (JvVMInitArgs *vm_args, jclass klass, const char *name, int argc, ...@@ -1525,7 +1525,7 @@ _Jv_RunMain (JvVMInitArgs *vm_args, jclass klass, const char *name, int argc,
("Exception during runtime initialization")); ("Exception during runtime initialization"));
t->printStackTrace(); t->printStackTrace();
if (runtime) if (runtime)
runtime->exit (1); java::lang::Runtime::exitNoChecksAccessor (1);
// In case the runtime creation failed. // In case the runtime creation failed.
::exit (1); ::exit (1);
} }
......
public class pr26990
{
public static void main (String args[]) throws Exception
{
System.setSecurityManager(new SecurityManager()
{
public void checkExit(int status)
{
throw new SecurityException("This is a bug");
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment