< prev index next >
src/java.base/share/classes/java/lang/ClassLoader.java
Print this page
@@ -205,10 +205,12 @@
*
* @jls 6.7 Fully Qualified Names
* @jls 13.1 The Form of a Binary
* @see #resolveClass(Class)
* @since 1.0
+ * @revised 9
+ * @spec JPMS
*/
public abstract class ClassLoader {
private static native void registerNatives();
static {
@@ -378,16 +380,16 @@
* If a security manager exists and its
* {@link SecurityManager#checkCreateClassLoader()}
* method doesn't allow creation of a new class loader.
*
* @since 9
+ * @spec JPMS
*/
protected ClassLoader(String name, ClassLoader parent) {
this(checkCreateClassLoader(name), name, parent);
}
-
/**
* Creates a new class loader using the specified parent class loader for
* delegation.
*
* <p> If there is a security manager, its {@link
@@ -438,10 +440,11 @@
*
* @return name of this class loader; or {@code null} if
* this class loader is not named.
*
* @since 9
+ * @spec JPMS
*/
public String getName() {
return name;
}
@@ -708,10 +711,11 @@
*
* @return The resulting {@code Class} object, or {@code null}
* if the class could not be found.
*
* @since 9
+ * @spec JPMS
*/
protected Class<?> findClass(String moduleName, String name) {
if (moduleName == null) {
try {
return findClass(name);
@@ -832,10 +836,12 @@
* @see #resolveClass(Class)
* @see java.security.CodeSource
* @see java.security.SecureClassLoader
*
* @since 1.1
+ * @revised 9
+ * @spec JPMS
*/
protected final Class<?> defineClass(String name, byte[] b, int off, int len)
throws ClassFormatError
{
return defineClass(name, b, off, len, null);
@@ -965,10 +971,13 @@
* If an attempt is made to add this class to a package that
* contains classes that were signed by a different set of
* certificates than this class, or if {@code name} begins with
* "{@code java.}" and this class loader is not the platform
* class loader or its ancestor.
+ *
+ * @revised 9
+ * @spec JPMS
*/
protected final Class<?> defineClass(String name, byte[] b, int off, int len,
ProtectionDomain protectionDomain)
throws ClassFormatError
{
@@ -1039,10 +1048,12 @@
* "{@code java.}".
*
* @see #defineClass(String, byte[], int, int, ProtectionDomain)
*
* @since 1.5
+ * @revised 9
+ * @spec JPMS
*/
protected final Class<?> defineClass(String name, java.nio.ByteBuffer b,
ProtectionDomain protectionDomain)
throws ClassFormatError
{
@@ -1262,15 +1273,15 @@
/**
* Returns a URL to a resource in a module defined to this class loader.
* Class loader implementations that support the loading from modules
* should override this method.
*
- * @apiNote This method is the basis for the {@code Class} {@link
- * Class#getResource getResource} and {@link Class#getResourceAsStream
- * getResourceAsStream} methods. It is not subject to the rules for
- * encapsulation specified by {@code Module} {@link
- * Module#getResourceAsStream getResourceAsStream}.
+ * @apiNote This method is the basis for the {@link
+ * Class#getResource Class.getResource}, {@link Class#getResourceAsStream
+ * Class.getResourceAsStream}, and {@link Module#getResourceAsStream
+ * Module.getResourceAsStream} methods. It is not subject to the rules for
+ * encapsulation specified by {@code Module.getResourceAsStream}.
*
* @implSpec The default implementation attempts to find the resource by
* invoking {@link #findResource(String)} when the {@code moduleName} is
* {@code null}. It otherwise returns {@code null}.
*
@@ -1290,10 +1301,11 @@
* @throws IOException
* If I/O errors occur
*
* @see java.lang.module.ModuleReader#find(String)
* @since 9
+ * @spec JPMS
*/
protected URL findResource(String moduleName, String name) throws IOException {
if (moduleName == null) {
return findResource(name);
} else {
@@ -1340,10 +1352,12 @@
* denied by the security manager.
*
* @throws NullPointerException If {@code name} is {@code null}
*
* @since 1.1
+ * @revised 9
+ * @spec JPMS
*/
public URL getResource(String name) {
Objects.requireNonNull(name);
URL url;
if (parent != null) {
@@ -1401,10 +1415,12 @@
* @throws NullPointerException If {@code name} is {@code null}
*
* @see #findResources(String)
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*/
public Enumeration<URL> getResources(String name) throws IOException {
Objects.requireNonNull(name);
@SuppressWarnings("unchecked")
Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2];
@@ -1497,10 +1513,12 @@
* constructed to locate the resource, the resource is in a package
* that is not opened unconditionally, or access to the resource is
* denied by the security manager.
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*/
protected URL findResource(String name) {
return null;
}
@@ -1529,10 +1547,12 @@
*
* @throws IOException
* If I/O errors occur
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*/
protected Enumeration<URL> findResources(String name) throws IOException {
return Collections.emptyEnumeration();
}
@@ -1599,10 +1619,12 @@
* constructed to locate the resource, the resource is in a package
* that is not opened unconditionally or access to the resource is
* denied by the security manager.
*
* @since 1.1
+ * @revised 9
+ * @spec JPMS
*/
public static URL getSystemResource(String name) {
return getSystemClassLoader().getResource(name);
}
@@ -1634,10 +1656,12 @@
*
* @throws IOException
* If I/O errors occur
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*/
public static Enumeration<URL> getSystemResources(String name)
throws IOException
{
return getSystemClassLoader().getResources(name);
@@ -1665,10 +1689,12 @@
* denied by the security manager.
*
* @throws NullPointerException If {@code name} is {@code null}
*
* @since 1.1
+ * @revised 9
+ * @spec JPMS
*/
public InputStream getResourceAsStream(String name) {
Objects.requireNonNull(name);
URL url = getResource(name);
try {
@@ -1697,10 +1723,12 @@
* resource could not be found, the resource is in a package that
* is not opened unconditionally, or access to the resource is
* denied by the security manager.
*
* @since 1.1
+ * @revised 9
+ * @spec JPMS
*/
public static InputStream getSystemResourceAsStream(String name) {
URL url = getSystemResource(name);
try {
return url != null ? url.openStream() : null;
@@ -1747,10 +1775,11 @@
*
* @return The unnamed Module for this class loader
*
* @see Module#isNamed()
* @since 9
+ * @spec JPMS
*/
public final Module getUnnamedModule() {
return unnamedModule;
}
@@ -1770,10 +1799,11 @@
* as or an ancestor of the platform class loader,
* and the caller does not have the
* {@link RuntimePermission}{@code ("getClassLoader")}
*
* @since 9
+ * @spec JPMS
*/
@CallerSensitive
public static ClassLoader getPlatformClassLoader() {
SecurityManager sm = System.getSecurityManager();
ClassLoader loader = getBuiltinPlatformClassLoader();
@@ -1845,10 +1875,12 @@
* exception is thrown by that constructor when it is invoked. The
* underlying cause of the error can be retrieved via the
* {@link Throwable#getCause()} method.
*
* @revised 1.4
+ * @revised 9
+ * @spec JPMS
*/
@CallerSensitive
public static ClassLoader getSystemClassLoader() {
switch (VM.initLevel()) {
case 0:
@@ -2099,10 +2131,12 @@
* @throws IllegalArgumentException
* if a package of the given {@code name} is already
* defined by this class loader
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*
* @see <a href="../../../technotes/guides/jar/jar.html#versioning">
* The JAR File Specification: Package Versioning</a>
* @see <a href="../../../technotes/guides/jar/jar.html#sealing">
* The JAR File Specification: Package Sealing</a>
@@ -2136,10 +2170,11 @@
*
* @throws NullPointerException
* if {@code name} is {@code null}.
*
* @since 9
+ * @spec JPMS
*/
public final Package getDefinedPackage(String name) {
Objects.requireNonNull(name, "name cannot be null");
NamedPackage p = packages.get(name);
@@ -2158,10 +2193,11 @@
*
* @return The array of {@code Package} objects defined by this class loader;
* or an zero length array if no package has been defined by this class loader.
*
* @since 9
+ * @spec JPMS
*/
public final Package[] getDefinedPackages() {
return packages().toArray(Package[]::new);
}
@@ -2194,10 +2230,12 @@
* a child loader. A more robust approach is to use the
* {@link ClassLoader#getDefinedPackage} method which returns
* a {@code Package} for the specified class loader.
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*/
@Deprecated(since="9")
protected Package getPackage(String name) {
Package pkg = getDefinedPackage(name);
if (pkg == null) {
@@ -2218,10 +2256,12 @@
*
* @return The array of {@code Package} objects defined by this
* class loader and its ancestors
*
* @since 1.2
+ * @revised 9
+ * @spec JPMS
*/
protected Package[] getPackages() {
Stream<Package> pkgs = packages();
ClassLoader ld = parent;
while (ld != null) {
< prev index next >