> 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
Strahinja Stanojevic has updated the pull request incrementally with one additional commit since the last revision: Add additional parameter to hashCode, because in Scala, lambda can be serializable without implementing Serializable interface ------------- Changes: - all: https://git.openjdk.org/jdk/pull/10024/files - new: https://git.openjdk.org/jdk/pull/10024/files/dd268934..6a8f9128 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=10024&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=10024&range=01-02 Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 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