mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
[java] Run finalisers only if main/2 returns normally
finalisers should be executed only if main/2 returns normally, it does not
throw an exception. The C backends already do this correctly but the Java
backend did not. The C# backend has the same bug, this patch does not fix
the C# backend.
java/runtime/MercuryThreadPool.java:
Add a parameter to the shutdown() method to specify whether the backend
is aborting.
In runMain(), run finalisers only if the runtime is exiting normally.
java/runtime/MercuryRuntime.java:
Add a new finalise() method that takes a parameter allowing standalone
Java applications to specify whether or not they are aborting when the
finalise the RTS.
doc/reference_manual.texi:
Specify the behaviour of finalise directives if main/2 terminates
with an uncaught exception.
samples/java_interface/standalone_java/JavaMain.java:
Conform to changes in MercuryRuntime.java.
This commit is contained in:
@@ -35,9 +35,11 @@ public class JavaMain {
|
||||
// This call will invoke any finalisers specified using
|
||||
// ':- finalise' declarations in the set of Mercury libraries we
|
||||
// are using. It also tells the thread pool to shutdown, if the
|
||||
// thread pool is not running then this does nothing.
|
||||
// thread pool is not running then this does nothing. Set the
|
||||
// parameter to "true" if the program is aborting (finalisers
|
||||
// will be skipped).
|
||||
//
|
||||
MercuryRuntime.finalise();
|
||||
MercuryRuntime.finalise(false);
|
||||
|
||||
// The Mercury exit status (as set by io.set_exit_status/1) may
|
||||
// be read from the MercuryRuntime class.
|
||||
|
||||
Reference in New Issue
Block a user