From d297e129e86a67559b4bc168d70b8bab75f8a044 Mon Sep 17 00:00:00 2001 From: Danil Sokolov Date: Sun, 22 Nov 2026 12:22:40 +0000 Subject: [PATCH 1/2] Remove finalize() from DockingSplitPane finalize() only called cleanup(), which clears a field of an object that is already unreachable, so it freed nothing. A finalizer delays garbage collection, and finalize() is deprecated for removal (JEP 421). DefaultDockingPort already calls cleanup() when it discards a split pane. --- .../flexdock/docking/defaults/DockingSplitPane.java | 10 ++-------- release-notes.txt | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/flexdock-core/src/main/java/org/flexdock/docking/defaults/DockingSplitPane.java b/flexdock-core/src/main/java/org/flexdock/docking/defaults/DockingSplitPane.java index 1aaad73e..2fff5431 100644 --- a/flexdock-core/src/main/java/org/flexdock/docking/defaults/DockingSplitPane.java +++ b/flexdock-core/src/main/java/org/flexdock/docking/defaults/DockingSplitPane.java @@ -332,9 +332,8 @@ public void doLayout() { /** * Releases any internal references to external objects to aid garbage - * collection. This method is {@code public} and may be invoked manually for - * proactive memory management. Otherwise, this method is invoked by this - * {@code DockingSplitPane's} {@code finalize()} method. + * collection. {@code DefaultDockingPort} invokes it when it discards this + * split pane; it may also be invoked manually. */ public void cleanup() { dockingPort = null; @@ -358,9 +357,4 @@ public void setInitialDividerRatio(double ratio) { initialDividerRatio = ratio; } - @Override - protected void finalize() throws Throwable { - cleanup(); - super.finalize(); - } } diff --git a/release-notes.txt b/release-notes.txt index b0bb8f5f..2503bc7c 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -10,6 +10,8 @@ Updates: * Persist the selected tab of each tabbed docking group in the layout; if none is stored, restore the last tab (as before), or the first tab after DockingManager.setSelectFirstTabByDefault(true) +* DockingSplitPane: remove finalize(), which freed nothing (deprecated for + removal since Java 18) Fixes: * DockingPathSerializer: read all split nodes of a stored docking path From f7c89ba31ee4e941388ba8e62f6864c2b8657d8f Mon Sep 17 00:00:00 2001 From: Danil Sokolov Date: Sun, 22 Nov 2026 12:33:48 +0000 Subject: [PATCH 2/2] Remove finalize() from demo MediaPanel finalize() closed the JMF player, but a finalizer may never run and delays garbage collection, and finalize() is deprecated for removal (JEP 421). The demo exits the JVM on close, which releases the player. removeNotify() is no replacement: a docked panel leaves the component tree on every redock. --- .../main/java/org/flexdock/demos/raw/jmf/MediaPanel.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/flexdock-demo/src/main/java/org/flexdock/demos/raw/jmf/MediaPanel.java b/flexdock-demo/src/main/java/org/flexdock/demos/raw/jmf/MediaPanel.java index 175491b8..ad55821f 100644 --- a/flexdock-demo/src/main/java/org/flexdock/demos/raw/jmf/MediaPanel.java +++ b/flexdock-demo/src/main/java/org/flexdock/demos/raw/jmf/MediaPanel.java @@ -154,15 +154,6 @@ private static URL replaceJarUrlWithFileUrl(URL url, String mediaUri) throws IOE return f.toURL(); } - @Override - protected void finalize() { - if(player!=null) { - player.stop(); - player.close(); - player = null; - } - } - @Override public Component getDragSource() { return titlebar;