EDIT: it turned out this question had been asked the wrong way — see my answer below. Please vote to close it.
For a unit test, I need to make the new java.net.URL(String) constructor throw a MalformedURLException, but it takes an awfully long time for what it does — 2.5 seconds.
I understand this is probably related to an attempt to create a protocol handler, so I tried specifying no protocol handler, e.g.:
new URL(null);
new URL("://");
new URL("/abc");
I briefly looked through the implementation, it seems to be preparsing the URL string to eliminate obvious errors. Why does it take so long, even with “null”?
Could it be something else causing the delay? I can’t reproduce this:
Output:
Regarding
equals(), this is from the javadoc: