public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
* [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results @ 2007-12-06 22:10 lnx1138 at us dot ibm dot com 2007-12-06 22:12 ` [Bug java/34369] " lnx1138 at us dot ibm dot com ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: lnx1138 at us dot ibm dot com @ 2007-12-06 22:10 UTC (permalink / raw) To: java-prs The method java.net.URI.relativize(URI) returns incorrect results for a couple of cases when compared to implementations from IBM Java or Sun Java. This problem affects directly the debugging process of C projects on Eclipse. Whenever someone is debugging a project whose part of its name is the name of another project on the workspace, Eclipse doesn't find the correct path for the project source files. For instance, if we have a project named "a" and another project named "aa" and we try to debug a file on "aa", Eclipse will match the path for the file on "aa" with the path to the project "a" and will not find the file as it doesn't exist on project "a". The method documentaion at http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html#relativize(java.net.URI) says: The relativization of the given URI against this URI is computed as follows: 1. If either this URI or the given URI are opaque, or if the scheme and authority components of the two URIs are not identical, or if the path of this URI is not a prefix of the path of the given URI, then the given URI is returned. 2. Otherwise a new relative hierarchical URI is constructed with query and fragment components taken from the given URI and with a path component computed by removing this URI's path from the beginning of the given URI's path. The test for "if the path of this URI is not a prefix of the path of the given URI then the given URI is returned" in libjava/classpath/java/net/URI.java does not appear correct: public URI relativize(URI uri) { if (isOpaque() || uri.isOpaque()) return uri; if (scheme == null && uri.getScheme() != null) return uri; if (scheme != null && !(scheme.equals(uri.getScheme()))) return uri; if (rawAuthority == null && uri.getRawAuthority() != null) return uri; if (rawAuthority != null && !(rawAuthority.equals(uri.getRawAuthority()))) return uri; if (!(uri.getRawPath().startsWith(rawPath))) <---- this test return uri; In some cases I would expect uri.getRawPath().startsWith(rawPath) to return true since with a simple string character sequence test of startsWith() such as with the string "file:/home/eclipse/runtime-New_configuration/simple" would be a prefix of "file:/home/eclipse/runtime-New_configuration/simple_spu/simple_spu.c" even though simple and simple_spu are technically different paths. This I think is where the other VM implementations must be doing it correctly as they likely examine components of a path as opposed to just a string prefix check. A second problem is that when the code drops through to return new URI(null, null, uri.getRawPath().substring(rawPath.length()), uri.getRawQuery(), uri.getRawFragment()); the substring() method may end up returning a leading '/' on the path in some cases which all the other JVMs do not. The proposed solution is to create a new path with '/' appended to this.rawPath for the given base URI we are checking for. We would have to check that it isn't already the last character. Example: "file:/home/eclipse/runtime-New_configuration/simple" becomes "file:/home/eclipse/runtime-New_configuration/simple/" which is stored in basePath and then the if (!(uri.getRawPath().startsWith(basePath))) should end up returning uri since it doesn't have basePath as prefix when it is for the path "file:/home/eclipse/runtime-New_configuration/simple_spu/simple_spu.c" for example. In addition, to correct avoiding returning a leading '/' a one line change is done to uri.getRawPath().substring(rawPath.length()) to instead get the length of the basePath string as it should always conclude with a '/'. A testcase is supplied to provide examples of the results from various calls to the URI.relativize() method. Here is the results from the unpatched, failing code as it is right now: [eclipse@chavez ~]$ java Test _spu/simple_spu.c <> eclipse /runtime-New_configuration/simple Here are the results after applying the patch and re-running the testcase: [eclipse@chavez ~]$ java Test file:/home/eclipse/runtime-New_configuration/simple_spu/simple_spu.c <> eclipse runtime-New_configuration/simple The above output is consistent with that provided by executing the testcase using IBM Java 5, Sun Java 5 and IBM Java 1.4.2. -- Summary: java.net.URI.relativize(URI) method returns incorrect results Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lnx1138 at us dot ibm dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug java/34369] java.net.URI.relativize(URI) method returns incorrect results 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com @ 2007-12-06 22:12 ` lnx1138 at us dot ibm dot com 2007-12-06 22:15 ` lnx1138 at us dot ibm dot com ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: lnx1138 at us dot ibm dot com @ 2007-12-06 22:12 UTC (permalink / raw) To: java-prs ------- Comment #1 from lnx1138 at us dot ibm dot com 2007-12-06 22:12 ------- Created an attachment (id=14704) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14704&action=view) testcase Sample java code providing two examples where URI.relativize() method is not consistent with other JVM implementations. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug java/34369] java.net.URI.relativize(URI) method returns incorrect results 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com 2007-12-06 22:12 ` [Bug java/34369] " lnx1138 at us dot ibm dot com @ 2007-12-06 22:15 ` lnx1138 at us dot ibm dot com 2008-01-21 20:00 ` [Bug libgcj/34369] " tromey at gcc dot gnu dot org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: lnx1138 at us dot ibm dot com @ 2007-12-06 22:15 UTC (permalink / raw) To: java-prs ------- Comment #2 from lnx1138 at us dot ibm dot com 2007-12-06 22:15 ------- Created an attachment (id=14705) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14705&action=view) gcc-libjava-uri-relativize.patch to fix java.net.URI.relativize(URI) method This patch corrects two issues found in URI.relativize() method in libjava/classpath/java/net/URI.java. It applies from gcc 4.1.2 through latest trunk: * does stricter check for a path match while still using String.startsWith() * excludes leading '/' if necessary for relative path fragment being returned -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/34369] java.net.URI.relativize(URI) method returns incorrect results 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com 2007-12-06 22:12 ` [Bug java/34369] " lnx1138 at us dot ibm dot com 2007-12-06 22:15 ` lnx1138 at us dot ibm dot com @ 2008-01-21 20:00 ` tromey at gcc dot gnu dot org 2008-01-21 20:09 ` tromey at gcc dot gnu dot org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: tromey at gcc dot gnu dot org @ 2008-01-21 20:00 UTC (permalink / raw) To: java-prs ------- Comment #3 from tromey at gcc dot gnu dot org 2008-01-21 20:00 ------- I'm handling this. -- tromey at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |tromey at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2008-01-21 20:00:24 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/34369] java.net.URI.relativize(URI) method returns incorrect results 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com ` (2 preceding siblings ...) 2008-01-21 20:00 ` [Bug libgcj/34369] " tromey at gcc dot gnu dot org @ 2008-01-21 20:09 ` tromey at gcc dot gnu dot org 2008-01-21 20:09 ` tromey at gcc dot gnu dot org 2008-01-21 20:11 ` cvs-commit at developer dot classpath dot org 5 siblings, 0 replies; 7+ messages in thread From: tromey at gcc dot gnu dot org @ 2008-01-21 20:09 UTC (permalink / raw) To: java-prs ------- Comment #4 from tromey at gcc dot gnu dot org 2008-01-21 20:09 ------- Fixed on trunk. -- tromey at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED Target Milestone|--- |4.3.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/34369] java.net.URI.relativize(URI) method returns incorrect results 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com ` (3 preceding siblings ...) 2008-01-21 20:09 ` tromey at gcc dot gnu dot org @ 2008-01-21 20:09 ` tromey at gcc dot gnu dot org 2008-01-21 20:11 ` cvs-commit at developer dot classpath dot org 5 siblings, 0 replies; 7+ messages in thread From: tromey at gcc dot gnu dot org @ 2008-01-21 20:09 UTC (permalink / raw) To: java-prs ------- Comment #5 from tromey at gcc dot gnu dot org 2008-01-21 20:09 ------- Subject: Bug 34369 Author: tromey Date: Mon Jan 21 20:08:38 2008 New Revision: 131701 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131701 Log: 2008-01-21 Luciano Chavez <lnx1138@us.ibm.com> PR libgcj/34369: * java/net/URI.java (relativize): Check initial segment for trailing "/". Modified: trunk/libjava/classpath/ChangeLog trunk/libjava/classpath/java/net/URI.java trunk/libjava/classpath/lib/java/net/URI.class -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/34369] java.net.URI.relativize(URI) method returns incorrect results 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com ` (4 preceding siblings ...) 2008-01-21 20:09 ` tromey at gcc dot gnu dot org @ 2008-01-21 20:11 ` cvs-commit at developer dot classpath dot org 5 siblings, 0 replies; 7+ messages in thread From: cvs-commit at developer dot classpath dot org @ 2008-01-21 20:11 UTC (permalink / raw) To: java-prs ------- Comment #6 from cvs-commit at developer dot classpath dot org 2008-01-21 20:11 ------- Subject: Bug 34369 CVSROOT: /cvsroot/classpath Module name: classpath Changes by: Tom Tromey <tromey> 08/01/21 20:09:56 Modified files: . : ChangeLog java/net : URI.java Log message: 2008-01-21 Luciano Chavez <lnx1138@us.ibm.com> PR libgcj/34369: * java/net/URI.java (relativize): Check initial segment for trailing "/". CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.9474&r2=1.9475 http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/URI.java?cvsroot=classpath&r1=1.20&r2=1.21 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34369 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-01-21 20:11 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-12-06 22:10 [Bug java/34369] New: java.net.URI.relativize(URI) method returns incorrect results lnx1138 at us dot ibm dot com 2007-12-06 22:12 ` [Bug java/34369] " lnx1138 at us dot ibm dot com 2007-12-06 22:15 ` lnx1138 at us dot ibm dot com 2008-01-21 20:00 ` [Bug libgcj/34369] " tromey at gcc dot gnu dot org 2008-01-21 20:09 ` tromey at gcc dot gnu dot org 2008-01-21 20:09 ` tromey at gcc dot gnu dot org 2008-01-21 20:11 ` cvs-commit at developer dot classpath dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).