·
Finalization is a feature allowing to automatically do actions before the destruction of an object.
This feature presents some problems:
👉 it delays the execution of this action to the Garbage Collector timeline.
👉 a badly shaped '𝒇𝒊𝒏𝒂𝒍𝒊𝒛𝒆()' method can even make an object recover from destruction
Since Java 9, '𝒇𝒊𝒏𝒂𝒍𝒊𝒛𝒆()' method deprecation made it as a not recommended method.
Rather, it is recommended to use the '𝒕𝒓𝒚-𝒘𝒊𝒕𝒉-𝒓𝒆𝒔𝒐𝒖𝒓𝒄𝒆𝒔' feature of the new '𝑪𝒍𝒆𝒂𝒏𝒆𝒓' API.
The 𝑱𝑬𝑷421 goes further by suppressing the finalization by deprecating for removal the finalization feature itself.
You can check if your code is 𝑱𝑬𝑷421 compliant with the JVM option '--𝒇𝒊𝒏𝒂𝒍𝒊𝒛𝒂𝒕𝒊𝒐𝒏=𝒅𝒊𝒔𝒂𝒃𝒍𝒆𝒅' switch.