Package.java revision 3909
3909N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * {@code Package} objects contain version information 0N/A * about the implementation and specification of a Java package. 0N/A * This versioning information is retrieved and made available 0N/A * by the {@link ClassLoader} instance that 0N/A * loaded the class(es). Typically, it is stored in the manifest that is 0N/A * distributed with the classes. 0N/A * <p>The set of classes that make up the package may implement a 0N/A * particular specification and if so the specification title, version number, 0N/A * and vendor strings identify that specification. 0N/A * An application can ask if the package is 0N/A * compatible with a particular version, see the {@link 0N/A * #isCompatibleWith isCompatibleWith} 0N/A * method for details. 0N/A * <p>Specification version numbers use a syntax that consists of nonnegative 0N/A * decimal integers separated by periods ".", for example "2.0" or 0N/A * "1.2.3.4.5.6.7". This allows an extensible number to be used to represent 0N/A * major, minor, micro, etc. versions. The version specification is described 0N/A * by the following formal grammar: 0N/A * <dt><i>SpecificationVersion: 0N/A * <dd>Digits RefinedVersion<sub>opt</sub></i> 0N/A * <p><dt><i>RefinedVersion:</i> 0N/A * <dd>{@code .} <i>Digits</i> 0N/A * <dd>{@code .} <i>Digits RefinedVersion</i> 0N/A * <p><dt><i>Digit:</i> 0N/A * <dd>any character for which {@link Character#isDigit} returns {@code true}, 0N/A * <p>The implementation title, version, and vendor strings identify an 0N/A * implementation and are made available conveniently to enable accurate 0N/A * reporting of the packages involved when a problem occurs. The contents 0N/A * all three implementation strings are vendor specific. The 0N/A * implementation version strings have no specified syntax and should 0N/A * only be compared for equality with desired version identifiers. 0N/A * <p>Within each {@code ClassLoader} instance all classes from the same 0N/A * java package have the same Package object. The static methods allow a package 0N/A * to be found by name or the set of all packages known to the current class 0N/A * loader to be found. 0N/A * @see ClassLoader#definePackage 0N/A * Return the name of this package. 0N/A * @return The fully-qualified name of this package as defined in the 0N/A * <em>Java Language Specification, Third Edition</em> 0N/A * §6.5.3</a>, for example, {@code java.lang} 0N/A * Return the title of the specification that this package implements. 0N/A * @return the specification title, null is returned if it is not known. 0N/A * Returns the version number of the specification 0N/A * that this package implements. 0N/A * This version string must be a sequence of nonnegative decimal 0N/A * integers separated by "."'s and may have leading zeros. 0N/A * When version strings are compared the most significant 0N/A * numbers are compared. 0N/A * @return the specification version, null is returned if it is not known. 0N/A * Return the name of the organization, vendor, 0N/A * or company that owns and maintains the specification 0N/A * of the classes that implement this package. 0N/A * @return the specification vendor, null is returned if it is not known. 0N/A * Return the title of this package. 0N/A * @return the title of the implementation, null is returned if it is not known. 0N/A * Return the version of this implementation. It consists of any string 0N/A * assigned by the vendor of this implementation and does 0N/A * not have any particular syntax specified or expected by the Java 0N/A * runtime. It may be compared for equality with other 0N/A * package version strings used for this implementation 0N/A * by this vendor for this package. 0N/A * @return the version of the implementation, null is returned if it is not known. 0N/A * Returns the name of the organization, 0N/A * vendor or company that provided this implementation. 0N/A * @return the vendor that implemented this package.. 0N/A * Returns true if this package is sealed. 0N/A * @return true if the package is sealed, false otherwise 0N/A * Returns true if this package is sealed with respect to the specified 0N/A * @param url the code source url 0N/A * @return true if this package is sealed with respect to url 0N/A * Compare this package's specification version with a 0N/A * desired version. It returns true if 0N/A * this packages specification version number is greater than or equal 0N/A * to the desired version number. <p> 0N/A * Version numbers are compared by sequentially comparing corresponding 0N/A * components of the desired and specification strings. 0N/A * Each component is converted as a decimal integer and the values 0N/A * If the specification value is greater than the desired 0N/A * value true is returned. If the value is less false is returned. 0N/A * If the values are equal the period is skipped and the next pair of 0N/A * components is compared. 0N/A * @param desired the version string of the desired version. 0N/A * @return true if this package's version number is greater 0N/A * than or equal to the desired version number 0N/A * @exception NumberFormatException if the desired or current version 0N/A * is not of the correct dotted form. 0N/A for (
int i =
0; i <
len; i++) {
0N/A * Find a package by name in the callers {@code ClassLoader} instance. 0N/A * The callers {@code ClassLoader} instance is used to find the package 0N/A * instance corresponding to the named class. If the callers 0N/A * {@code ClassLoader} instance is null then the set of packages loaded 0N/A * by the system {@code ClassLoader} instance is searched to find the 0N/A * named package. <p> 0N/A * Packages have attributes for versions and specifications only if the class 0N/A * loader created the package instance with the appropriate attributes. Typically, 0N/A * those attributes are defined in the manifests that accompany the classes. 0N/A * @param name a package name, for example, java.lang. 0N/A * @return the package of the requested name. It may be null if no package 0N/A * information is available from the archive or codebase. 0N/A * Get all the packages currently known for the caller's {@code ClassLoader} 0N/A * instance. Those packages correspond to classes loaded via or accessible by 0N/A * name to that {@code ClassLoader} instance. If the caller's 0N/A * {@code ClassLoader} instance is the bootstrap {@code ClassLoader} 0N/A * instance, which may be represented by {@code null} in some implementations, 0N/A * only packages corresponding to classes loaded by the bootstrap 0N/A * {@code ClassLoader} instance will be returned. 0N/A * @return a new array of packages known to the callers {@code ClassLoader} 0N/A * instance. An zero length array is returned if none are known. 0N/A * Get the package for the specified class. 0N/A * The class's class loader is used to find the package instance 0N/A * corresponding to the specified class. If the class loader 0N/A * is the bootstrap class loader, which may be represented by 0N/A * {@code null} in some implementations, then the set of packages 0N/A * loaded by the bootstrap class loader is searched to find the package. 0N/A * Packages have attributes for versions and specifications only 0N/A * if the class loader created the package 0N/A * instance with the appropriate attributes. Typically those 0N/A * attributes are defined in the manifests that accompany 0N/A * @param class the class to get the package of. 0N/A * @return the package of the class. It may be null if no package 0N/A * information is available from the archive or codebase. */ 0N/A * Return the hash code computed from the package name. 0N/A * @return the hash code computed from the package name. 0N/A * Returns the string representation of this Package. 0N/A * Its value is the string "package " and the package name. 0N/A * If the package title is defined it is appended. 0N/A * If the package version is defined it is appended. 0N/A * @return the string representation of the package. 0N/A // store a proxy for the package info that has no annotations 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * Construct a package instance with the specified version 0N/A * @param pkgName the name of the package 0N/A * @param spectitle the title of the specification 0N/A * @param specversion the version of the specification 0N/A * @param specvendor the organization that maintains the specification 0N/A * @param impltitle the title of the implementation 0N/A * @param implversion the version of the implementation 0N/A * @param implvendor the organization that maintains the implementation 0N/A * @return a new package for containing the specified information. 0N/A * Construct a package using the attributes from the specified manifest. 0N/A * @param name the package name 0N/A * @param man the optional manifest for the package 0N/A * @param url the optional code source url for the package 0N/A * Returns the loaded system package for the specified name. 0N/A * Return an array of loaded system packages. 0N/A // First, update the system package map with new package names 0N/A // Get the cached code source url for the file name 0N/A // URL not found, so create one 0N/A // If loading a JAR file, then also cache the manifest 0N/A // Convert to "."-separated package name 0N/A * Returns the Manifest for the specified JAR file name. 0N/A // The map of loaded system packages 0N/A // Maps each directory or zip file name to its corresponding url 0N/A // Maps each code source url for a jar file to its manifest 0N/A * Private storage for the package name and attributes.