< prev index next >

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

Print this page




1664      * instance of this class.
1665      *
1666      * <p> If the system property "<tt>java.system.class.loader</tt>" is defined
1667      * when this method is first invoked then the value of that property is
1668      * taken to be the name of a class that will be returned as the system
1669      * class loader.  The class is loaded using the default system class loader
1670      * and must define a public constructor that takes a single parameter of
1671      * type <tt>ClassLoader</tt> which is used as the delegation parent.  An
1672      * instance is then created using this constructor with the default system
1673      * class loader as the parameter.  The resulting class loader is defined
1674      * to be the system class loader. During construction, the class loader
1675      * should take great care to avoid calling {@code getSystemClassLoader()}.
1676      * If circular initialization of the system class loader is detected then
1677      * an unspecified error or exception is thrown.
1678      *
1679      * @implNote The system property to override the system class loader is not
1680      * examined until the VM is almost fully initialized. Code that executes
1681      * this method during startup should take care not to cache the return
1682      * value until the system is fully initialized.
1683      *









1684      * @return  The system <tt>ClassLoader</tt> for delegation
1685      *
1686      * @throws  SecurityException
1687      *          If a security manager is present, and the caller's class loader
1688      *          is not {@code null} and is not the same as or an ancestor of the
1689      *          system class loader, and the caller does not have the
1690      *          {@link RuntimePermission}{@code ("getClassLoader")}
1691      *
1692      * @throws  IllegalStateException
1693      *          If invoked recursively during the construction of the class
1694      *          loader specified by the "<tt>java.system.class.loader</tt>"
1695      *          property.
1696      *
1697      * @throws  Error
1698      *          If the system property "<tt>java.system.class.loader</tt>"
1699      *          is defined but the named class could not be loaded, the
1700      *          provider class does not define the required constructor, or an
1701      *          exception is thrown by that constructor when it is invoked. The
1702      *          underlying cause of the error can be retrieved via the
1703      *          {@link Throwable#getCause()} method.




1664      * instance of this class.
1665      *
1666      * <p> If the system property "<tt>java.system.class.loader</tt>" is defined
1667      * when this method is first invoked then the value of that property is
1668      * taken to be the name of a class that will be returned as the system
1669      * class loader.  The class is loaded using the default system class loader
1670      * and must define a public constructor that takes a single parameter of
1671      * type <tt>ClassLoader</tt> which is used as the delegation parent.  An
1672      * instance is then created using this constructor with the default system
1673      * class loader as the parameter.  The resulting class loader is defined
1674      * to be the system class loader. During construction, the class loader
1675      * should take great care to avoid calling {@code getSystemClassLoader()}.
1676      * If circular initialization of the system class loader is detected then
1677      * an unspecified error or exception is thrown.
1678      *
1679      * @implNote The system property to override the system class loader is not
1680      * examined until the VM is almost fully initialized. Code that executes
1681      * this method during startup should take care not to cache the return
1682      * value until the system is fully initialized.
1683      *
1684      * <p> The class path used by the built-in system class loader is determined
1685      * by the system property "{@code java.class.path}" during early
1686      * initialization of the VM. If the system property is not defined,
1687      * or its value is an empty string, then there is no class path
1688      * when the initial module is a module on the application module path,
1689      * i.e. <em>a named module</em>. If the initial module is not on
1690      * the application module path then the class path defaults to
1691      * the current working directory.
1692      *
1693      * @return  The system <tt>ClassLoader</tt> for delegation
1694      *
1695      * @throws  SecurityException
1696      *          If a security manager is present, and the caller's class loader
1697      *          is not {@code null} and is not the same as or an ancestor of the
1698      *          system class loader, and the caller does not have the
1699      *          {@link RuntimePermission}{@code ("getClassLoader")}
1700      *
1701      * @throws  IllegalStateException
1702      *          If invoked recursively during the construction of the class
1703      *          loader specified by the "<tt>java.system.class.loader</tt>"
1704      *          property.
1705      *
1706      * @throws  Error
1707      *          If the system property "<tt>java.system.class.loader</tt>"
1708      *          is defined but the named class could not be loaded, the
1709      *          provider class does not define the required constructor, or an
1710      *          exception is thrown by that constructor when it is invoked. The
1711      *          underlying cause of the error can be retrieved via the
1712      *          {@link Throwable#getCause()} method.


< prev index next >