Package java.lang

Class ClassLoader

  • Direct Known Subclasses:
    URLClassLoader

    public class ClassLoader
    extends Object
    This stripped down ClassLoader class is simply here to give us cross-platform support for code that might need a valid classloader.

    xapi-gwt-reflect does call into the one and only system classloader, to define mappings of java-names to runtime classes, in order to enable Class.forName() and ClassLoader.loadClass();

    Author:
    "James X. Nelson (james@wetheinter.net)"
    • Constructor Detail

      • ClassLoader

        protected ClassLoader​(ClassLoader parent)
        Creates a new class loader using the specified parent class loader for delegation.
        Parameters:
        parent - The parent class loader
      • ClassLoader

        protected ClassLoader()
        Creates a new class loader using the ClassLoader returned by the method getSystemClassLoader() as the parent class loader.
    • Method Detail

      • loadClass

        protected Class<?> loadClass​(String name,
                                     boolean resolve)
                              throws ClassNotFoundException
        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
        Throws:
        ClassNotFoundException - If the class could not be found
      • findClass

        protected Class<?> findClass​(String name)
                              throws ClassNotFoundException
        Finds the class with the specified binary name. This method should be overridden by class loader implementations that follow the delegation model for loading classes, and will be invoked by the loadClass method after checking the parent class loader for the requested class. The default implementation throws a ClassNotFoundException.

        Parameters:
        name - The binary name of the class
        Returns:
        The resulting Class object
        Throws:
        ClassNotFoundException - If the class could not be found
        Since:
        1.2
      • setSigners

        protected final void setSigners​(Class<?> pclass,
                                        Object[] signers)
        No-op for compatibility.
      • getResource

        public URL getResource​(String name)
      • getResourceAsStream

        public InputStream getResourceAsStream​(String name)
        Unsupported.
      • getSystemResourceAsStream

        public static InputStream getSystemResourceAsStream​(String name)
        Unsupported.
      • getParent

        public final ClassLoader getParent()
        Returns the parent class loader for delegation. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class loader's parent is the bootstrap class loader.
      • getSystemClassLoader

        public static ClassLoader getSystemClassLoader()
        get system class loader.
        Returns:
        ClassLoader