Hello.
Please review the "small" fix for jdk9.

Description of the problem:
When the XMLEncoder writes the object to the stream it does not save the whole object as is(like the usual serialization). But it creates the object of the same class with default parameters and then saves only the difference between the two objects. Encoder checks recursively for difference the public fields and public properties(setters+getters) on current object and so on. Only transient fields and @Transient properties are skipped by encoder.

The tests from the bug causes an exception when running on the OSX, because it serialize the platform-specific data (part of Aqua L&F). This occurs because XMLEncoder tries to save the ui property of JComponent.

Scheme of objects:
JComponent-A (non-default component orientation)
   UI-a

JComponent-B (default component orientation)
   UI-b

Note that components A and B have different orientation, this indirectly changes some properties of UI-a, these changes are not important because they can be(and will be) restored from the component itself, but XMLEncoder treats ui as sensible fields and tries to save them to the stream.

As a fix I suggest to mark getUI() method as @Transient, this will allow the encoder to skip the changes in UI property. Note that the ui field in JComponent is transient already, but it affects the usual serialization only.


Bug: https://bugs.openjdk.java.net/browse/JDK-8131754
Webrev can be found at: http://cr.openjdk.java.net/~serb/8131754/webrev.00

--
Best regards, Sergey.

Reply via email to