RFR: 8292914: Drop the counter from lambda class names [v5]
David M. Lloyd
duke at openjdk.org
Thu Feb 16 18:51:29 UTC 2023
On Thu, 16 Feb 2023 14:06:54 GMT, David M. Lloyd <duke at openjdk.org> wrote:
>> The class generated for lambda proxies is now defined as a hidden class. This means that the counter, which was used to ensure a unique class name and avoid clashes, is now redundant. In addition to performing redundant work, this also impacts build reproducibility for native image generators which might already have a strategy to cope with hidden classes but cannot cope with indeterminate definition order for lambda proxy classes.
>>
>> This solves JDK-8292914 by making lambda proxy names always be stable without any configuration needed. This would also replace #10024.
>
> David M. Lloyd has updated the pull request incrementally with one additional commit since the last revision:
>
> Use `Instant.now()` for more precise timestamps.
>
> Using `currentTimeMillis` is imprecise enough that tests may sporadically fail if two lambda classes from the same lambda class are dumped within 1ms of one another. `Instant.now()` is much more precise and also sorts nicely.
I can't say for certain (since I don't have a Windows environment I can test on) but I believe that the timestamp resolution on Windows may be too low for the timestamp approach to work (at least by itself).
I guess next I'll try out the approach similar to the one suggested by @iklam. Though maybe instead of a `Map` I'll use a `ClassValue` to retain an `AtomicInteger` instance for the per-class counter.
-------------
PR: https://git.openjdk.org/jdk/pull/12579
More information about the core-libs-dev
mailing list