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

Quick Search    Search Deep

edu.emory.mathcs.util.classloader
Class URIClassLoader  view URIClassLoader download URIClassLoader.java

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byedu.emory.mathcs.util.classloader.GenericClassLoader
              extended byedu.emory.mathcs.util.classloader.URIClassLoader

public class URIClassLoader
extends GenericClassLoader

Equivalent of java.net.URLClassloader 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.

Version:
1.0

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
finder
 
Fields inherited from class java.security.SecureClassLoader
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
URIClassLoader(java.net.URI[] uris)
          Creates URIClassLoader with the specified search path.
URIClassLoader(java.net.URI[] uris, java.lang.ClassLoader parent)
          Creates URIClassLoader with the specified search path and parent class loader.
 
Method Summary
 void addURI(java.net.URI 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 java.security.SecureClassLoader
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

URIClassLoader

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


URIClassLoader

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

Method Detail

addURI

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