Menu

#18 Remove Interp finalizer

open
nobody
None
5
2008-03-21
2008-03-21
No

Removes the 'finalize' method from Jacl Interp.java. Use of 'finalize()' is discouraged in modern Java. This patch simply removes the finalize method.

Discussion

  • Tom Poindexter

    Tom Poindexter - 2008-03-21

    tcljava.interp.finalizer.patch

     
  • Mo DeJong

    Mo DeJong - 2008-12-13

    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.

     
  • Tom Poindexter

    Tom Poindexter - 2008-12-15

    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?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.