This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
PATCH: Serialization mods
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: PATCH: Serialization mods
- From: Warren Levy <warrenl at cygnus dot com>
- Date: Mon, 26 Jun 2000 22:07:15 -0700 (PDT)
Folks,
Here are some basic serialization mods I'm checking in per the JDK doc at
http://java.sun.com/products/jdk/1.2/docs/api/serialized-form.html
Mostly it brings various fields in line with the spec. Just a lot of
housekeeping changes; nothing earth-shattering. There will be
more serialization mods to come; this is just the start.
--warrenl
2000-06-26 Warren Levy <warrenl@cygnus.com>
* java/beans/PropertyChangeEvent.java (oldVal): Renamed to oldValue.
(newVal): Renamed to newValue.
* java/beans/PropertyVetoException.java (changeEvent): Renamed to evt.
* java/beans/beancontext/BeanContextServiceRevokedEvent.java
(revokeNow): Renamed to invalidateRefs.
* java/io/OptionalDataException.java: Updated FIXME.
(eof): New placeholder field.
(length); Ditto.
* java/io/WriteAbortedException.java (message): Made transient.
* java/lang/ClassNotFoundException.java: Updated comments for JDK 1.2.
* java/lang/Throwable.java (stackTrace): Made transient.
* java/net/InetAddress.java: Made Serializable.
* java/security/KeyPair.java: Made Serializable.
* java/security/Provider.java: Replaced with Classpath version that
implements serialization and proper methods.
* java/text/ChoiceFormat.java (strings): Renamed to choiceFormats.
(limits): Renamed to choiceLimits.
Index: java/beans/PropertyChangeEvent.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/beans/PropertyChangeEvent.java,v
retrieving revision 1.1
diff -u -p -r1.1 PropertyChangeEvent.java
--- PropertyChangeEvent.java 2000/05/19 17:55:30 1.1
+++ PropertyChangeEvent.java 2000/06/27 03:27:44
@@ -1,5 +1,5 @@
/* java.beans.PropertyChangeEvent
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,8 +50,8 @@ package java.beans;
public class PropertyChangeEvent extends java.util.EventObject {
String propertyName;
- Object oldVal;
- Object newVal;
+ Object oldValue;
+ Object newValue;
Object propagationId;
/** Create a new PropertyChangeEvent. Remember that if
@@ -60,14 +60,14 @@ public class PropertyChangeEvent extends
** from the old PropertyChangeEvent.
** @param source the Bean containing the property.
** @param propertyName the property's name.
- ** @param oldVal the old value of the property.
- ** @param newVal the new value of the property.
+ ** @param oldValue the old value of the property.
+ ** @param newValue the new value of the property.
**/
public PropertyChangeEvent(Object source, String propertyName, Object oldVal, Object newVal) {
super(source);
this.propertyName = propertyName;
- this.oldVal = oldVal;
- this.newVal = newVal;
+ oldValue = oldVal;
+ newValue = newVal;
}
/** Get the property name.
@@ -81,14 +81,14 @@ public class PropertyChangeEvent extends
** @return the property's old value.
**/
public Object getOldValue() {
- return oldVal;
+ return oldValue;
}
/** Get the property's new value.
** @return the property's new value.
**/
public Object getNewValue() {
- return newVal;
+ return newValue;
}
/** Set the propagation ID. This is a way for the event
Index: java/beans/PropertyVetoException.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/beans/PropertyVetoException.java,v
retrieving revision 1.1
diff -u -p -r1.1 PropertyVetoException.java
--- PropertyVetoException.java 2000/05/19 17:55:30 1.1
+++ PropertyVetoException.java 2000/06/27 03:27:44
@@ -1,5 +1,5 @@
/* java.beans.PropertyVetoException
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,7 @@ package java.beans;
**/
public class PropertyVetoException extends Exception {
- PropertyChangeEvent changeEvent;
+ PropertyChangeEvent evt;
/** Instantiate this exception with the given message and property change.
** @param msg the reason for the veto.
@@ -45,11 +45,11 @@ public class PropertyVetoException exten
**/
public PropertyVetoException(String msg, PropertyChangeEvent changeEvent) {
super(msg);
- this.changeEvent = changeEvent;
+ evt = changeEvent;
}
/** Get the PropertyChange event that was vetoed. **/
public PropertyChangeEvent getPropertyChangeEvent() {
- return changeEvent;
+ return evt;
}
}
Index: java/beans/beancontext/BeanContextServiceRevokedEvent.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/beans/beancontext/BeanContextServiceRevokedEvent.java,v
retrieving revision 1.1
diff -u -p -r1.1 BeanContextServiceRevokedEvent.java
--- BeanContextServiceRevokedEvent.java 2000/05/19 17:55:31 1.1
+++ BeanContextServiceRevokedEvent.java 2000/06/27 03:27:44
@@ -1,5 +1,5 @@
/* java.beans.beancontext.BeanContextServiceRevokedEvent
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,7 @@ public class BeanContextServiceRevokedEv
* available.
*/
protected Class serviceClass;
- private boolean revokeNow;
+ private boolean invalidateRefs;
/**
* Create a new service revoked event.
@@ -55,7 +55,7 @@ public class BeanContextServiceRevokedEv
public BeanContextServiceRevokedEvent(BeanContextServices services, Class serviceClass, boolean revokeNow) {
super(services);
this.serviceClass = serviceClass;
- this.revokeNow = revokeNow;
+ invalidateRefs = revokeNow;
}
/**
@@ -94,6 +94,6 @@ public class BeanContextServiceRevokedEv
* usable.
*/
public boolean isCurrentServiceInvalidNow() {
- return revokeNow;
+ return invalidateRefs;
}
}
Index: java/io/OptionalDataException.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/OptionalDataException.java,v
retrieving revision 1.1
diff -u -p -r1.1 OptionalDataException.java
--- OptionalDataException.java 2000/04/11 09:21:53 1.1
+++ OptionalDataException.java 2000/06/27 03:27:44
@@ -19,6 +19,10 @@ package java.io;
public class OptionalDataException extends ObjectStreamException
{
+ // FIXME: Need to set these fields per the doc in a constructor.
+ public boolean eof;
+ public int length;
+
public OptionalDataException()
{
super();
Index: java/io/WriteAbortedException.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/WriteAbortedException.java,v
retrieving revision 1.1
diff -u -p -r1.1 WriteAbortedException.java
--- WriteAbortedException.java 2000/05/19 17:55:31 1.1
+++ WriteAbortedException.java 2000/06/27 03:27:44
@@ -1,6 +1,6 @@
/* WriteAbortedException.java -- An exception occured while writing a
serialization stream
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,7 +47,7 @@ public class WriteAbortedException exten
* The detailed exception that caused this exception to be thrown
*/
public Exception detail;
-private String message;
+private transient String message;
/*************************************************************************/
Index: java/lang/ClassNotFoundException.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/ClassNotFoundException.java,v
retrieving revision 1.3
diff -u -p -r1.3 ClassNotFoundException.java
--- ClassNotFoundException.java 2000/03/07 19:55:26 1.3
+++ ClassNotFoundException.java 2000/06/27 03:27:44
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -20,6 +20,9 @@ package java.lang;
public class ClassNotFoundException extends Exception
{
+ // TODO12:
+ // Throwable ex;
+
public ClassNotFoundException()
{
super();
@@ -28,6 +31,7 @@ public class ClassNotFoundException exte
// TODO12:
// public ClassNotFoundException(String msg, Throwable ex)
// {
+ // FIXME: Set 'ex' here.
// }
public ClassNotFoundException(String msg)
Index: java/lang/Throwable.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/Throwable.java,v
retrieving revision 1.6
diff -u -p -r1.6 Throwable.java
--- Throwable.java 2000/05/30 23:26:02 1.6
+++ Throwable.java 2000/06/27 03:27:45
@@ -164,5 +164,5 @@ public class Throwable implements Serial
// Name of this field comes from serialization spec.
private String detailMessage;
- private byte stackTrace[];
+ private transient byte stackTrace[];
}
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/InetAddress.java,v
retrieving revision 1.4
diff -u -p -r1.4 InetAddress.java
--- InetAddress.java 2000/03/07 19:55:27 1.4
+++ InetAddress.java 2000/06/27 03:27:45
@@ -22,10 +22,10 @@ package java.net;
* Status: Believed complete and correct.
*/
-public final class InetAddress
+public final class InetAddress implements java.io.Serializable
{
- String hostname;
byte[] address;
+ String hostname;
InetAddress (byte[] address, String hostname)
{
Index: java/security/KeyPair.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/security/KeyPair.java,v
retrieving revision 1.1
diff -u -p -r1.1 KeyPair.java
--- KeyPair.java 2000/03/10 02:43:56 1.1
+++ KeyPair.java 2000/06/27 03:27:45
@@ -17,7 +17,7 @@ package java.security;
* Status: Believed complete and correct.
*/
-public class KeyPair /* FIXME: implements serializable */
+public class KeyPair implements java.io.Serializable
{
public KeyPair (PublicKey publicKey, PrivateKey privateKey)
{
Index: java/text/ChoiceFormat.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/text/ChoiceFormat.java,v
retrieving revision 1.5
diff -u -p -r1.5 ChoiceFormat.java
--- ChoiceFormat.java 2000/05/04 15:50:34 1.5
+++ ChoiceFormat.java 2000/06/27 03:27:45
@@ -84,14 +84,14 @@ public class ChoiceFormat extends Number
++index;
}
- strings = new String[stringVec.size()];
- stringVec.copyInto(strings);
+ choiceFormats = new String[stringVec.size()];
+ stringVec.copyInto(choiceFormats);
- limits = new double[limitVec.size()];
- for (int i = 0; i < limits.length; ++i)
+ choiceLimits = new double[limitVec.size()];
+ for (int i = 0; i < choiceLimits.length; ++i)
{
Double d = (Double) limitVec.elementAt(i);
- limits[i] = d.doubleValue();
+ choiceLimits[i] = d.doubleValue();
}
}
@@ -101,15 +101,15 @@ public class ChoiceFormat extends Number
applyPattern (newPattern);
}
- public ChoiceFormat (double[] limits, String[] strings)
+ public ChoiceFormat (double[] choiceLimits, String[] choiceFormats)
{
super ();
- setChoices (limits, strings);
+ setChoices (choiceLimits, choiceFormats);
}
public Object clone ()
{
- return new ChoiceFormat (limits, strings);
+ return new ChoiceFormat (choiceLimits, choiceFormats);
}
public boolean equals (Object obj)
@@ -117,12 +117,12 @@ public class ChoiceFormat extends Number
if (! (obj instanceof ChoiceFormat))
return false;
ChoiceFormat cf = (ChoiceFormat) obj;
- if (limits.length != cf.limits.length)
+ if (choiceLimits.length != cf.choiceLimits.length)
return false;
- for (int i = limits.length - 1; i >= 0; --i)
+ for (int i = choiceLimits.length - 1; i >= 0; --i)
{
- if (limits[i] != cf.limits[i]
- || !strings[i].equals(cf.strings[i]))
+ if (choiceLimits[i] != cf.choiceLimits[i]
+ || !choiceFormats[i].equals(cf.choiceFormats[i]))
return false;
}
return true;
@@ -137,42 +137,42 @@ public class ChoiceFormat extends Number
public StringBuffer format (double num, StringBuffer appendBuf,
FieldPosition pos)
{
- if (limits.length == 0)
+ if (choiceLimits.length == 0)
return appendBuf;
int index = 0;
- if (! Double.isNaN(num) && num >= limits[0])
+ if (! Double.isNaN(num) && num >= choiceLimits[0])
{
- for (; index < limits.length - 1; ++index)
+ for (; index < choiceLimits.length - 1; ++index)
{
- if (limits[index] <= num
- && index != limits.length - 2
- && num < limits[index + 1])
+ if (choiceLimits[index] <= num
+ && index != choiceLimits.length - 2
+ && num < choiceLimits[index + 1])
break;
}
}
- return appendBuf.append(strings[index]);
+ return appendBuf.append(choiceFormats[index]);
}
public Object[] getFormats ()
{
- return (Object[]) strings.clone();
+ return (Object[]) choiceFormats.clone();
}
public double[] getLimits ()
{
- return (double[]) limits.clone();
+ return (double[]) choiceLimits.clone();
}
public int hashCode ()
{
int hash = 0;
- for (int i = 0; i < limits.length; ++i)
+ for (int i = 0; i < choiceLimits.length; ++i)
{
- long v = Double.doubleToLongBits(limits[i]);
+ long v = Double.doubleToLongBits(choiceLimits[i]);
hash ^= (v ^ (v >>> 32));
- hash ^= strings[i].hashCode();
+ hash ^= choiceFormats[i].hashCode();
}
return hash;
}
@@ -238,12 +238,12 @@ public class ChoiceFormat extends Number
public Number parse (String sourceStr, ParsePosition pos)
{
int index = pos.getIndex();
- for (int i = 0; i < limits.length; ++i)
+ for (int i = 0; i < choiceLimits.length; ++i)
{
- if (sourceStr.startsWith(strings[i], index))
+ if (sourceStr.startsWith(choiceFormats[i], index))
{
- pos.setIndex(index + strings[i].length());
- return new Double (limits[i]);
+ pos.setIndex(index + choiceFormats[i].length());
+ return new Double (choiceLimits[i]);
}
}
pos.setErrorIndex(index);
@@ -255,12 +255,14 @@ public class ChoiceFormat extends Number
return nextDouble (d, false);
}
- public void setChoices (double[] limits, String[] strings)
+ public void setChoices (double[] choiceLimits, String[] choiceFormats)
{
- if (limits.length != strings.length)
+ if (choiceLimits == null || choiceFormats == null)
+ throw new NullPointerException ();
+ if (choiceLimits.length != choiceFormats.length)
throw new IllegalArgumentException ();
- this.strings = (String[]) strings.clone();
- this.limits = (double[]) limits.clone();
+ this.choiceFormats = (String[]) choiceFormats.clone();
+ this.choiceLimits = (double[]) choiceLimits.clone();
}
private final void quoteString (StringBuffer dest, String text)
@@ -288,18 +290,18 @@ public class ChoiceFormat extends Number
public String toPattern ()
{
StringBuffer result = new StringBuffer ();
- for (int i = 0; i < limits.length; ++i)
+ for (int i = 0; i < choiceLimits.length; ++i)
{
- result.append(limits[i]);
+ result.append(choiceLimits[i]);
result.append('#');
- quoteString (result, strings[i]);
+ quoteString (result, choiceFormats[i]);
}
return result.toString();
}
// Formats and limits.
- private String[] strings;
- private double[] limits;
+ private String[] choiceFormats;
+ private double[] choiceLimits;
// Number of mantissa bits in double.
private static final int mantissaBits = 52;