8228773: URLClassLoader constructors should include API note warning that the parent should not be null
Reviewed-by: alanb, mullan
This commit is contained in:
parent
3a3ea7e17f
commit
84002d12ed
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -77,8 +77,15 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* the URL is assumed to refer to a JAR file which will be downloaded and
|
||||
* opened as needed.
|
||||
*
|
||||
* @apiNote If {@code parent} is specified as {@code null} (for the
|
||||
* bootstrap class loader) then there is no guarantee that all platform
|
||||
* classes are visible.
|
||||
* See {@linkplain ClassLoader##builtinLoaders Run-time Built-in Class Loaders}
|
||||
* for information on the bootstrap class loader and other built-in class loaders.
|
||||
*
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @param parent the parent class loader for delegation, can be {@code null}
|
||||
* for the bootstrap class loader
|
||||
* @throws NullPointerException if {@code urls} or any of its
|
||||
* elements is {@code null}.
|
||||
*/
|
||||
@ -89,12 +96,12 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
|
||||
/**
|
||||
* Constructs a new URLClassLoader for the specified URLs using the
|
||||
* default delegation parent {@code ClassLoader}. The URLs will
|
||||
* be searched in the order specified for classes and resources after
|
||||
* first searching in the parent class loader. Any URL that ends with
|
||||
* a '/' is assumed to refer to a directory. Otherwise, the URL is
|
||||
* assumed to refer to a JAR file which will be downloaded and opened
|
||||
* as needed.
|
||||
* {@linkplain ClassLoader#getSystemClassLoader() system class loader
|
||||
* as the parent}. The URLs will be searched in the order
|
||||
* specified for classes and resources after first searching in the
|
||||
* parent class loader. Any URL that ends with a '/' is assumed to
|
||||
* refer to a directory. Otherwise, the URL is assumed to refer to
|
||||
* a JAR file which will be downloaded and opened as needed.
|
||||
*
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
*
|
||||
@ -113,8 +120,15 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* factory argument will be used as the stream handler factory to
|
||||
* obtain protocol handlers when creating new jar URLs.
|
||||
*
|
||||
* @apiNote If {@code parent} is specified as {@code null} (for the
|
||||
* bootstrap class loader) then there is no guarantee that all platform
|
||||
* classes are visible.
|
||||
* See {@linkplain ClassLoader##builtinLoaders Run-time Built-in Class Loaders}
|
||||
* for information on the bootstrap class loader and other built-in class loaders.
|
||||
*
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @param parent the parent class loader for delegation, can be {@code null}
|
||||
* for the bootstrap class loader
|
||||
* @param factory the URLStreamHandlerFactory to use when creating URLs
|
||||
*
|
||||
* @throws NullPointerException if {@code urls} or any of its
|
||||
@ -135,9 +149,16 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* Otherwise, the URL is assumed to refer to a JAR file which will be
|
||||
* downloaded and opened as needed.
|
||||
*
|
||||
* @apiNote If {@code parent} is specified as {@code null} (for the
|
||||
* bootstrap class loader) then there is no guarantee that all platform
|
||||
* classes are visible.
|
||||
* See {@linkplain ClassLoader##builtinLoaders Run-time Built-in Class Loaders}
|
||||
* for information on the bootstrap class loader and other built-in class loaders.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @param parent the parent class loader for delegation, can be {@code null}
|
||||
* for the bootstrap class loader
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
* @throws NullPointerException if {@code urls} or any of its
|
||||
@ -159,9 +180,16 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* The factory argument will be used as the stream handler factory to
|
||||
* obtain protocol handlers when creating new jar URLs.
|
||||
*
|
||||
* @apiNote If {@code parent} is specified as {@code null} (for the
|
||||
* bootstrap class loader) then there is no guarantee that all platform
|
||||
* classes are visible.
|
||||
* See {@linkplain ClassLoader##builtinLoaders Run-time Built-in Class Loaders}
|
||||
* for information on the bootstrap class loader and other built-in class loaders.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @param parent the parent class loader for delegation, can be {@code null}
|
||||
* for the bootstrap class loader
|
||||
* @param factory the URLStreamHandlerFactory to use when creating URLs
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
|
@ -64,15 +64,22 @@ public class SecureClassLoader extends ClassLoader {
|
||||
* Creates a new {@code SecureClassLoader} using the specified parent
|
||||
* class loader for delegation.
|
||||
*
|
||||
* @param parent the parent ClassLoader
|
||||
* @apiNote If {@code parent} is specified as {@code null} (for the
|
||||
* bootstrap class loader) then there is no guarantee that all platform
|
||||
* classes are visible.
|
||||
* See {@linkplain ClassLoader##builtinLoaders Run-time Built-in Class Loaders}
|
||||
* for information on the bootstrap class loader and other built-in class loaders.
|
||||
*
|
||||
* @param parent the parent ClassLoader, can be {@code null} for the bootstrap
|
||||
* class loader
|
||||
*/
|
||||
protected SecureClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code SecureClassLoader} using the default parent class
|
||||
* loader for delegation.
|
||||
* Creates a new {@code SecureClassLoader} using the
|
||||
* {@linkplain ClassLoader#getSystemClassLoader() system class loader as the parent}.
|
||||
*/
|
||||
protected SecureClassLoader() {
|
||||
super();
|
||||
@ -82,8 +89,15 @@ public class SecureClassLoader extends ClassLoader {
|
||||
* Creates a new {@code SecureClassLoader} of the specified name and
|
||||
* using the specified parent class loader for delegation.
|
||||
*
|
||||
* @apiNote If {@code parent} is specified as {@code null} (for the
|
||||
* bootstrap class loader) then there is no guarantee that all platform
|
||||
* classes are visible.
|
||||
* See {@linkplain ClassLoader##builtinLoaders Run-time Built-in Class Loaders}
|
||||
* for information on the bootstrap class loader and other built-in class loaders.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param parent the parent class loader
|
||||
* @param parent the parent class loader, can be {@code null} for the bootstrap
|
||||
* class loader
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user