RFR: 8362289: [macOS] Remove finalize method in JRSUIControls.java [v3]

Phil Race prr at openjdk.org
Wed Jul 16 21:39:13 UTC 2025


> Eliminate a finalize() method in the Swing macOS implementation.
> 
> I tested that the dispose method is being called by running this small test in combination with some 'println' statements in the source code (now removed)
> 
> import javax.swing.JTabbedPane;
> import javax.swing.plaf.TabbedPaneUI;
> 
> public class CreateTabbedPaneUIStressTest {
> 
>    public static void main(String[] args) {
>        for (int i=0; i<1000000000; i++) {
>            JTabbedPane jtp = new JTabbedPane();
>            TabbedPaneUI tpui = jtp.getUI();
>        }
>    }
> }
> 
> 
> I also monitored the process size using 'top'.
> And when I commented out the native call that did the free and re-tested I saw process size grow.
> 
> Turning the above into a useful regression test doesn't seem possible to me.
> Limiting Java heap is pointless (and I did use -Xmx20m) since it is a native resource that is to be freed and failure to dispose won't show up as a problem without taking down the machine.

Phil Race has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains four commits:

 - Merge branch 'master' into jrsuicontrols
 - 8362289
 - 8362289
 - 8362289

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

Changes: https://git.openjdk.org/jdk/pull/26331/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26331&range=02
  Stats: 19 lines in 1 file changed: 13 ins; 0 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/26331.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26331/head:pull/26331

PR: https://git.openjdk.org/jdk/pull/26331


More information about the client-libs-dev mailing list