On Wed, 25 Mar 2026 11:29:30 GMT, Per Minborg <[email protected]> wrote:

>> Implement JEP 531: Lazy Constants (Third Preview)
>> 
>> This PR replaces _draft_ https://github.com/openjdk/jdk/pull/29507
>
> Per Minborg has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains 42 additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into 
> implement-lazy-constants-third-prewiew-exceptions
>  - Improve tests. Add concurrent tests for Set
>  - Improve testing
>  - Update test/hotspot/jtreg/compiler/stable/LazyConstantsIrTest.java
>    
>    Co-authored-by: Manuel Hässig <[email protected]>
>  - Update test/hotspot/jtreg/compiler/stable/LazyConstantsIrTest.java
>    
>    Co-authored-by: Manuel Hässig <[email protected]>
>  - Improve IR test
>  - Strenghten contention tests
>  - Reduce dead reconing waits
>  - Improve testing with multi-threading
>  - Address additional docs comment
>  - ... and 32 more: https://git.openjdk.org/jdk/compare/99dfbae4...1f9c6c21

Some drive-by comments.

src/java.base/share/classes/java/util/LazyCollections.java line 607:

> 605:         // Holds all the token-to-throwable mappings
> 606:         static final Map<Integer, Class<? extends Throwable>> THROWABLES 
> = new ConcurrentHashMap<>();
> 607:         // Start from 1 (and not zero) to allow constant folding in the 
> `throable` `int` array.

Suggestion:

        // Start from 1 (and not zero) to allow constant folding in the 
`throwable` `int` array.

src/java.base/share/classes/java/util/LazyCollections.java line 637:

> 635:             // We are reading/modifying `nextToken` under synchronization
> 636:             final int token = nextToken++;
> 637:             if (token == 0) {

Wraps around to `Integer.MIN_VALUE`

Suggestion:

            if (token < 0) {

src/java.base/share/classes/java/util/LazyCollections.java line 639:

> 637:             if (token == 0) {
> 638:                 nextToken--;
> 639:                 throw new InternalError("More than 2^32-1 throwable 
> classes detected");

Signed integer range.

Suggestion:

                throw new InternalError("More than 2^31-1 throwable classes 
detected");

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

Changes requested by krk (Author).

PR Review: https://git.openjdk.org/jdk/pull/30194#pullrequestreview-4006048546
PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r2987663434
PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r2987682107
PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r2987692642

Reply via email to