<Swing Dev> RFR: 8240709: Enable javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java on all L&F
Sergey Bylokhov
serb at openjdk.java.net
Sun Oct 11 21:40:17 UTC 2020
On Sun, 11 Oct 2020 21:26:06 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
> Fix for various memory leaks in Nimbus and Motif L&Fs, see comments inline.
src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java line 113:
> 111: if (iconPane instanceof JToggleButton) {
> 112: ((JToggleButton)iconPane).removeActionListener(handler);
> 113: frame.removePropertyChangeListener(this);
This code is never executed, the iconPane is null here, it is moved above to the uninstallComponents()
src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java line 757:
> 755:
> 756: public void unregister() {
> 757: comboBox.removePropertyChangeListener("editor", this);
The listener is added as "comboBox.addPropertyChangeListener("editor",this);" and should be removed by the pair API.
src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java line 71:
> 69: };
> 70:
> 71: SwingUtilities.invokeLater( initCode );
This code was added in 1998, the intention was to postpone the initialization of the editor's background till
everything in the combo box will be initialized, but:
- Since then we have a special method configureEditor() which called every time the editor is changed and sets the
correct background (see below in this file)
- If the L&F will be changed to something else the posted event will "poison" the background of the editor by the "motif
color".
test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java line 94:
> 92: for (LookAndFeelInfo laf : getInstalledLookAndFeels()) {
> 93: String name = laf.getName();
> 94: if (name.contains("OS X") || name.contains("Metal")) {
The test was checked on all platforms via mach5
-------------
PR: https://git.openjdk.java.net/jdk/pull/595
More information about the swing-dev
mailing list