Java Reference
In-Depth Information
protected Package
definePackage(String name, String specTitle,
String specVersion, String specVendor, String implTitle, String im-
plVersion, String implVendor, URL sealBase)
Returns a
Package
object with the given name, and with spe-
cification and implementation values set to the corresponding
arguments. If
sealBase
is
null
the package is unsealed, other-
wise it is sealed with respect to that
URL
. The
Package
object for
a class must be defined before the class is defined and pack-
age names must be unique within a class loader. If the pack-
age name duplicates an existing name, an
IllegalArgumentEx-
ception
is thrown.
You can get the
Package
object for a given class from the
getPackage
method of the
Class
object for that class. You can also get a
Package
object by invoking either the static method
Package.getPackage
with the
name of the package, or the static method
Package.getPackages
, which
returns an array of all known packages. Both methods work with respect
to the class loader of the code making the call by invoking the
getPack-
age
or
getPackages
method of that class loader. These class loader meth-
ods search the specific class loader and all of its parents. If there is no
current class loader then the system class loader is used. Note that the
class loader methods will return
null
if the package is unknown because
no type from the package has been loaded.
When a shepherd goes to kill a wolf, and takes his dog along to
see the sport, he should take care to avoid mistakes. The dog has
certain relationships to the wolf the shepherd may have forgotten.
Robert Prisig,
Zen and the Art of Motorcycle Maintenance