Finalizers are not destructors, finalizers are useless.
From what I hear a lot of Java resource Objects dispose on finalize() "just in case".
This seems an overly permissive attitude likely to lead to bugs.
The least you would want to do is for finalize to log errors(un disposed resources at finalization time) and print them to standard out and then dispose.
A more restrictive attitude might be to thow an exception instead.
I'm not necessarily going to implement such restrictive resource objects but I'd like to know how to do it.
But in Java an exception thrown in a finalizer gets ignored(other then the object being put back on the list to be finalized again). Is there a way to implement something like this? Maybe a way to give thread that created object an exception from the finalizer if it still exists(or possibly parent threads if not?
Also!!!!! How do other gc languages(especially C#,python and the like) deal with resource finalization(do they generally implement "just in case disposal" for resource classes?), throwing from finalizers, giving exeptions to other threads. (note: I don't care much about with/using sugar for calling dispose method or methods accepting closures that automatically close resource, I'm intrested in what role finalizers play and error propagation from finalizers).