3 ms·
Perhaps there may be objects that depend on the finalizer callback for correctnesss. I have seen people use finalizer to do things like close file handles, and
by jelllyounf 7y ago
Perhaps there may be objects that depend on the finalizer callback for correctnesss. I have seen people use finalizer to do things like close file handles, and presumably not calling close may not guarantee data is persisted.
- deleted 7y ago[deleted]
- jlokier 7y agoAt least on unix systems, process termination implicitly calls close() on every file descriptor anyway. There should be no need to call it explicitly. (You won't get the chance to log any write errors reported by close() or react to the errors, though.)
- vips7L 7y agoWho would do that? Effective Java specifically says not to rely on finalizers.
- pron 7y agoFinalizers were deprecated two years ago, and might be removed altogether in the not-too-distant-future.