Returns package information for the given package. Unfortunately, the
PathClassLoader doesn't really have this information, and as a
non-secure ClassLoader, it isn't even required to, according to the spec.
Yet, we want to provide it, in order to make all those hopeful callers of
myClass.getPackage().getName()
happy. Thus we construct a
Package object the first time it is being requested and fill most of the
fields with dummy values. The Package object is then put into the
ClassLoader's Package cache, so we see the same one next time. We don't
create Package objects for null arguments or for the default package.
There a limited chance that we end up with multiple Package objects
representing the same package: It can happen when when a package is
scattered across different JAR files being loaded by different
ClassLoaders. Rather unlikely, and given that this whole thing is more or
less a workaround, probably not worth the effort.
Parameters
name
| The name of the package to find |
Returns
- The package requested, or null