This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] libjava: java.net.URI.relativize method results inconsistent with other Java VMs
- From: Tom Tromey <tromey at redhat dot com>
- To: Luciano Chavez <lnx1138 at us dot ibm dot com>
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, GNU Classpath Patches <classpath-patches at gnu dot org>
- Date: Mon, 21 Jan 2008 12:31:49 -0700
- Subject: Re: [PATCH] libjava: java.net.URI.relativize method results inconsistent with other Java VMs
- References: <1199846929.20059.54.camel@localhost>
- Reply-to: Tom Tromey <tromey at redhat dot com>
>>>>> "Luciano" == Luciano Chavez <lnx1138@us.ibm.com> writes:
Luciano> This patch corrects two issues found in URI.relativize()
Luciano> method in libjava/classpath/java/net/URI.java. It applies
Luciano> from gcc 4.1.2 through latest trunk:
Thanks. I am checking in a slightly different patch, appended.
There's no need to use 'new String(rawPath)', because Strings are
immutable.
I'm also checking it in to Classpath.
Just FYI... it is easier for us if you write a ChangeLog entry and
submit it with your patch.
Tom
ChangeLog:
2008-01-21 Luciano Chavez <lnx1138@us.ibm.com>
PR libgcj/34369:
* java/net/URI.java (relativize): Check initial segment for
trailing "/".
Index: java/net/URI.java
===================================================================
--- java/net/URI.java (revision 131699)
+++ java/net/URI.java (working copy)
@@ -1,5 +1,5 @@
/* URI.java -- An URI class
- Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -968,12 +968,18 @@
return uri;
if (rawAuthority != null && !(rawAuthority.equals(uri.getRawAuthority())))
return uri;
- if (!(uri.getRawPath().startsWith(rawPath)))
- return uri;
+ String basePath = rawPath;
+ if (!(uri.getRawPath().equals(rawPath)))
+ {
+ if (!(basePath.endsWith("/")))
+ basePath = basePath.concat("/");
+ if (!(uri.getRawPath().startsWith(basePath)))
+ return uri;
+ }
try
{
return new URI(null, null,
- uri.getRawPath().substring(rawPath.length()),
+ uri.getRawPath().substring(basePath.length()),
uri.getRawQuery(), uri.getRawFragment());
}
catch (URISyntaxException e)