RFR - 8132734: java.util.jar.* changes to support multi-release jar files

Alan Bateman Alan.Bateman at oracle.com
Tue Nov 10 10:10:10 UTC 2015

On 10/11/2015 09:06, Paul Sandoz wrote:
> :
> It’s more common to register a URLStreamHandlerFactory via URL.setURLStreamHandlerFactory. I suspect that is used more for supporting different URL schemes than for overriding the “jar” scheme. This is a very delicate area, override the “jar" scheme might be risky given the interaction with class loaders. IMO the URLs returned from JDK ClassLoaders should be using URL schemes that are not overridable, but it’s probably too late to change that.
We had to re-examine this area in preparation for modules and 
java.net.URL has the following in its javadoc:

      * Some protocol handlers, for example those used for loading platform
      * classes or classes on the class path, may not be overridden. The 
      * of such restrictions, and when those restrictions apply (during
      * initialization of the runtime for example), are implementation 
      * and therefore not specified.

At things stand then the file and jrt protocol handlers are not 
overridable. The jar protocol handler can be overridden but not via the 
ServiceLoader mechanism (for obvious reasons) and only after the 
VM/runtime has been initialized.

The Java Plugin and Java Web Start in Oracle's builds is the only case 
that I'm aware of where the jar protocol handler is overridden.


More information about the core-libs-dev mailing list