-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid overriding finalize() #1465
Comments
I already made some PO to use Cleaner API instead: this has the advantage that one still can use |
here is a working commit that was rejected: |
Is there any reason why we can't let the Cleaner do the disposal, effectively making |
Aa cleaner depends on GC, which has literally no guaranties to run. Resources are OS objects which need to be released otherwise the OS runs in out of resource; and- a cleaner does not run in swt thread. |
My proposed solution: #1702 |
Is your feature request related to a problem? Please describe.
The current implementation to make Resource.setNonDisposehandler(Consumer) work, uses
finalize()
under the hood:eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Lines 74 to 81 in 4d68329
This method is deprecated for removal since Java 18 as described in JEP 421.
Describe the solution you'd like
We should rewrite this functionality using PhantomReferences and a daemon thread polling from the shared ReferenceQueue.
Describe alternatives you've considered
The cleaner API might also work:
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/Cleaner.html
The text was updated successfully, but these errors were encountered: