JCEF java finalize method

Having problems with building or using the JCEF Java binding? Ask your questions here.

JCEF java finalize method

Postby dstueken » Fri Oct 04, 2024 11:39 am

After switching to java21 I got massive warnings about still using finalize().
Using finalization is deprecated since java 9 but was even deprecated for removal since java 19.
The https://openjdk.org/jeps/42 promises to support finalization for some time, but the door begins to close.

I found 21 overrides of finalize(). All of them are calling some cleanup/close/cancel/dispose method.
Some might better be enforced by a try/resource block. Others however, seem to be necessary i.E. to release the native memory.
I'm about to make a list of usages, but I'm not that familiar with the native code by now.

The future cleanup must not use this any more. But most final callbacks seem to relay on the N_CefHandle only.
This looks promising, but the native callback must become static then!
The Cleaner.Cleanable can easily hold a N_CefHandle, but must not have any reference pointer to the instance any more.

But the cleaner can be statefull: It may carry a boolean if it was already called once.

see: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ref/Cleaner.html

Dieter.
dstueken
Newbie
 
Posts: 1
Joined: Fri Apr 12, 2024 10:29 am

Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 1 guest