commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neil Roeth (Commented) (JIRA)" <>
Subject [jira] [Commented] (MATH-742) Please make PolynomialSplineFunction Serializable
Date Sun, 19 Feb 2012 03:40:08 GMT


Neil Roeth commented on MATH-742:

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.
I am not understanding what problems this could cause - can you give some explicit examples?
 I don't know what your criteria are for "appropriate serialization code" - can you describe
a case where the default serialization code is not appropriate and _why_ it is not appropriate?

As far as I can tell, the writeObject() and readObject() methods in ExceptionContext are unnecessary
because they simply do what the default mechanism does anyway (except that it replaces throwing
an exception for a non-serializable object with a String that says it is non-serializable).
 What am I missing?

Your code for a class that serializes PolynomialSplineFunction pulls coefficients[] out of
the underlying PolynomialFunction class and serializes them.  Why do that instead of just
using PolynomialFunction.writeObject()?  Why is it better programming practice to create separate
serialization classes that have deep knowledge of the class structure of each of its data
members rather than encapsulate the serialization in each of those classes?  If PolynomialFunction
implements Serializable, then either PolynomialFunction.writeObject() will do the right thing
or it is a bug in PolynomialFunction's implementation of writeObject() - a serializer for
PolynomialSplineFunction shouldn't have to take on the responsibility of serializing the guts
of PolynomialFunction.  I don't see how breaking encapsulation like this is an improvement
over the default mechanism, which doesn't break it.
> Please make PolynomialSplineFunction Serializable
> -------------------------------------------------
>                 Key: MATH-742
>                 URL:
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 2.2
>            Reporter: Neil Roeth
>            Priority: Minor
>         Attachments:
> 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;}}
> and change this:
> {{public class PolynomialSplineFunction implements DifferentiableUnivariateRealFunction}}
> to this:
> {{public class PolynomialSplineFunction implements DifferentiableUnivariateRealFunction,
> 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:!default.jspa
For more information on JIRA, see:


View raw message