This method explicitly invokes an object's finalize
method. Because finalizer methods are supposed to be executed once, and only by the JVM's internal code, this is a bad idea.
this.finalize();
If a connected set of objects is currently being finalized, there is a chance that the finalize
method of all such objects could be called at the same time by the JVM over multiple threads. If the finalize
method were to be invoked on such a connected object at the same time as its finalize
method was called by the JVM, it could cause a virtually impossible to diagnose race condition.
Remove the call to finalize
.
Note: Finalizers are deprecated since Java 9.