Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 20338 invoked from network); 20 Jun 2009 03:00:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Jun 2009 03:00:30 -0000 Received: (qmail 42361 invoked by uid 500); 20 Jun 2009 03:00:41 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 42270 invoked by uid 500); 20 Jun 2009 03:00:41 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 42261 invoked by uid 99); 20 Jun 2009 03:00:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Jun 2009 03:00:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Jun 2009 03:00:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 75AB023888C5; Sat, 20 Jun 2009 03:00:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r786751 - /commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java Date: Sat, 20 Jun 2009 03:00:18 -0000 To: commits@commons.apache.org From: billbarker@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090620030018.75AB023888C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: billbarker Date: Sat Jun 20 03:00:18 2009 New Revision: 786751 URL: http://svn.apache.org/viewvc?rev=786751&view=rev Log: Change Complex to use readResolve instead of introspection Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java?rev=786751&r1=786750&r2=786751&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java Sat Jun 20 03:00:18 2009 @@ -17,8 +17,6 @@ package org.apache.commons.math.complex; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -973,33 +971,15 @@ } /** - * Deserialize a Complex Object. - * @param ois The stream to deserialize from. - * @throws IOException If there is an error reading the stream. - * @throws ClassNotFoundException If this class cannot be found. - */ - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - ois.defaultReadObject(); - - try { - final java.lang.reflect.Field fNaN = getClass().getDeclaredField("isNaN"); - fNaN.setAccessible(true); - fNaN.set(this, Double.isNaN(real) || Double.isNaN(imaginary)); - final java.lang.reflect.Field fInf = getClass().getDeclaredField("isInfinite"); - fInf.setAccessible(true); - fInf.set(this, !isNaN && (Double.isInfinite(real) || Double.isInfinite(imaginary))); - } catch (IllegalAccessException iae) { - IOException ioe = new IOException(); - ioe.initCause(iae); - throw ioe; - } catch (NoSuchFieldException nsfe) { - IOException ioe = new IOException(); - ioe.initCause(nsfe); - throw ioe; - } - + *

Resolve the transient fields in a deserialized Complex Object.

+ *

Subclasses will need to override {@link #createComplex} to deserialize properly

+ * @return A Complex instance with all fields resolved. + * @since 2.0 + */ + private final Object readResolve() { + return createComplex(real, imaginary); } - + /** {@inheritDoc} */ public ComplexField getField() { return ComplexField.getInstance();