public class

AppletClassLoader

extends URLClassLoader
java.lang.Object
   ↳ java.lang.ClassLoader
     ↳ java.security.SecureClassLoader
       ↳ java.net.URLClassLoader
         ↳ sun.applet.AppletClassLoader

Class Overview

This class defines the class loader for loading applet classes and resources. It extends URLClassLoader to search the applet code base for the class or resource after checking any loaded JAR files.

Summary

Protected Constructors
AppletClassLoader(URL base)
Public Methods
URL findResource(String name)
Finds the resource with the specified name on the URL search path.
Enumeration findResources(String name)
Returns an Enumeration of URLs representing all of the resources on the URL search path having the specified name.
AppContext getAppContext()
boolean getExceptionStatus()
InputStream getResourceAsStream(String name)
Returns an input stream for reading the specified resource.
InputStream getResourceAsStreamFromJar(String name)
Returns an input stream for reading the specified resource from the the loaded jar files.
ThreadGroup getThreadGroup()
URL[] getURLs()
Returns the search path of URLs for loading classes and resources.
synchronized Class loadClass(String name, boolean resolve)
Loads the class with the specified binary name.
Protected Methods
void addJar(String name)
Class findClass(String name)
Finds and loads the class with the specified name from the URL search path.
PermissionCollection getPermissions(CodeSource codesource)
Returns the permissions for the given codesource object.
void release()
Release this AppletClassLoader and its ThreadGroup/AppContext.
void setExceptionStatus()
[Expand]
Inherited Methods
From class java.net.URLClassLoader
From class java.security.SecureClassLoader
From class java.lang.ClassLoader
From class java.lang.Object

Protected Constructors

protected AppletClassLoader (URL base)

Public Methods

public URL findResource (String name)

Finds the resource with the specified name on the URL search path.

Parameters
name the name of the resource
Returns
  • a URL for the resource, or null if the resource could not be found.

public Enumeration findResources (String name)

Returns an Enumeration of URLs representing all of the resources on the URL search path having the specified name.

Parameters
name the resource name
Returns
  • an Enumeration of URLs
Throws
IOException

public AppContext getAppContext ()

public boolean getExceptionStatus ()

public InputStream getResourceAsStream (String name)

Returns an input stream for reading the specified resource. The search order is described in the documentation for getResource(String).

Parameters
name the resource name
Returns
  • an input stream for reading the resource, or null if the resource could not be found

public InputStream getResourceAsStreamFromJar (String name)

Returns an input stream for reading the specified resource from the the loaded jar files. The search order is described in the documentation for getResource(String).

Parameters
name the resource name
Returns
  • an input stream for reading the resource, or null if the resource could not be found

public ThreadGroup getThreadGroup ()

public URL[] getURLs ()

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.

Returns
  • the search path of URLs for loading classes and resources.

public synchronized Class loadClass (String name, boolean resolve)

Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:

  1. Invoke findLoadedClass(String) to check if the class has already been loaded.

  2. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead.

  3. Invoke the findClass(String) method to find the class.

If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object.

Subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.

Parameters
name The binary name of the class
resolve If true then resolve the class
Returns
  • The resulting Class object

Protected Methods

protected void addJar (String name)

Throws
IOException

protected Class findClass (String name)

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.

Parameters
name the name of the class
Returns
  • the resulting class

protected PermissionCollection getPermissions (CodeSource codesource)

Returns the permissions for the given codesource object. The implementation of this method first calls super.getPermissions, to get the permissions granted by the super class, and then adds additional permissions based on the URL of the codesource.

If the protocol is "file" and the path specifies a file, permission is granted to read all files and (recursively) all files and subdirectories contained in that directory. This is so applets with a codebase of file:/blah/some.jar can read in file:/blah/, which is needed to be backward compatible. We also add permission to connect back to the "localhost".

Parameters
codesource the codesource
Returns
  • the permissions granted to the codesource

protected void release ()

Release this AppletClassLoader and its ThreadGroup/AppContext. If nothing else has grabbed this AppletClassLoader, its ThreadGroup and AppContext will be destroyed. Because this method may destroy the AppletClassLoader's ThreadGroup, this method should NOT be called from within the AppletClassLoader's ThreadGroup. Changed modifier to protected in order to be able to overwrite this function in PluginClassLoader.java

protected void setExceptionStatus ()