I am not convinced that one should have a custom finalize() method in a class that creates a socket.
I understand that finalize() can be used to clean up non-memory resources used by an object. And socket() uses a non-memory resource. However�
Read Item #6: Avoid finalizers in Effective
Java by Joshua Bloch.
The Java Programming Language says �
You should only rarely need to write a finalize() method�. I�ll bet people use socket() frequently rather than rarely.
In Java Network Programming by Harold (O�Reilly) there is no discussion on finalize(). In Java RMI by Grosso (O�Reilly) there is no discussion on finalize(). In Core Java II there is no discussion on finalize().
I searched the Sun Java Forums and found no advice on using finalize() when using socket(). What I gleaned from scanning the Sun Java Forums for use of the
word "finalize" is that nowadays people recommend using weak references and advise against using finalize().
I am tempted to post a question on the Sun Java Advanced Features forum and ask whether people who do socket() calls for a living ever use finalize().
[ March 16, 2003: Message edited by: Marlene Miller ]
[ March 16, 2003: Message edited by: Marlene Miller ]