All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.net.URLClassLoader Maven / Gradle / Ivy

/*

This is not an official specification document, and usage is restricted.

NOTICE


(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.

Neither this file nor any files generated from it describe a complete specification, and they may only be used as described below. For example, no permission is given for you to incorporate this file, in whole or in part, in an implementation of a Java specification.

Sun Microsystems Inc. owns the copyright in this file and it is provided to you for informative, as opposed to normative, use. The file and any files generated from it may be used to generate other informative documentation, such as a unified set of documents of API signatures for a platform that includes technologies expressed as Java APIs. The file may also be used to produce "compilation stubs," which allow applications to be compiled and validated for such platforms.

Any work generated from this file, such as unified javadocs or compiled stub files, must be accompanied by this notice in its entirety.

This work corresponds to the API signatures of JSR 219: Foundation Profile 1.1. In the event of a discrepency between this work and the JSR 219 specification, which is available at http://www.jcp.org/en/jsr/detail?id=219, the latter takes precedence. */ package java.net; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.io.File; import java.io.FilePermission; import java.io.InputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandlerFactory; import java.util.Enumeration; import java.util.NoSuchElementException; import java.util.StringTokenizer; import java.util.jar.Manifest; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; import java.security.AccessController; import java.security.AccessControlContext; import java.security.SecureClassLoader; import java.security.CodeSource; import java.security.Permission; import java.security.PermissionCollection; /** * This class loader is used to load classes and resources from a search * path of URLs referring to both JAR files and directories. Any URL that * ends with a '/' is assumed to refer to a directory. Otherwise, the URL * is assumed to refer to a JAR file which will be opened as needed. *

* The AccessControlContext of the thread that created the instance of * URLClassLoader will be used when subsequently loading classes and * resources. *

* The classes that are loaded are by default granted permission only to * access the URLs specified when the URLClassLoader was created. * * @author David Connelly * @version 1.72 10/17/00 * @since 1.2 */ public class URLClassLoader extends SecureClassLoader { /** * Constructs a new URLClassLoader for the given URLs. The URLs will be * searched in the order specified for classes and resources after first * searching in the specified parent class loader. Any URL that ends with * a '/' is assumed to refer to a directory. Otherwise, the URL is assumed * to refer to a JAR file which will be downloaded and opened as needed. * *

If there is a security manager, this method first * calls the security manager's checkCreateClassLoader method * to ensure creation of a class loader is allowed. * * @param urls the URLs from which to load classes and resources * @param parent the parent class loader for delegation * @exception SecurityException if a security manager exists and its * checkCreateClassLoader method doesn't allow * creation of a class loader. * @see SecurityManager#checkCreateClassLoader */ public URLClassLoader(java.net.URL[] urls, ClassLoader parent) { } /** * Constructs a new URLClassLoader for the specified URLs using the * default delegation parent ClassLoader. The URLs will * be searched in the order specified for classes and resources after * first searching in the parent class loader. Any URL that ends with * a '/' is assumed to refer to a directory. Otherwise, the URL is * assumed to refer to a JAR file which will be downloaded and opened * as needed. * *

If there is a security manager, this method first * calls the security manager's checkCreateClassLoader method * to ensure creation of a class loader is allowed. * * @param urls the URLs from which to load classes and resources * * @exception SecurityException if a security manager exists and its * checkCreateClassLoader method doesn't allow * creation of a class loader. * @see SecurityManager#checkCreateClassLoader */ public URLClassLoader(java.net.URL[] urls) { } /** * Constructs a new URLClassLoader for the specified URLs, parent * class loader, and URLStreamHandlerFactory. The parent argument * will be used as the parent class loader for delegation. The * factory argument will be used as the stream handler factory to * obtain protocol handlers when creating new URLs. * *

If there is a security manager, this method first * calls the security manager's checkCreateClassLoader method * to ensure creation of a class loader is allowed. * * @param urls the URLs from which to load classes and resources * @param parent the parent class loader for delegation * @param factory the URLStreamHandlerFactory to use when creating URLs * * @exception SecurityException if a security manager exists and its * checkCreateClassLoader method doesn't allow * creation of a class loader. * @see SecurityManager#checkCreateClassLoader */ public URLClassLoader(java.net.URL[] urls, ClassLoader parent, java.net.URLStreamHandlerFactory factory) { } /** * Appends the specified URL to the list of URLs to search for * classes and resources. * * @param url the URL to be added to the search path of URLs */ protected void addURL(java.net.URL url) { } /** * Returns the search path of URLs for loading classes and resources. * This includes the original list of URLs specified to the constructor, * along with any URLs subsequently appended by the addURL() method. * @return the search path of URLs for loading classes and resources. */ public java.net.URL[] getURLs() { return null; } /** * Finds and loads the class with the specified name from the URL search * path. Any URLs referring to JAR files are loaded and opened as needed * until the class is found. * * @param name the name of the class * @return the resulting class * @exception ClassNotFoundException if the class could not be found */ protected Class findClass(String name) throws ClassNotFoundException { return null; } /** * Defines a new package by name in this ClassLoader. The attributes * contained in the specified Manifest will be used to obtain package * version and sealing information. For sealed packages, the additional * URL specifies the code source URL from which the package was loaded. * * @param name the package name * @param man the Manifest containing package version and sealing * information * @param url the code source url for the package, or null if none * @exception IllegalArgumentException if the package name duplicates * an existing package either in this class loader or one * of its ancestors * @return the newly defined Package object */ protected Package definePackage(String name, Manifest man, java.net.URL url) throws IllegalArgumentException { return null; } /** * Finds the resource with the specified name on the URL search path. * * @param name the name of the resource * @return a URL for the resource, or null * if the resource could not be found. */ public java.net.URL findResource(String name) { return null; } /** * Returns an Enumeration of URLs representing all of the resources * on the URL search path having the specified name. * * @param name the resource name * @exception IOException if an I/O exception occurs * @return an Enumeration of URLs */ public Enumeration findResources(String name) throws IOException { return null; } /** * Returns the permissions for the given codesource object. * The implementation of this method first calls super.getPermissions * and then adds permissions based on the URL of the codesource. *

* If the protocol is "file" * and the path specifies a file, then permission to read that * file is granted. If protocol is "file" and the path is * a directory, permission is granted to read all files * and (recursively) all files and subdirectories contained in * that directory. *

* If the protocol is not "file", then * to connect to and accept connections from the URL's host is granted. * @param codesource the codesource * @return the permissions granted to the codesource */ protected java.security.PermissionCollection getPermissions(CodeSource codesource) { return null; } /** * Creates a new instance of URLClassLoader for the specified * URLs and parent class loader. If a security manager is * installed, the loadClass method of the URLClassLoader * returned by this method will invoke the * SecurityManager.checkPackageAccess method before * loading the class. * * @param urls the URLs to search for classes and resources * @param parent the parent class loader for delegation * @return the resulting class loader */ public static java.net.URLClassLoader newInstance(java.net.URL[] urls, ClassLoader parent) { return null; } /** * Creates a new instance of URLClassLoader for the specified * URLs and default parent class loader. If a security manager is * installed, the loadClass method of the URLClassLoader * returned by this method will invoke the * SecurityManager.checkPackageAccess before * loading the class. * * @param urls the URLs to search for classes and resources * @return the resulting class loader */ public static java.net.URLClassLoader newInstance(java.net.URL[] urls) { return null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy