The following are some quotes from Effective Java 2nd Edition: Point 7: Avoid Finalizers:
Finalizers are unpredictable, often dangerous and not needed at all . Their use can cause erratic behavior, poor performance, and portability problems. Finalizers have few valid uses, [...] as a rule, you should avoid finalizers.
You really have to make sure that you really need finalizers; most of the time you are NOT.
C ++ programmers are cautioned not to think of finalizers as the Java counterpart of C ++ destructors. In C ++, destructors are a normal way to recover resources associated with an object, a necessary analogue for constructors. In Java, the garbage collector restores the storage associated with the object when it becomes inaccessible, without requiring much effort from the programmer. C ++ destructors are also used to recover other memoryless resources. In Java, a try-finally block is usually used for this purpose.
It is also important to consider the semantics of including finalizers:
The Java programming language does not indicate how soon finalizer [... nor] will be called, which thread will call the finalizer for any given object. [...] If an uncaught exception occurs during finalization, the exception is ignored and the completion of this object ends. (JLS 12.6.2) Finalizer statements are not ordered
In addition, the only mechanism for starting the finalizer on demand is violated. The following quotes from Effective Java 2nd Edition:
[...] The only methods that claim to guarantee completion are System.runFinalizersOnExit and its evil twin, Runtime.runFinalizersOnExit . These methods are deadly wrong and outdated.
Bloch went further to comment on the execution penalty (emphasis it):
Oh, and there is one more thing: there is a serious performance limitation when using finalizers . On my machine, the creation and destruction time of a simple object is about 5.6ns. Adding a finalizer increases the time to 2400 ns. In other words, it is about 430 times slower to create and destroy objects with finalizers.
With such little details on the benchmarking methodology, I donβt think that specific numbers mean a lot, but it confirms what has been widely documented: finalizers are very expensive.
The book explains rare scenarios in which the use of finalizers is valid. The absence of these quotes from this answer is intentional.