/**@class java.lang.ClassLoader @extends java.lang.Object A class loader is an object that is responsible for loading classes. The class <tt>ClassLoader</tt> is an abstract class. Given the <a href="#name">binary name</a> of a class, a class loader should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system. <p> Every {@link Class <tt>Class</tt>} object contains a {@link java.lang.Class#getjava.lang.ClassLoader() reference} to the <tt>ClassLoader</tt> that defined it. <p> <tt>Class</tt> objects for array classes are not created by class loaders, but are created automatically as required by the Java runtime. The class loader for an array class, as returned by {@link java.lang.Class#getjava.lang.ClassLoader()} is the same as the class loader for its element type; if the element type is a primitive type, then the array class has no class loader. <p> Applications implement subclasses of <tt>ClassLoader</tt> in order to extend the manner in which the Java virtual machine dynamically loads classes. <p> Class loaders may typically be used by security managers to indicate security domains. <p> The <tt>ClassLoader</tt> class uses a delegation model to search for classes and resources. Each instance of <tt>ClassLoader</tt> has an associated parent class loader. When requested to find a class or resource, a <tt>ClassLoader</tt> instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. The virtual machine's built-in class loader, called the "bootstrap class loader", does not itself have a parent but may serve as the parent of a <tt>ClassLoader</tt> instance. <p> Class loaders that support concurrent loading of classes are known as <em>parallel capable</em> class loaders and are required to register themselves at their class initialization time by invoking the {@link #registerAsParallelCapable <tt>ClassLoader.registerAsParallelCapable</tt>} method. Note that the <tt>ClassLoader</tt> class is registered as parallel capable by default. However, its subclasses still need to register themselves if they are parallel capable. <br> In environments in which the delegation model is not strictly hierarchical, class loaders need to be parallel capable, otherwise class loading can lead to deadlocks because the loader lock is held for the duration of the class loading process (see {@link #loadClass <tt>loadClass</tt>} methods). <p> Normally, the Java virtual machine loads classes from the local file system in a platform-dependent manner. For example, on UNIX systems, the virtual machine loads classes from the directory defined by the <tt>CLASSPATH</tt> environment variable. <p> However, some classes may not originate from a file; they may originate from other sources, such as the network, or they could be constructed by an application. The method {@link #defineClass(String, byte[], int, int) <tt>defineClass</tt>} converts an array of bytes into an instance of class <tt>Class</tt>. Instances of this newly defined class can be created using {@link Class#newInstance <tt>Class.newInstance</tt>}. <p> The methods and constructors of objects created by a class loader may reference other classes. To determine the class(es) referred to, the Java virtual machine invokes the {@link #loadClass <tt>loadClass</tt>} method of the class loader that originally created the class. <p> For example, an application could create a network class loader to download class files from a server. Sample code might look like: <blockquote><pre> ClassLoader loader = new NetworkClassLoader(host, port); Object main = loader.loadClass("Main", true).newInstance(); . . . </pre></blockquote> <p> The network class loader subclass must define the methods {@link #findClass <tt>findClass</tt>} and <tt>loadClassData</tt> to load a class from the network. Once it has downloaded the bytes that make up the class, it should use the method {@link #defineClass <tt>defineClass</tt>} to create a class instance. A sample implementation is: <blockquote><pre> class NetworkClassLoader extends ClassLoader { String host; int port; public Class findClass(String name) { byte[] b = loadClassData(name); return defineClass(name, b, 0, b.length); } private byte[] loadClassData(String name) { // load the class data from the connection . . . } } </pre></blockquote> <h3> <a name="name">Binary names</a> </h3> <p> Any class name provided as a {@link java.lang.String} parameter to methods in <tt>ClassLoader</tt> must be a binary name as defined by <cite>The Java™ Language Specification</cite>. <p> Examples of valid class names include: <blockquote><pre> "java.lang.String" "javax.swing.JSpinner$DefaultEditor" "java.security.KeyStore$Builder$FileBuilder$1" "java.net.URLClassLoader$3$1" </pre></blockquote> @see #resolveClass(Class) @since 1.0 */ var ClassLoader = { /** To avoid unloading individual classes, {@link java.lang.reflect.Proxy} only generates one class for each set of interfaces. This maps sets of interfaces to the proxy class that implements all of them. It is declared here so that these generated classes can be unloaded with their class loader. @hide */ proxyCache : "null", /**Loads the class with the specified <a href="#name">binary name</a>. This method searches for classes in the same manner as the {@link #loadClass(String, boolean)} method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking {@link #loadClass(String, boolean) <tt>loadClass(name, false)</tt>}. @param {String} name The <a href="#name">binary name</a> of the class @return {Object {java.lang.Class}} The resulting <tt>Class</tt> object @throws ClassNotFoundException If the class was not found */ loadClass : function( ) {}, /**Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. <p> The name of a resource is a '<tt>/</tt>'-separated path name that identifies the resource. <p> This method will first search the parent class loader for the resource; if the parent is <tt>null</tt> the path of the class loader built-in to the virtual machine is searched. That failing, this method will invoke {@link #findResource}(String) to find the resource. </p> @param {String} name The resource name @param name The resource name @return {Object {java.net.URL}} A <tt>URL</tt> object for reading the resource, or <tt>null</tt> if the resource could not be found or the invoker doesn't have adequate privileges to get the resource. @since 1.1 */ getResource : function( ) {}, /**Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. <p>The name of a resource is a <tt>/</tt>-separated path name that identifies the resource. <p> The search order is described in the documentation for {@link #getResource}(String). </p> @param {String} name The resource name @param name The resource name @return {Object {java.util.Enumeration}} An enumeration of {@link java.net.URL <tt>URL</tt>} objects for the resource. If no resources could be found, the enumeration will be empty. Resources that the class loader doesn't have access to will not be in the enumeration. @throws IOException If I/O errors occur @see #findResources(String) @since 1.2 */ getResources : function( ) {}, /**Find a resource of the specified name from the search path used to load classes. This method locates the resource through the system class loader (see {@link #getSystemClassLoader}()). @param {String} name The resource name @return {Object {java.net.URL}} A {@link java.net.URL <tt>URL</tt>} object for reading the resource, or <tt>null</tt> if the resource could not be found @since 1.1 */ getSystemResource : function( ) {}, /**Finds all resources of the specified name from the search path used to load classes. The resources thus found are returned as an {@link java.util.Enumeration <tt>Enumeration</tt>} of {@link java.net.URL <tt>URL</tt>} objects. <p> The search order is described in the documentation for {@link #getSystemResource}(String). </p> @param {String} name The resource name @return {Object {java.util.Enumeration}} An enumeration of resource {@link java.net.URL <tt>URL</tt>} objects @throws IOException If I/O errors occur @since 1.2 */ getSystemResources : function( ) {}, /**Returns an input stream for reading the specified resource. <p> The search order is described in the documentation for {@link #getResource}(String). </p> @param {String} name The resource name @return {Object {java.io.InputStream}} An input stream for reading the resource, or <tt>null</tt> if the resource could not be found @since 1.1 */ getResourceAsStream : function( ) {}, /**Open for reading, a resource of the specified name from the search path used to load classes. This method locates the resource through the system class loader (see {@link #getSystemClassLoader}()). @param {String} name The resource name @return {Object {java.io.InputStream}} An input stream for reading the resource, or <tt>null</tt> if the resource could not be found @since 1.1 */ getSystemResourceAsStream : function( ) {}, /**Returns the parent class loader for delegation. Some implementations may use <tt>null</tt> to represent the bootstrap class loader. This method will return <tt>null</tt> in such implementations if this class loader's parent is the bootstrap class loader. <p> If a security manager is present, and the invoker's class loader is not <tt>null</tt> and is not an ancestor of this class loader, then this method invokes the security manager's {@link SecurityManager#checkPermission(java.security.Permission) <tt>checkPermission</tt>} method with a {@link RuntimePermission#RuntimePermission(String) <tt>RuntimePermission("getClassLoader")</tt>} permission to verify access to the parent class loader is permitted. If not, a <tt>SecurityException</tt> will be thrown. </p> @return {Object {java.lang.ClassLoader}} The parent <tt>ClassLoader</tt> @throws SecurityException If a security manager exists and its <tt>checkPermission</tt> method doesn't allow access to this class loader's parent class loader. @since 1.2 */ getParent : function( ) {}, /**Returns the system class loader for delegation. This is the default delegation parent for new <tt>ClassLoader</tt> instances, and is typically the class loader used to start the application. <p> This method is first invoked early in the runtime's startup sequence, at which point it creates the system class loader and sets it as the context class loader of the invoking <tt>Thread</tt>. <p> The default system class loader is an implementation-dependent instance of this class. <p> If a security manager is present, and the invoker's class loader is not <tt>null</tt> and the invoker's class loader is not the same as or an ancestor of the system class loader, then this method invokes the security manager's {@link SecurityManager#checkPermission(java.security.Permission) <tt>checkPermission</tt>} method with a {@link RuntimePermission#RuntimePermission(String) <tt>RuntimePermission("getClassLoader")</tt>} permission to verify access to the system class loader. If not, a <tt>SecurityException</tt> will be thrown. </p> @return {Object {java.lang.ClassLoader}} The system <tt>ClassLoader</tt> for delegation, or <tt>null</tt> if none @throws SecurityException If a security manager exists and its <tt>checkPermission</tt> method doesn't allow access to the system class loader. @throws IllegalStateException If invoked recursively during the construction of the class loader specified by the "<tt>java.system.class.loader</tt>" property. @throws Error If the system property "<tt>java.system.class.loader</tt>" is defined but the named class could not be loaded, the provider class does not define the required constructor, or an exception is thrown by that constructor when it is invoked. The underlying cause of the error can be retrieved via the {@link Throwable#getCause()} method. @revised 1.4 */ getSystemClassLoader : function( ) {}, /**Sets the default assertion status for this class loader. This setting determines whether classes loaded by this class loader and initialized in the future will have assertions enabled or disabled by default. This setting may be overridden on a per-package or per-class basis by invoking {@link #setPackageAssertionStatus(String, boolean)} or {@link #setClassAssertionStatus(String, boolean)}. @param {Boolean} enabled <tt>true</tt> if classes loaded by this class loader will henceforth have assertions enabled by default, <tt>false</tt> if they will have assertions disabled by default. @since 1.4 */ setDefaultAssertionStatus : function( ) {}, /**Sets the package default assertion status for the named package. The package default assertion status determines the assertion status for classes initialized in the future that belong to the named package or any of its "subpackages". <p> A subpackage of a package named p is any package whose name begins with "<tt>p.</tt>". For example, <tt>javax.swing.text</tt> is a subpackage of <tt>javax.swing</tt>, and both <tt>java.util</tt> and <tt>java.lang.reflect</tt> are subpackages of <tt>java</tt>. <p> In the event that multiple package defaults apply to a given class, the package default pertaining to the most specific package takes precedence over the others. For example, if <tt>javax.lang</tt> and <tt>javax.lang.reflect</tt> both have package defaults associated with them, the latter package default applies to classes in <tt>javax.lang.reflect</tt>. <p> Package defaults take precedence over the class loader's default assertion status, and may be overridden on a per-class basis by invoking {@link #setClassAssertionStatus(String, boolean)}. </p> @param {String} packageName The name of the package whose package default assertion status is to be set. A <tt>null</tt> value indicates the unnamed package that is "current" (see section 7.4.2 of <cite>The Java™ Language Specification</cite>.) @param {Boolean} enabled <tt>true</tt> if classes loaded by this classloader and belonging to the named package or any of its subpackages will have assertions enabled by default, <tt>false</tt> if they will have assertions disabled by default. @since 1.4 */ setPackageAssertionStatus : function( ) {}, /**Sets the desired assertion status for the named top-level class in this class loader and any nested classes contained therein. This setting takes precedence over the class loader's default assertion status, and over any applicable per-package default. This method has no effect if the named class has already been initialized. (Once a class is initialized, its assertion status cannot change.) <p> If the named class is not a top-level class, this invocation will have no effect on the actual assertion status of any class. </p> @param {String} className The fully qualified class name of the top-level class whose assertion status is to be set. @param {Boolean} enabled <tt>true</tt> if the named class is to have assertions enabled when (and if) it is initialized, <tt>false</tt> if the class is to have assertions disabled. @since 1.4 */ setClassAssertionStatus : function( ) {}, /**Sets the default assertion status for this class loader to <tt>false</tt> and discards any package defaults or class assertion status settings associated with the class loader. This method is provided so that class loaders can be made to ignore any command line or persistent assertion status settings and "start with a clean slate." @since 1.4 */ clearAssertionStatus : function( ) {}, };