livesplit-core icon indicating copy to clipboard operation
livesplit-core copied to clipboard

[Java, JNA] `Object.finalize` is deprecated and subject to removal as of Java 9

Open cD1rtX3 opened this issue 4 months ago • 3 comments

cD1rtX3 avatar Aug 22 '25 09:08 cD1rtX3

It would be great if you could provide some code of how it's supposed to be done now.

CryZe avatar Aug 22 '25 09:08 CryZe

Java 9 has Cleaner, and if you can't use Java 9 features, you can reimplement it using PhantomReference, though it's a little complicated—this blog post seems helpful.

cD1rtX3 avatar Aug 26 '25 09:08 cD1rtX3

You could also have the classes implement AutoCloseable and require a try-with-resources construction or have the user free it manually.

cD1rtX3 avatar Dec 05 '25 22:12 cD1rtX3