commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: [math] Serialization
Date Mon, 25 May 2009 06:47:11 GMT
Bill,

Did you commit those changes?

I ask because I see similar issues with abstract and static classes.  Gamma
is an example of the static class issue.  This class has only static
methods, but it is marked as serializable (why?).  ContinuedFraction is a
good example of an abstract class that is marked as serializable.  This
latter case leads to code that is either strange or incorrect.  The strange
version has a version identifier even on anonymous classes as in this code
here:

         // create continued fraction
            ContinuedFraction cf = new ContinuedFraction() {

                private static final long serialVersionUID =
5378525034886164398L;

                @Override
                protected double getA(int n, double x) {
                    return ((2.0 * n) + 1.0) - a + x;
                }

                @Override
                protected double getB(int n, double x) {
                    return n * (a - n);
                }
            };

            ret = 1.0 / cf.evaluate(x, epsilon, maxIterations);
            ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * ret;

If the serialVersionUID is ommitted, the anonymous class would be
incorrectly serialized because it would inherit it's parent UID (I think).
More importantly, I can't imagine why an abstract class like
ContinuedFraction should be serializable.

On Sun, May 24, 2009 at 6:10 PM, Bill Barker <billwbarker@verizon.net>wrote:

> Ok, most of the rest look like transient classes (e.g. all of
> linear.decomposition).  So asking for what needs to be Serialized, and what
> doesn't.
>



-- 
Ted Dunning, CTO
DeepDyve

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message