Skip to content
Eric Bodden edited this page Mar 15, 2015 · 1 revision
package java.awt.datatransfer;

    protected final static Class<?> tryToLoadClass(String className,
						   ClassLoader fallback) 
        throws ClassNotFoundException
    {
	ClassLoader systemClassLoader = (ClassLoader)
	    java.security.AccessController.doPrivileged(
                new java.security.PrivilegedAction() {
		    public Object run() {
			ClassLoader cl = Thread.currentThread().
			    getContextClassLoader();
			return (cl != null)
			    ? cl
			    : ClassLoader.getSystemClassLoader();
		    }
		    });
	
	try {
	    return Class.forName(className, true, systemClassLoader);
	} catch (ClassNotFoundException e2) {
	    if (fallback != null) {
		return Class.forName(className, true, fallback);
	    } else {
		throw new ClassNotFoundException(className);
	    }
	}
    }

=> Avoiding problems of default system class loader //creating a connection between theses files: List.class String.class InputStream.class Image.class HomeTransferableList.class

Clone this wiki locally