< prev index next >

src/java.base/share/classes/java/util/jar/Attributes.java

Print this page
rev 52800 : 8214712: Archive Attributes$Name.KNOWN_NAMES
Reviewed-by: TBD

*** 32,41 **** --- 32,43 ---- import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Set; + import jdk.internal.misc.VM; + import jdk.internal.vm.annotation.Stable; import sun.util.logging.PlatformLogger; /** * The Attributes class maps Manifest attribute names to associated string * values. Valid attribute names are case-insensitive, are restricted to
*** 464,474 **** private final int hashCode; /** * Avoid allocation for common Names */ ! private static final Map<String, Name> KNOWN_NAMES; static final Name of(String name) { Name n = KNOWN_NAMES.get(name); if (n != null) { return n; --- 466,476 ---- private final int hashCode; /** * Avoid allocation for common Names */ ! private static @Stable Map<String, Name> KNOWN_NAMES; static final Name of(String name) { Name n = KNOWN_NAMES.get(name); if (n != null) { return n;
*** 551,688 **** * manifest attribute. This attribute indicates the version number * of the manifest standard to which a JAR file's manifest conforms. * @see <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest"> * Manifest and Signature Specification</a> */ ! public static final Name MANIFEST_VERSION = new Name("Manifest-Version"); /** * {@code Name} object for {@code Signature-Version} * manifest attribute used when signing JAR files. * @see <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest"> * Manifest and Signature Specification</a> */ ! public static final Name SIGNATURE_VERSION = new Name("Signature-Version"); /** * {@code Name} object for {@code Content-Type} * manifest attribute. */ ! public static final Name CONTENT_TYPE = new Name("Content-Type"); /** * {@code Name} object for {@code Class-Path} * manifest attribute. * @see <a href="{@docRoot}/../specs/jar/jar.html#class-path-attribute"> * JAR file specification</a> */ ! public static final Name CLASS_PATH = new Name("Class-Path"); /** * {@code Name} object for {@code Main-Class} manifest * attribute used for launching applications packaged in JAR files. * The {@code Main-Class} attribute is used in conjunction * with the {@code -jar} command-line option of the * {@code java} application launcher. */ ! public static final Name MAIN_CLASS = new Name("Main-Class"); /** * {@code Name} object for {@code Sealed} manifest attribute * used for sealing. * @see <a href="{@docRoot}/../specs/jar/jar.html#package-sealing"> * Package Sealing</a> */ ! public static final Name SEALED = new Name("Sealed"); /** * {@code Name} object for {@code Extension-List} manifest attribute * used for the extension mechanism that is no longer supported. */ ! public static final Name EXTENSION_LIST = new Name("Extension-List"); /** * {@code Name} object for {@code Extension-Name} manifest attribute. * used for the extension mechanism that is no longer supported. */ ! public static final Name EXTENSION_NAME = new Name("Extension-Name"); /** * {@code Name} object for {@code Extension-Installation} manifest attribute. * * @deprecated Extension mechanism is no longer supported. */ @Deprecated ! public static final Name EXTENSION_INSTALLATION = new Name("Extension-Installation"); /** * {@code Name} object for {@code Implementation-Title} * manifest attribute used for package versioning. */ ! public static final Name IMPLEMENTATION_TITLE = new Name("Implementation-Title"); /** * {@code Name} object for {@code Implementation-Version} * manifest attribute used for package versioning. */ ! public static final Name IMPLEMENTATION_VERSION = new Name("Implementation-Version"); /** * {@code Name} object for {@code Implementation-Vendor} * manifest attribute used for package versioning. */ ! public static final Name IMPLEMENTATION_VENDOR = new Name("Implementation-Vendor"); /** * {@code Name} object for {@code Implementation-Vendor-Id} * manifest attribute. * * @deprecated Extension mechanism is no longer supported. */ @Deprecated ! public static final Name IMPLEMENTATION_VENDOR_ID = new Name("Implementation-Vendor-Id"); /** * {@code Name} object for {@code Implementation-URL} * manifest attribute. * * @deprecated Extension mechanism is no longer supported. */ @Deprecated ! public static final Name IMPLEMENTATION_URL = new Name("Implementation-URL"); /** * {@code Name} object for {@code Specification-Title} * manifest attribute used for package versioning. */ ! public static final Name SPECIFICATION_TITLE = new Name("Specification-Title"); /** * {@code Name} object for {@code Specification-Version} * manifest attribute used for package versioning. */ ! public static final Name SPECIFICATION_VERSION = new Name("Specification-Version"); /** * {@code Name} object for {@code Specification-Vendor} * manifest attribute used for package versioning. */ ! public static final Name SPECIFICATION_VENDOR = new Name("Specification-Vendor"); /** * {@code Name} object for {@code Multi-Release} * manifest attribute that indicates this is a multi-release JAR file. * * @since 9 */ ! public static final Name MULTI_RELEASE = new Name("Multi-Release"); private static void addName(Map<String, Name> names, Name name) { names.put(name.name, name); } static { var names = new HashMap<String, Name>(64); addName(names, MANIFEST_VERSION); addName(names, SIGNATURE_VERSION); addName(names, CONTENT_TYPE); addName(names, CLASS_PATH); --- 553,713 ---- * manifest attribute. This attribute indicates the version number * of the manifest standard to which a JAR file's manifest conforms. * @see <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest"> * Manifest and Signature Specification</a> */ ! public static final Name MANIFEST_VERSION; /** * {@code Name} object for {@code Signature-Version} * manifest attribute used when signing JAR files. * @see <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest"> * Manifest and Signature Specification</a> */ ! public static final Name SIGNATURE_VERSION; /** * {@code Name} object for {@code Content-Type} * manifest attribute. */ ! public static final Name CONTENT_TYPE; /** * {@code Name} object for {@code Class-Path} * manifest attribute. * @see <a href="{@docRoot}/../specs/jar/jar.html#class-path-attribute"> * JAR file specification</a> */ ! public static final Name CLASS_PATH; /** * {@code Name} object for {@code Main-Class} manifest * attribute used for launching applications packaged in JAR files. * The {@code Main-Class} attribute is used in conjunction * with the {@code -jar} command-line option of the * {@code java} application launcher. */ ! public static final Name MAIN_CLASS; /** * {@code Name} object for {@code Sealed} manifest attribute * used for sealing. * @see <a href="{@docRoot}/../specs/jar/jar.html#package-sealing"> * Package Sealing</a> */ ! public static final Name SEALED; /** * {@code Name} object for {@code Extension-List} manifest attribute * used for the extension mechanism that is no longer supported. */ ! public static final Name EXTENSION_LIST; /** * {@code Name} object for {@code Extension-Name} manifest attribute. * used for the extension mechanism that is no longer supported. */ ! public static final Name EXTENSION_NAME; /** * {@code Name} object for {@code Extension-Installation} manifest attribute. * * @deprecated Extension mechanism is no longer supported. */ @Deprecated ! public static final Name EXTENSION_INSTALLATION; /** * {@code Name} object for {@code Implementation-Title} * manifest attribute used for package versioning. */ ! public static final Name IMPLEMENTATION_TITLE; /** * {@code Name} object for {@code Implementation-Version} * manifest attribute used for package versioning. */ ! public static final Name IMPLEMENTATION_VERSION; /** * {@code Name} object for {@code Implementation-Vendor} * manifest attribute used for package versioning. */ ! public static final Name IMPLEMENTATION_VENDOR; /** * {@code Name} object for {@code Implementation-Vendor-Id} * manifest attribute. * * @deprecated Extension mechanism is no longer supported. */ @Deprecated ! public static final Name IMPLEMENTATION_VENDOR_ID; /** * {@code Name} object for {@code Implementation-URL} * manifest attribute. * * @deprecated Extension mechanism is no longer supported. */ @Deprecated ! public static final Name IMPLEMENTATION_URL; /** * {@code Name} object for {@code Specification-Title} * manifest attribute used for package versioning. */ ! public static final Name SPECIFICATION_TITLE; /** * {@code Name} object for {@code Specification-Version} * manifest attribute used for package versioning. */ ! public static final Name SPECIFICATION_VERSION; /** * {@code Name} object for {@code Specification-Vendor} * manifest attribute used for package versioning. */ ! public static final Name SPECIFICATION_VENDOR; /** * {@code Name} object for {@code Multi-Release} * manifest attribute that indicates this is a multi-release JAR file. * * @since 9 */ ! public static final Name MULTI_RELEASE; private static void addName(Map<String, Name> names, Name name) { names.put(name.name, name); } static { + + VM.initializeFromArchive(Attributes.Name.class); + + if (KNOWN_NAMES == null) { + MANIFEST_VERSION = new Name("Manifest-Version"); + SIGNATURE_VERSION = new Name("Signature-Version"); + CONTENT_TYPE = new Name("Content-Type"); + CLASS_PATH = new Name("Class-Path"); + MAIN_CLASS = new Name("Main-Class"); + SEALED = new Name("Sealed"); + EXTENSION_LIST = new Name("Extension-List"); + EXTENSION_NAME = new Name("Extension-Name"); + EXTENSION_INSTALLATION = new Name("Extension-Installation"); + IMPLEMENTATION_TITLE = new Name("Implementation-Title"); + IMPLEMENTATION_VERSION = new Name("Implementation-Version"); + IMPLEMENTATION_VENDOR = new Name("Implementation-Vendor"); + IMPLEMENTATION_VENDOR_ID = new Name("Implementation-Vendor-Id"); + IMPLEMENTATION_URL = new Name("Implementation-URL"); + SPECIFICATION_TITLE = new Name("Specification-Title"); + SPECIFICATION_VERSION = new Name("Specification-Version"); + SPECIFICATION_VENDOR = new Name("Specification-Vendor"); + MULTI_RELEASE = new Name("Multi-Release"); + var names = new HashMap<String, Name>(64); addName(names, MANIFEST_VERSION); addName(names, SIGNATURE_VERSION); addName(names, CONTENT_TYPE); addName(names, CLASS_PATH);
*** 721,729 **** addName(names, new Name("Import-Package")); addName(names, new Name("Name")); addName(names, new Name("SHA1-Digest")); addName(names, new Name("X-Compile-Source-JDK")); addName(names, new Name("X-Compile-Target-JDK")); ! KNOWN_NAMES = names; } } } --- 746,776 ---- addName(names, new Name("Import-Package")); addName(names, new Name("Name")); addName(names, new Name("SHA1-Digest")); addName(names, new Name("X-Compile-Source-JDK")); addName(names, new Name("X-Compile-Target-JDK")); ! KNOWN_NAMES = Map.copyOf(names); ! } else { ! // Even if KNOWN_NAMES was read from archive, we still need ! // to initialize the public constants ! MANIFEST_VERSION = KNOWN_NAMES.get("Manifest-Version"); ! SIGNATURE_VERSION = KNOWN_NAMES.get("Signature-Version"); ! CONTENT_TYPE = KNOWN_NAMES.get("Content-Type"); ! CLASS_PATH = KNOWN_NAMES.get("Class-Path"); ! MAIN_CLASS = KNOWN_NAMES.get("Main-Class"); ! SEALED = KNOWN_NAMES.get("Sealed"); ! EXTENSION_LIST = KNOWN_NAMES.get("Extension-List"); ! EXTENSION_NAME = KNOWN_NAMES.get("Extension-Name"); ! EXTENSION_INSTALLATION = KNOWN_NAMES.get("Extension-Installation"); ! IMPLEMENTATION_TITLE = KNOWN_NAMES.get("Implementation-Title"); ! IMPLEMENTATION_VERSION = KNOWN_NAMES.get("Implementation-Version"); ! IMPLEMENTATION_VENDOR = KNOWN_NAMES.get("Implementation-Vendor"); ! IMPLEMENTATION_VENDOR_ID = KNOWN_NAMES.get("Implementation-Vendor-Id"); ! IMPLEMENTATION_URL = KNOWN_NAMES.get("Implementation-URL"); ! SPECIFICATION_TITLE = KNOWN_NAMES.get("Specification-Title"); ! SPECIFICATION_VERSION = KNOWN_NAMES.get("Specification-Version"); ! SPECIFICATION_VENDOR = KNOWN_NAMES.get("Specification-Vendor"); ! MULTI_RELEASE = KNOWN_NAMES.get("Multi-Release"); ! } } } }
< prev index next >