--- a/src/java.base/share/classes/java/util/jar/Attributes.java Tue Mar 26 10:23:11 2019 +0100
+++ b/src/java.base/share/classes/java/util/jar/Attributes.java Mon Dec 03 16:25:27 2018 +0100
@@ -34,6 +34,8 @@
import java.util.Objects;
import java.util.Set;
+import jdk.internal.misc.VM;
+import jdk.internal.vm.annotation.Stable;
import sun.util.logging.PlatformLogger;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -454,7 +456,7 @@
/**
* Avoid allocation for common Names
*/
- private static final Map<String, Name> KNOWN_NAMES;
+ private static @Stable Map<String, Name> KNOWN_NAMES;
static final Name of(String name) {
Name n = KNOWN_NAMES.get(name);
@@ -541,7 +543,7 @@
* @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");
+ public static final Name MANIFEST_VERSION;
/**
* {@code Name} object for {@code Signature-Version}
@@ -549,13 +551,13 @@
* @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");
+ public static final Name SIGNATURE_VERSION;
/**
* {@code Name} object for {@code Content-Type}
* manifest attribute.
*/
- public static final Name CONTENT_TYPE = new Name("Content-Type");
+ public static final Name CONTENT_TYPE;
/**
* {@code Name} object for {@code Class-Path}
@@ -563,7 +565,7 @@
* @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");
+ public static final Name CLASS_PATH;
/**
* {@code Name} object for {@code Main-Class} manifest
@@ -572,7 +574,7 @@
* with the {@code -jar} command-line option of the
* {@code java} application launcher.
*/
- public static final Name MAIN_CLASS = new Name("Main-Class");
+ public static final Name MAIN_CLASS;
/**
* {@code Name} object for {@code Sealed} manifest attribute
@@ -580,19 +582,19 @@
* @see <a href="{@docRoot}/../specs/jar/jar.html#package-sealing">
* Package Sealing</a>
*/
- public static final Name SEALED = new Name("Sealed");
+ 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 = new Name("Extension-List");
+ 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 = new Name("Extension-Name");
+ public static final Name EXTENSION_NAME;
/**
* {@code Name} object for {@code Extension-Installation} manifest attribute.
@@ -600,25 +602,25 @@
* @deprecated Extension mechanism is no longer supported.
*/
@Deprecated
- public static final Name EXTENSION_INSTALLATION = new Name("Extension-Installation");
+ 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 = new Name("Implementation-Title");
+ 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 = new Name("Implementation-Version");
+ 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 = new Name("Implementation-Vendor");
+ public static final Name IMPLEMENTATION_VENDOR;
/**
* {@code Name} object for {@code Implementation-Vendor-Id}
@@ -627,7 +629,7 @@
* @deprecated Extension mechanism is no longer supported.
*/
@Deprecated
- public static final Name IMPLEMENTATION_VENDOR_ID = new Name("Implementation-Vendor-Id");
+ public static final Name IMPLEMENTATION_VENDOR_ID;
/**
* {@code Name} object for {@code Implementation-URL}
@@ -636,25 +638,25 @@
* @deprecated Extension mechanism is no longer supported.
*/
@Deprecated
- public static final Name IMPLEMENTATION_URL = new Name("Implementation-URL");
+ 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 = new Name("Specification-Title");
+ 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 = new Name("Specification-Version");
+ 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 = new Name("Specification-Vendor");
+ public static final Name SPECIFICATION_VENDOR;
/**
* {@code Name} object for {@code Multi-Release}
@@ -662,56 +664,91 @@
*
* @since 9
*/
- public static final Name MULTI_RELEASE = new Name("Multi-Release");
+ public static final 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);
- addName(names, MAIN_CLASS);
- addName(names, SEALED);
- addName(names, EXTENSION_LIST);
- addName(names, EXTENSION_NAME);
- addName(names, IMPLEMENTATION_TITLE);
- addName(names, IMPLEMENTATION_VERSION);
- addName(names, IMPLEMENTATION_VENDOR);
- addName(names, SPECIFICATION_TITLE);
- addName(names, SPECIFICATION_VERSION);
- addName(names, SPECIFICATION_VENDOR);
- addName(names, MULTI_RELEASE);
+
+ 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");
- // Common attributes used in MANIFEST.MF et.al; adding these has a
- // small footprint cost, but is likely to be quickly paid for by
- // reducing allocation when reading and parsing typical manifests
- addName(names, new Name("Add-Exports"));
- addName(names, new Name("Add-Opens"));
- addName(names, new Name("Ant-Version"));
- addName(names, new Name("Archiver-Version"));
- addName(names, new Name("Build-Jdk"));
- addName(names, new Name("Built-By"));
- addName(names, new Name("Bnd-LastModified"));
- addName(names, new Name("Bundle-Description"));
- addName(names, new Name("Bundle-DocURL"));
- addName(names, new Name("Bundle-License"));
- addName(names, new Name("Bundle-ManifestVersion"));
- addName(names, new Name("Bundle-Name"));
- addName(names, new Name("Bundle-Vendor"));
- addName(names, new Name("Bundle-Version"));
- addName(names, new Name("Bundle-SymbolicName"));
- addName(names, new Name("Created-By"));
- addName(names, new Name("Export-Package"));
- 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;
+ var names = new HashMap<String, Name>(64);
+ addName(names, MANIFEST_VERSION);
+ addName(names, SIGNATURE_VERSION);
+ addName(names, CONTENT_TYPE);
+ addName(names, CLASS_PATH);
+ addName(names, MAIN_CLASS);
+ addName(names, SEALED);
+ addName(names, EXTENSION_LIST);
+ addName(names, EXTENSION_NAME);
+ addName(names, IMPLEMENTATION_TITLE);
+ addName(names, IMPLEMENTATION_VERSION);
+ addName(names, IMPLEMENTATION_VENDOR);
+ addName(names, SPECIFICATION_TITLE);
+ addName(names, SPECIFICATION_VERSION);
+ addName(names, SPECIFICATION_VENDOR);
+ addName(names, MULTI_RELEASE);
+
+ // Common attributes used in MANIFEST.MF et.al; adding these has a
+ // small footprint cost, but is likely to be quickly paid for by
+ // reducing allocation when reading and parsing typical manifests
+
+ // JDK internal attributes
+ addName(names, new Name("Add-Exports"));
+ addName(names, new Name("Add-Opens"));
+ // LauncherHelper attributes
+ addName(names, new Name("Launcher-Agent-Class"));
+ addName(names, new Name("JavaFX-Application-Class"));
+ // jarsigner attributes
+ addName(names, new Name("Name"));
+ addName(names, new Name("Created-By"));
+ addName(names, new Name("SHA1-Digest"));
+ addName(names, new Name("SHA-256-Digest"));
+ 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");
+ }
}
}
}