<Beans Dev>  Review Request: 8131754 AquaTreeUI.getCollapsedIcon() issue reported in java beans tests with a modular build
Sergey.Bylokhov at oracle.com
Mon Nov 9 18:19:27 UTC 2015
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)
JComponent-B (default component orientation)
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
Webrev can be found at: http://cr.openjdk.java.net/~serb/8131754/webrev.00
Best regards, Sergey.
More information about the beans-dev