Fix JIDE/Windows-LookAndFeel crash on non-Windows JDKs

JIDE 3.6.18's LookAndFeelFactory contains compile-time
\`instanceof com.sun.java.swing.plaf.windows.WindowsLookAndFeel\` checks in
multiple methods, including a JIDE PropertyChangeListener that fires on every
UIManager.setLookAndFeel call.  On Linux and macOS JDKs the class is genuinely
absent from java.desktop, so the JVM throws NoClassDefFoundError the first time
JIDE's dispatch code is executed (during JFrame init and again from
JideSplitPane.updateUI on each LAF change).

Two complementary fixes:

1. Pass an explicit MetalLookAndFeel instance to the 3-arg
   installJideExtension(UIDefaults, LookAndFeel, int) overload so JIDE's Metal
   branch matches first and never falls through to the Windows branch in the
   normal install path.

2. Add a no-op stub class at com.sun.java.swing.plaf.windows.WindowsLookAndFeel
   so that the compile-time class reference resolves on non-Windows JDKs.  The
   stub reports isSupportedLookAndFeel = false and is never instantiated -
   JIDE only uses it for instanceof comparisons against the active LAF, which
   always return false in our setup.  On Windows JDKs the real class in
   java.desktop is loaded by the platform classloader and shadows this stub.
This commit is contained in:
Akumas_Coffin_
2026-05-14 20:25:07 +10:00
parent 566159198e
commit 8871adc4a0
2 changed files with 90 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ import javafx.application.Platform;
import javafx.scene.Scene;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -259,11 +260,14 @@ public class ThemeManager
try
{
//JIDE components (split panes, docking) need their UI delegates re-registered
//after every LAF change. Pass an explicit style: the no-arg version probes
//com.sun.java.swing.plaf.windows.WindowsLookAndFeel which is not present on
//non-Windows JDKs, throwing ClassNotFoundException at startup.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.VSNET_STYLE);
//JIDE 3.6.18 has compile-time `instanceof WindowsLookAndFeel` checks throughout
//LookAndFeelFactory. On Linux/macOS JDKs that class is not present at all, so any
//call path that reaches those checks fails with NoClassDefFoundError. The 3-arg
//overload lets us hand JIDE an explicit Metal LAF instance for *type detection*
//while leaving the real (FlatLaf) defaults table in place; JIDE's Metal branch
//matches first and the Windows branch is never reached.
LookAndFeelFactory.installJideExtension(UIManager.getLookAndFeelDefaults(),
new MetalLookAndFeel(), LookAndFeelFactory.VSNET_STYLE);
}
catch(Throwable t)
{