Hi,

please review this patch which might make URI.toURL more efficient

Webrev: http://cr.openjdk.java.net/~redestad/8147462
Bug: https://bugs.openjdk.java.net/browse/JDK-8147462

This patch exploits the fact that URI will apply the same validation to the URI/URL specification for any valid non-opaque URL, thus it's safe to use the component-based URL constructor. Also, URIs representing malformed URLs will throw an exception as specified both before and after. A number of simple test cases to capture and document this was added to the existing java/net/URI/URItoURL jtreg test.

Microbenchmarks covering various URIs vary from neutral (for opaque) to 1.5x (for the simplest URIs without query and fragment components), while also bringing in a small footprint improvement in jake builds.

While toURL() could arguably construct the URL file as path[?query][#fragment], the implementation I tried for this caused regressions in micros due to hitting C2 inlining limit.

Thanks!

/Claes

Reply via email to