RFR: JDK-8292914: Introduce a system property that enables stable names for lambda classes

Strahinja Stanojevic duke at openjdk.org
Mon Sep 5 16:04:28 UTC 2022


This PR introduces a system property that creates stable names for the lambda classes in the JDK. Instead of using an atomic counter in the lambda name, we can use a 32-bit hash after `$$Lambda$`. Thus, the name becomes `lambdaCapturingClass$$Lambda$hashValue`.
Parameters used to create a stable part of the name (hash value) are a superset of the parameters used for lambda class archiving when the CDS dumping option is enabled. During the stable name creation process,
all the common parameters are in the same form as in the low-level implementation (C part of the code) of the archiving process.
We concatenate all of those parameters in one string `hashData`. We calculate the long hash value for `hashData` in the same manner as the `java.lang.StringUTF16#hashCode` does, and then we hash that value using `Long.toString(longHashValue, Character.MAX_RADIX)`. The desired length for this hash is equal to the length of the `Long.toString(Long.MAX_VALUE, Character.MAX_RADIX)`.
Sometimes, the calculated hash value is shorter than the desired length, so we pad it with the character `#` to hit it. Appending `#` only affects the hash length, but not its stability.

Link to the related issue: https://bugs.openjdk.org/browse/JDK-8292914

-------------

Commit messages:
 - Remove debug messages. Change hex address preffix for 32 bit arhictecture
 - Debug message to check architecture which gate is running on
 - Debug message to check on which architecture gate is running
 - Debug message to check on which architecture gate is running
 - Test fails on the JDK20 that is not released yet. Since local testing and debugging is not possible beacuse of this, debug message added in this commit
 - JDK-8292914: Introduce a system property that enables stable names for lambda classes

Changes: https://git.openjdk.org/jdk/pull/10024/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10024&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8292914
  Stats: 404 lines in 2 files changed: 402 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/10024.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/10024/head:pull/10024

PR: https://git.openjdk.org/jdk/pull/10024


More information about the core-libs-dev mailing list