org.netbeans.JarClassLoader.java:880 uses a literal of 0. This causes URL.equals(Object) to fail when comparing URLs that were
constructed using the different means.
The URL spec violation is that they are setting the port without setting the
host. The specification prohibits that. If the host is not set, the port
must be -1. The standard URL constructors ensure this is always the case.
However, JarClassLoader bypasses those constructors and calls
URLStreamHandler.setURL(), and explicitly sets the port to 0. They need to
change that code to be consistent with URLs created with the standard
constructors, and use -1. Should only be a 2 character change in the file, I
Created attachment 107830 [details]
I cannot reproduce the faulty behavior, URLs seem to be equal
To reproduce one needs to use URL(u, "/relative/path"): ergonomics#63fed943e185
Jesse, please review, I'd like to put the fix into release692 branch.
Fix looks OK to me.
Note that new URL("jar:file:/....jar!/...").getHost() => "" rather than null, which will be another difference from the current code. Probably it makes no difference.
Would prefer that testURLsAreEqual be moved inside JarClassLoaderTest, probably right beneath testJarURLConnection, so that Ctrl-F6 from JarClassLoader.java runs all relevant tests.
user: Jaroslav Tulach <firstname.lastname@example.org>
date: Tue Apr 19 21:02:06 2011 +0200
summary: Backport of #197861 to release692 branch
I started with the test in JarClassLoaderTest, but it does not work. It needs to obtain URL from the original handler first, and only then initialize JarClassLoader. This is a bit fragile, and it is better to isolate this into own test case.
Integrated into 'main-golden', will be available in build *201104200000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jaroslav Tulach <email@example.com>
Log: #197861: Copy the host and port