FileDocCategorySizeDatePackage
CustomURLClassLoader.javaAPI DocExample1854Sat Jan 13 12:32:06 GMT 2001javasec.samples.ch06

CustomURLClassLoader

public class CustomURLClassLoader extends URLClassLoader

Fields Summary
static URL[]
urls
Constructors Summary
public CustomURLClassLoader()

        try {
            urls = new URL[2];
            urls[0] = new URL("http://piccolo.East/~sdo/");
            urls[1] = new URL("file:/home/classes/LocalClasses.jar");
        } catch (Exception e) {
            throw new RuntimeException("Can't create URLs " + e);
        }
    
        super(urls);
    
Methods Summary
protected java.lang.ClassfindClass(java.lang.String name)

        // First check if we have permission to access the package.
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            int i = name.lastIndexOf('.");
            if (i != -1) {
                sm.checkPackageDefinition(name.substring(0, i));
            }
        }
        return super.findClass(name);
    
protected java.security.PermissionCollectiongetPermissions(java.security.CodeSource codesource)

        // Use all the standard permissions, plus allow the code to
        // exit the VM.
        PermissionCollection pc = super.getPermissions(codesource);
        pc.add(new RuntimePermission("exitVM"));
        return pc;
    
public final synchronized java.lang.ClassloadClass(java.lang.String name, boolean resolve)

        // First check if we have permission to access the package.
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            int i = name.lastIndexOf('.");
            if (i != -1) {
                sm.checkPackageAccess(name.substring(0, i));
            }
        }
        return super.loadClass(name, resolve);