JDK-8353787 : Increased number of SHA-384-Digest java.util.jar.Attributes$Name instances leading to higher memory footprint
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-04-05
  • Updated: 2025-04-28
  • Resolved: 2025-04-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 24 JDK 25
21.0.8-oracleFixed 24.0.2Fixed 25 b18Fixed
Related Reports
Causes :  
Relates :  
Description
When parsing the manifest file of a JAR file the JDK constructs a java.util.jar.Manifest instance. The Manifest instance consists of java.util.jar.Attributes instances which correspond to the attributes of the manfiest file. An Attributes instance is a name-value mapping and the name is represented by the Attributes$Name class. 

Several attribute names that appear in a manifest file are standard names and many of those names may be repeated. For example, when a JAR file is signed (using the jarsigner tool), the each entry in the JAR file will have a digest recorded in the manifest file as an attribute name:

Name: foo.txt
SHA-256-Digest: ...

Name: bar.txt
SHA-256-Digest: ...

Each of these "Name" and "SHA-256-Digest" attribute names thus translate to a Attributes$Name instance, when parsed. 

JAR file instances are typically cached by the internal implementation of the JDK and as a result the Manifest instance and the Attributes instance too are cached. Several releases back it was noticed that these Attributes instances can contribute to increased memory footprint of the runtime. In https://bugs.openjdk.org/browse/JDK-6805750 a performance improvement was implemented (RFR https://mail.openjdk.org/pipermail/core-libs-dev/2018-April/052697.html) to maintain an internal cache of some well-known attribtue names mapped to a single instance of Attributes$Name. That way, several occurences of "SHA-256-Digest" attribtue name would end up using a single instance of Attributes$Name for that name. This cache is maintained as a static field in java.util.jar.Attributes class.

Recently, in Java 19, the jarsigner tool was enhanced to use SHA-384 as the default digest algorithm instead of the previous SHA-256 algorithm. That was done in https://bugs.openjdk.org/browse/JDK-8283475. Since then, when jarsigner tool is used to sign the JAR, the manifest file generated in the signed JAR would now have:

Name: foo.txt
SHA-384-Digest: ...

Name: bar.txt
SHA-384-Digest: ...

The internal cache that's maintained in java.util.jar.Attributes doesn't know of this new attribute name so ends up creating separate instances of Attributes$Name for each occurence of the SHA-384-Digest attribute name.

A user reports in core-libs-dev that this now shows up as an increase in the memory footprint of the runtime https://mail.openjdk.org/pipermail/core-libs-dev/2025-April/142299.html.


Comments
Fix request [21u] I backport this for parity with 21.0.8-oracle. Low risk although in security area as it just adds an omitted part for new algorithm that is in place for the older ones already. Introduced in 19. Resolved copyright, clean anyways. SAP nightly testing passed.
19-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/1680 Date: 2025-04-18 09:26:42 +0000
18-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk24u/pull/187 Date: 2025-04-11 08:50:15 +0000
11-04-2025

Changeset: b64cdc28 Branch: master Author: Jaikiran Pai <jpai@openjdk.org> Date: 2025-04-08 00:35:33 +0000 URL: https://git.openjdk.org/jdk/commit/b64cdc28132c889ca8e21dc9534590ba2a778bcd
08-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24475 Date: 2025-04-07 06:34:11 +0000
07-04-2025

I've changed this to a P3 issue since this can show up as a noticeable increase in the memory usage of the application as compared to Java releases prior to 19.
07-04-2025

The proposal is to update the caching implementation in java.util.jar.Attributes to create just one instance of Attributes$Name for "SHA-384-Digest", just like it does for the "SHA-256-Digest".
05-04-2025