Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.
The name of a resource is a ' /
'-separated path name that
identifies the resource.
Resources in named modules are subject to the encapsulation rules
specified by Module.getResourceAsStream
.
Additionally, and except for the special case where the resource has a
name ending with " .class
", this method will only find resources in
packages of named modules when the package is Module.isOpen(String)
unconditionally (even if the caller of this method is in the
same module as the resource).
name
| The resource name |
URL
object for reading the resource; null
if
the resource could not be found, a URL
could not be
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.
NullPointerException | If name is null |
@implSpec The default implementation will first search the parent class
loader for the resource; if the parent is null
the path of the
class loader built into the virtual machine is searched. If not found,
this method will invoke findResource(String)
to find the resource.
@apiNote Where several modules are defined to the same class loader,
and where more than one module contains a resource with the given name,
then the ordering that modules are searched is not specified and may be
very unpredictable.
When overriding this method it is recommended that an implementation
ensures that any delegation is consistent with the getResources(String)
method.
@revised 9
@spec JPMS
Diagram: ClassLoader