Hi, while investigation for JDK-8022748 [1] (new URI(u.toString()).equals(u) does not hold with paths containing colons
i found some smaller things. The javadoc contains the following example ------- * This operation is often useful when constructing a document containing URIs that must be made relative to the base URI of the document wherever possible. For example, relativizing the URI * https://docs.oracle.com/javase/1.3/docs/guide/index.html * against the base URI * http://java.sun.com/j2se/1.3 * yields the relative URI docs/guide/index.html. -------- which seems to be a correction error. I think it must be https://docs.oracle.com/javase/1.3 instead of http://java.sun.com/j2se/1.3. I would provide a patch (if someone would sponsor it) for this with some other things that i think needs some more discussion. If you can the example above and try to do another thing that defines the relativize functionality /----------- * Relativization/, finally, is the inverse of resolution: For any two normalized URIs /u/ and /v/,/ * u/|.relativize(|/u/|.resolve(|/v/|)).equals(|/v/|)| and/ * u/|.resolve(|/u/|.relativize(|/v/|)).equals(|/v/|)| . ----------- and try it with the "corrected" example above it URI tu = new URI("https://docs.oracle.com/javase/1.3/docs/guide/index.html"); tu = tu.normalize(); URI base = new URI("https://docs.oracle.com/javase/1.3"); base = base.normalize(); URI rel = base.relativize(tu); System.out.println(rel); System.out.println(tu); System.out.println(base.resolve(rel)); you get docs/guide/index.html https://docs.oracle.com/javase/1.3/docs/guide/index.html https://docs.oracle.com/javase/docs/guide/index.html instead of the expected which you only get if you use a base-uri with trailing / docs/guide/index.html https://docs.oracle.com/javase/1.3/docs/guide/index.html https://docs.oracle.com/javase/1.3/docs/guide/index.html I want to cleanup and fix some of these and maybe even JDK-8022748, but i need some clarification/dicussion what the expected behavior is. Is the relativize-specification only valid for base-uris with trailing / ??? There are some Testcases that adress this case. If the tests are right than this is only a minor javadoc failure. -- Sebastian [1] https://bugs.openjdk.java.net/browse/JDK-8022748