This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Fix PR 17081
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org, classpath-patches at gnu dot org
- Date: Wed, 18 Aug 2004 14:04:11 -0400
- Subject: FYI: Fix PR 17081
I'm checking this in. It fixes serialization of java.net.URI.
Bryce
2004-08-18 Bryce McKinlay <mckinlay@redhat.com>
PR libgcj/17081
* java/net/URI.java (string): New field. Make all other fields
transient.
(readObject): Implemented.
(writeObject): Implemented.
(URI): Set 'string'.
Index: URI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URI.java,v
retrieving revision 1.5
diff -u -r1.5 URI.java
--- URI.java 20 Apr 2004 13:05:10 -0000 1.5
+++ URI.java 18 Aug 2004 18:03:03 -0000
@@ -111,30 +111,44 @@
* Index of fragment component in parsed URI.
*/
private static final int FRAGMENT_GROUP = 10;
- private String scheme;
- private String rawSchemeSpecificPart;
- private String schemeSpecificPart;
- private String rawAuthority;
- private String authority;
- private String rawUserInfo;
- private String userInfo;
- private String rawHost;
- private String host;
- private int port;
- private String rawPath;
- private String path;
- private String rawQuery;
- private String query;
- private String rawFragment;
- private String fragment;
+ private transient String scheme;
+ private transient String rawSchemeSpecificPart;
+ private transient String schemeSpecificPart;
+ private transient String rawAuthority;
+ private transient String authority;
+ private transient String rawUserInfo;
+ private transient String userInfo;
+ private transient String rawHost;
+ private transient String host;
+ private transient int port;
+ private transient String rawPath;
+ private transient String path;
+ private transient String rawQuery;
+ private transient String query;
+ private transient String rawFragment;
+ private transient String fragment;
+ private String string;
private void readObject(ObjectInputStream is)
throws ClassNotFoundException, IOException
{
+ this.string = (String) is.readObject();
+ try
+ {
+ parseURI(this.string);
+ }
+ catch (URISyntaxException x)
+ {
+ // Should not happen.
+ throw new RuntimeException(x);
+ }
}
- private void writeObject(ObjectOutputStream is) throws IOException
- {
+ private void writeObject(ObjectOutputStream os) throws IOException
+ {
+ if (string == null)
+ string = toString();
+ os.writeObject(string);
}
private static String getURIGroup(Matcher match, int group)
@@ -362,6 +376,7 @@
*/
public URI(String str) throws URISyntaxException
{
+ this.string = str;
parseURI(str);
}