Class RhinoClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable, org.mozilla.javascript.GeneratedClassLoader

public class RhinoClassLoader extends URLClassLoader implements org.mozilla.javascript.GeneratedClassLoader
This class loader implementation will work whether or not the documentURL is null.
  • Field Details

    • documentURL

      protected URL documentURL
      URL for the document referencing the script.
    • codeSource

      protected CodeSource codeSource
      CodeSource for classes defined by this loader
    • rhinoAccessControlContext

      protected AccessControlContext rhinoAccessControlContext
      The AccessControlContext which can be associated with code loaded by this class loader if it was running stand-alone (i.e., not invoked by code with lesser priviledges).
  • Constructor Details

    • RhinoClassLoader

      public RhinoClassLoader(URL documentURL, ClassLoader parent)
      Constructor.
      Parameters:
      documentURL - the URL from which to load classes and resources
      parent - the parent class loader for delegation
  • Method Details

    • defineClass

      public Class defineClass(String name, byte[] data)
      Define and load a Java class
      Specified by:
      defineClass in interface org.mozilla.javascript.GeneratedClassLoader
    • linkClass

      public void linkClass(Class clazz)
      Links the Java class.
      Specified by:
      linkClass in interface org.mozilla.javascript.GeneratedClassLoader
    • getAccessControlContext

      public AccessControlContext getAccessControlContext()
      Returns the AccessControlContext which should be associated with RhinoCode.
    • getPermissions

      protected PermissionCollection getPermissions(CodeSource codesource)
      Returns the permissions for the given CodeSource object. Compared to URLClassLoader, this adds a FilePermission so that files under the same root directory as the document can be read.
      Overrides:
      getPermissions in class URLClassLoader