Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 13 commits into from
10 changes: 5 additions & 5 deletions test/jdk/javax/swing/JTableHeader/SerializeJTableHeader.java
Original file line number Diff line number Diff line change
@@ -55,11 +55,11 @@ public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose to set LAF on EDT? You then continue with creating and serialising the component on the main thread.

Copy link
Contributor Author

@prsadhuk prsadhuk Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure if any event processing needs to be done for lookandfeel change particularly native l&f like GTK and Aqua.
Seems like it works with both EDT and non-EDT...tried with repeat count 50....so removed EDT usage...
however GTK is not supported on headless environment so made the test run on headful environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never thought about it… Yet if there's anything that depends on access to native platform, it probably needs to run on the toolkit thread.

I'm for keeping it simpler: if it works correctly on the main thread here, let's keep it this way.

JTableHeader jth = new JTableHeader();
for (int i = 0; i < 10; i++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
//System.out.println(jth.getUI());
oos.writeObject(jth);
oos.writeObject(jth.getAccessibleContext());
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(jth);
oos.writeObject(jth.getAccessibleContext());
}
}
}
}