< prev index next >

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

Print this page




1876      * should take great care to avoid calling {@code getSystemClassLoader()}.
1877      * If circular initialization of the system class loader is detected then
1878      * an {@code IllegalStateException} is thrown.
1879      *
1880      * @implNote The system property to override the system class loader is not
1881      * examined until the VM is almost fully initialized. Code that executes
1882      * this method during startup should take care not to cache the return
1883      * value until the system is fully initialized.
1884      *
1885      * <p> The name of the built-in system class loader is {@code "app"}.
1886      * The system property "{@code java.class.path}" is read during early
1887      * initialization of the VM to determine the class path.
1888      * An empty value of "{@code java.class.path}" property is interpreted
1889      * differently depending on whether the initial module (the module
1890      * containing the main class) is named or unnamed:
1891      * If named, the built-in system class loader will have no class path and
1892      * will search for classes and resources using the application module path;
1893      * otherwise, if unnamed, it will set the class path to the current
1894      * working directory.
1895      *










1896      * @return  The system {@code ClassLoader}
1897      *
1898      * @throws  SecurityException
1899      *          If a security manager is present, and the caller's class loader
1900      *          is not {@code null} and is not the same as or an ancestor of the
1901      *          system class loader, and the caller does not have the
1902      *          {@link RuntimePermission}{@code ("getClassLoader")}
1903      *
1904      * @throws  IllegalStateException
1905      *          If invoked recursively during the construction of the class
1906      *          loader specified by the "{@code java.system.class.loader}"
1907      *          property.
1908      *
1909      * @throws  Error
1910      *          If the system property "{@code java.system.class.loader}"
1911      *          is defined but the named class could not be loaded, the
1912      *          provider class does not define the required constructor, or an
1913      *          exception is thrown by that constructor when it is invoked. The
1914      *          underlying cause of the error can be retrieved via the
1915      *          {@link Throwable#getCause()} method.




1876      * should take great care to avoid calling {@code getSystemClassLoader()}.
1877      * If circular initialization of the system class loader is detected then
1878      * an {@code IllegalStateException} is thrown.
1879      *
1880      * @implNote The system property to override the system class loader is not
1881      * examined until the VM is almost fully initialized. Code that executes
1882      * this method during startup should take care not to cache the return
1883      * value until the system is fully initialized.
1884      *
1885      * <p> The name of the built-in system class loader is {@code "app"}.
1886      * The system property "{@code java.class.path}" is read during early
1887      * initialization of the VM to determine the class path.
1888      * An empty value of "{@code java.class.path}" property is interpreted
1889      * differently depending on whether the initial module (the module
1890      * containing the main class) is named or unnamed:
1891      * If named, the built-in system class loader will have no class path and
1892      * will search for classes and resources using the application module path;
1893      * otherwise, if unnamed, it will set the class path to the current
1894      * working directory.
1895      *
1896      * <p> JAR files on the class path may contain a {@code Class-Path} manifest
1897      * attribute to specify dependent JAR files to be included in the class path.
1898      * {@code Class-Path} entries must meet certain conditions for validity (see
1899      * the <a href="{@docRoot}/../specs/jar/jar.html#class-path-attribute">
1900      * JAR File Specification</a> for details).  Invalid {@code Class-Path}
1901      * entries are ignored.  For debugging purposes, ignored entries can be
1902      * printed to the console if the
1903      * {@systemProperty jdk.net.URLClassPath.showIgnoredClassPathEntries} system
1904      * property is set to {@code true}.
1905      *
1906      * @return  The system {@code ClassLoader}
1907      *
1908      * @throws  SecurityException
1909      *          If a security manager is present, and the caller's class loader
1910      *          is not {@code null} and is not the same as or an ancestor of the
1911      *          system class loader, and the caller does not have the
1912      *          {@link RuntimePermission}{@code ("getClassLoader")}
1913      *
1914      * @throws  IllegalStateException
1915      *          If invoked recursively during the construction of the class
1916      *          loader specified by the "{@code java.system.class.loader}"
1917      *          property.
1918      *
1919      * @throws  Error
1920      *          If the system property "{@code java.system.class.loader}"
1921      *          is defined but the named class could not be loaded, the
1922      *          provider class does not define the required constructor, or an
1923      *          exception is thrown by that constructor when it is invoked. The
1924      *          underlying cause of the error can be retrieved via the
1925      *          {@link Throwable#getCause()} method.


< prev index next >