< prev index next >

src/java.base/share/classes/java/lang/ClassLoader.java

Print this page




1859      *
1860      * <p> If the system property "{@code java.system.class.loader}" is defined
1861      * when this method is first invoked then the value of that property is
1862      * taken to be the name of a class that will be returned as the system
1863      * class loader.  The class is loaded using the default system class loader
1864      * and must define a public constructor that takes a single parameter of
1865      * type {@code ClassLoader} which is used as the delegation parent.  An
1866      * instance is then created using this constructor with the default system
1867      * class loader as the parameter.  The resulting class loader is defined
1868      * to be the system class loader. During construction, the class loader
1869      * should take great care to avoid calling {@code getSystemClassLoader()}.
1870      * If circular initialization of the system class loader is detected then
1871      * an {@code IllegalStateException} is thrown.
1872      *
1873      * @implNote The system property to override the system class loader is not
1874      * examined until the VM is almost fully initialized. Code that executes
1875      * this method during startup should take care not to cache the return
1876      * value until the system is fully initialized.
1877      *
1878      * <p> The name of the built-in system class loader is {@code "app"}.
1879      * The class path used by the built-in system class loader is determined
1880      * by the system property "{@code java.class.path}" during early
1881      * initialization of the VM. If the system property is not defined,
1882      * or its value is an empty string, then there is no class path
1883      * when the initial module is a module on the application module path,
1884      * i.e. <em>a named module</em>. If the initial module is not on
1885      * the application module path then the class path defaults to
1886      * the current working directory.
1887      *
1888      * @return  The system {@code ClassLoader}
1889      *
1890      * @throws  SecurityException
1891      *          If a security manager is present, and the caller's class loader
1892      *          is not {@code null} and is not the same as or an ancestor of the
1893      *          system class loader, and the caller does not have the
1894      *          {@link RuntimePermission}{@code ("getClassLoader")}
1895      *
1896      * @throws  IllegalStateException
1897      *          If invoked recursively during the construction of the class
1898      *          loader specified by the "{@code java.system.class.loader}"
1899      *          property.
1900      *
1901      * @throws  Error
1902      *          If the system property "{@code java.system.class.loader}"
1903      *          is defined but the named class could not be loaded, the
1904      *          provider class does not define the required constructor, or an
1905      *          exception is thrown by that constructor when it is invoked. The




1859      *
1860      * <p> If the system property "{@code java.system.class.loader}" is defined
1861      * when this method is first invoked then the value of that property is
1862      * taken to be the name of a class that will be returned as the system
1863      * class loader.  The class is loaded using the default system class loader
1864      * and must define a public constructor that takes a single parameter of
1865      * type {@code ClassLoader} which is used as the delegation parent.  An
1866      * instance is then created using this constructor with the default system
1867      * class loader as the parameter.  The resulting class loader is defined
1868      * to be the system class loader. During construction, the class loader
1869      * should take great care to avoid calling {@code getSystemClassLoader()}.
1870      * If circular initialization of the system class loader is detected then
1871      * an {@code IllegalStateException} is thrown.
1872      *
1873      * @implNote The system property to override the system class loader is not
1874      * examined until the VM is almost fully initialized. Code that executes
1875      * this method during startup should take care not to cache the return
1876      * value until the system is fully initialized.
1877      *
1878      * <p> The name of the built-in system class loader is {@code "app"}.
1879      * It reads the system property "{@code java.class.path}" during early
1880      * initialization of the VM to determine the class path.
1881      * An empty value of "{@code java.class.path}" property is interpreted
1882      * differently depending on whether the initial module is named or not:
1883      * If named, the built-in system class loader will have no class path
1884      * i.e. only find classes and resources only from the application module
1885      * path; otherwise, if unnamed, it will set the class path to
1886      * the current working directory.
1887      *
1888      * @return  The system {@code ClassLoader}
1889      *
1890      * @throws  SecurityException
1891      *          If a security manager is present, and the caller's class loader
1892      *          is not {@code null} and is not the same as or an ancestor of the
1893      *          system class loader, and the caller does not have the
1894      *          {@link RuntimePermission}{@code ("getClassLoader")}
1895      *
1896      * @throws  IllegalStateException
1897      *          If invoked recursively during the construction of the class
1898      *          loader specified by the "{@code java.system.class.loader}"
1899      *          property.
1900      *
1901      * @throws  Error
1902      *          If the system property "{@code java.system.class.loader}"
1903      *          is defined but the named class could not be loaded, the
1904      *          provider class does not define the required constructor, or an
1905      *          exception is thrown by that constructor when it is invoked. The


< prev index next >