Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Class URIClassLoader  view URIClassLoader download

  extended byjava.lang.ClassLoader
          extended byedu.emory.mathcs.util.classloader.GenericClassLoader
              extended byedu.emory.mathcs.util.classloader.URIClassLoader

public class URIClassLoader
extends GenericClassLoader

Equivalent of but without bugs related to ill-formed URLs and with customizable JAR caching policy. The standard URLClassLoader accepts URLs containing spaces and other characters which are forbidden in the URI syntax, according to the RFC 2396. As a workaround to this problem, Java escapes and un-escapes URLs in various arbitrary places; however, this is inconsistent and leads to numerous problems with URLs referring to local files with spaces in the path. SUN acknowledges the problem, see but refuses to modify the behavior for compatibility reasons; see Java Bug Parade 4273532, 4466485.

Additionally, the JAR caching policy used by URLClassLoader is system-wide and inflexible: once downloaded JAR files are never re-downloaded, even if one creates a fresh instance of the class loader that happens to have the same URL in its search path. In fact, that policy is a security vulnerability: it is possible to crash any URL class loader, thus affecting potentially separate part of the system, by creating URL connection to one of the URLs of that class loader search path and closing the associated JAR file. See Java Bug Parade 4405789, 4388666, 4639900.

This class avoids these problems by 1) using URIs instead of URLs for the search path (thus enforcing strict syntax conformance and defining precise escaping semantics), and 2) using custom URLStreamHandler which ensures per-classloader JAR caching policy.


Nested Class Summary
private static class URIClassLoader.URIResourceFinder
Nested classes inherited from class java.lang.ClassLoader
Field Summary
Fields inherited from class edu.emory.mathcs.util.classloader.GenericClassLoader
Fields inherited from class
Fields inherited from class java.lang.ClassLoader
Constructor Summary
URIClassLoader([] uris)
          Creates URIClassLoader with the specified search path.
URIClassLoader([] uris, java.lang.ClassLoader parent)
          Creates URIClassLoader with the specified search path and parent class loader.
Method Summary
 void addURI( uri)
          Add specified URI at the end of the search path.
Methods inherited from class edu.emory.mathcs.util.classloader.GenericClassLoader
defineClass, definePackage, findClass, findLibrary, findResource, findResources, getClassHandle, getDefaultURLStreamHandler, getLibraryHandle, getResourceHandle, getResourceHandles
Methods inherited from class
defineClass, getPermissions
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public URIClassLoader([] uris)
Creates URIClassLoader with the specified search path.


public URIClassLoader([] uris,
                      java.lang.ClassLoader parent)
Creates URIClassLoader with the specified search path and parent class loader.

Method Detail


public void addURI( uri)
Add specified URI at the end of the search path.