[ https://issues.apache.org/jira/browse/MATH-742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13211121#comment-13211121 ]
Gilles commented on MATH-742: ----------------------------- bq. Do you mean that if you corrected this and made them transient, you would introduce an incompatibility with objects serialized using older versions of the class? If not that, then could you explain? [...] It was an example of a case where the appropriate serialization code might be missing. In other words, because it is so simple to add "Serializable" _just in case_, we create problems for later. My main point is that CM should not spend its scarce human resources to provide features (in that case: support for serialization) that _should_ require careful planning. But if people want to contribute, they will bring the feature, together with the necessary unit testing. Personally, I think that there should be a commitment to *support* the feature... However, as you've understood, my preference would really be to drop all "Serializable" but the indispensable (I was convinced by the remotely-generated exception use case). This case will also give you the example of implementing the explicit serialization methods (if that's what you asked): Have a look at the "ExceptionContext" class (in package "o.a.c.m.exception.util"). In CM, the trends is currently going towards having "immutable" classes. The constructors' precondition checks guarantee the state of the object and people who want that serialization provides the same guarantee (where "good Java programming" includes robustness) have come up with the idiom which I've adapted above for "PolynomialSplineFunction". > Please make PolynomialSplineFunction Serializable > ------------------------------------------------- > > Key: MATH-742 > URL: https://issues.apache.org/jira/browse/MATH-742 > Project: Commons Math > Issue Type: Improvement > Affects Versions: 2.2 > Reporter: Neil Roeth > Priority: Minor > Attachments: PolynomialSplineFunction.java > > > PolynomialSplineFunction is not Serializable, while the very similar > PolynomialFunction class in the same package is. All that needs to be done is > to add the import: > {{import java.io.Serializable;}} > and change this: > {{public class PolynomialSplineFunction implements > DifferentiableUnivariateRealFunction}} > to this: > {{public class PolynomialSplineFunction implements > DifferentiableUnivariateRealFunction, Serializable}} > I made exactly that modification to a local copy and it serialized > successfully. Before the change, I got serialization errors. > Thanks. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira