Why is this patch needed? The logic just prints to stderr in the case where an interp
was not cleaned up via a call to Interp.dispose() in the normal code. I agree that the
finalize method is mostly useless, but it does do something to try to help to user catch
a real error that can't be discovered any other way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
tcljava.interp.finalizer.patch
Why is this patch needed? The logic just prints to stderr in the case where an interp
was not cleaned up via a call to Interp.dispose() in the normal code. I agree that the
finalize method is mostly useless, but it does do something to try to help to user catch
a real error that can't be discovered any other way.
Here's a good summary (under "Finalizers are not your friend")
http://www.ibm.com/developerworks/library/j-jtp01274.html
The fact that they are unreliable make them a poor debugging tool:
public class TestFin {
public static void main(String[] args) throws Exception {
tcl.lang.Interp interp = new tcl.lang.Interp();
interp.eval("puts exiting....");
}
}
$ java -cp 'tcljava.jar;jacl.jar;.' TestFin
exiting....
tpoindex@XXXXX ~/src/testfin
$
For my Aejaks project where I allocate and dispose of many Interps, finalize() means
interpreters may hang around as garbage longer than I'd like.
Perhaps create an InterpDebug class, that extends Interp and includes the finalizer?