jfreechart icon indicating copy to clipboard operation
jfreechart copied to clipboard

The EventListenerList declared in class Series should be transient.

Open grimlock81 opened this issue 3 years ago • 3 comments

Hi I have hit a problem in my application whereby a time series chart that was serialized in a Java 8 JRE cannot be deserialized in a Java 11 JRE.

Caused by: java.io.InvalidClassException: javax.swing.event.EventListenerList; local class incompatible: stream classdesc serialVersionUID = -5677132037850737084, local class serialVersionUID = -7977902244297240866

I have traced this down to the EventListenerList declared in org.jfree.data.general.Series

https://github.com/jfree/jfreechart/blob/768e0502995a9c55a48fc26d579fe5128ad43539/src/main/java/org/jfree/data/general/Series.java#L74

Because EventListenerList does not declare a serialVersionUID, it has a different generated value for different JRE versions. Hence this should not be serializable and needs to be declared transient. All other declarations and usages of EventListenerList in JFreeChart are declared as transient.

grimlock81 avatar Nov 19 '21 00:11 grimlock81

Assigning this one to myself - this relates to the work I've been doing with the equals/hashCode methods. I noticed that too, and (if memory serves) kept it as is, but left it out of the equals/hashCode and instructed. EqualsVerifier to ignore it.

tracylynne99 avatar Dec 11 '21 16:12 tracylynne99

This one is actually quite a big issue in cases where a series belongs to a dataset and the dataset is being serialised/deserialised. In this case, the deserialised dataset needs to ensure it is registered as a listener on each of the series that it contains. It doesn't look like this is that well tested nor that well implemented. I'm trying out some things to see what can be improved.

jfree avatar Jan 03 '22 04:01 jfree

Yeah, I found that out quickly! 🤦‍♀️🤦‍♀️🤦‍♀️

Tried dealing with it, got frustrated, set it aside 😂

On Sun, Jan 2, 2022 at 10:36 PM David Gilbert @.***> wrote:

This one is actually quite a big issue in cases where a series belongs to a dataset and the dataset is being serialised/deserialised. In this case, the deserialised dataset needs to ensure it is registered as a listener on each of the series that it contains. It doesn't look like this is that well tested nor that well implemented. I'm trying out some things to see what can be improved.

— Reply to this email directly, view it on GitHub https://github.com/jfree/jfreechart/issues/249#issuecomment-1003867891, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEKTYBCEJRKRWI6SBFL3GLUUERWTANCNFSM5IK45BZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.***>

tracylynne99 avatar Jan 03 '22 16:01 tracylynne99