RFR: 8362291: [macOS] Remove finalize method in CGraphicsEnvironment.java

Sergey Bylokhov serb at openjdk.org
Tue Jul 15 21:17:41 UTC 2025


On Tue, 15 Jul 2025 20:42:15 GMT, Phil Race <prr at openjdk.org> wrote:

> Remove a finalize() method in CGraphicsEnvironment, replacing it with Disposer.
> 
> I don't see a way to add a test to verify this clean up.

src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java line 153:

> 151:         }
> 152: 
> 153:         public synchronized void dispose() {

Why the method is synchronized? we can call it on a different threads via Disposer?

src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java line 154:

> 152: 
> 153:         public synchronized void dispose() {
> 154:             if (displayReconfigContext != 0L) {

can it be 0 here? it seems we never register 0 pointer, and we have a guard in native to be safe.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26332#discussion_r2208694333
PR Review Comment: https://git.openjdk.org/jdk/pull/26332#discussion_r2208693159


More information about the client-libs-dev mailing list