RFR: 6450193: After the first Serialization, JTableHeader does not uninstall its UI

Prasanta Sadhukhan psadhukhan at openjdk.org
Thu Aug 31 08:09:15 UTC 2023


After the first time a JTableHeader is serialized, it no longer will uninstall its UI upon subsequent serializations.
This happens for classes that use the BasicTableHeaderUI class. Any LAF that extends the BasicTableHeaderUI like SynthTableHeaderUI and WindowsTableHeaderUI will get an NotSerializableException thrown

Each time an JComponent instance is Serialized, a [counter ](https://github.com/openjdk/jdk/blob/218829e0a2a3ae5599b81733df53557966392033/src/java.desktop/share/classes/javax/swing/JComponent.java#L5644-L5645) for the instance is incremented. It is de-incremented in JComponent's writeObject or a class that implements it the same way, like JButton, JScrollPane etc..
With JTableHeader it does not deincrement the counter. The uninstall mechanism will not uninstall a UI if the counter is not 0 on the first pass..It is not possible to call JComponent.setWriteObjectCounter in JTableHeader as it is not in the same package so the fix is to remove the writeObject implementation and rely on JComponent writeObject implementation to make sure uninstallation of UI happens and also NotSerializableException does not happen for Synth

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

Commit messages:
 - 6450193: After the first Serialization, JTableHeader does not uninstall its UI
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge
 - Merge branch 'master' of github.com:prsadhuk/jdk
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Revert "Fix"
 - Fix

Changes: https://git.openjdk.org/jdk/pull/15507/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15507&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-6450193
  Stats: 89 lines in 2 files changed: 76 ins; 13 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/15507.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15507/head:pull/15507

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


More information about the client-libs-dev mailing list