Reputation: 8653
Effective Java item 7 says, finalizers cause portability issues.
Finalizers are unpredictable, often dangerous, and generally unnecessary. Their use can cause erratic behavior, poor performance, and portability problems.
But I could not understand Java being platform independent how finalizer can cause portability issues?
Upvotes: 1
Views: 44
Reputation: 200168
Finalizers usually contain code which releases non-JVM (system) resources. If resource management is entrusted to them, they create very unusual resource lifecycle patterns (a huge number of needlessly open resources + releasing thousands of resources at once). This does indeed sound dangerous and on each yet-untested platform it poses a threat of breaking unpredictably.
Upvotes: 4