Skip to content

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Sep 25, 2025

Update: JEP 502's successor is a draft for LazyConstants https://openjdk.org/jeps/8359894 with a much more aligned API.

We now use Java's StableValue to back our Lazy implementation. StableValue suggests an Optional orElse…(…) usage pattern and it is not primarily intended for lazifying value resolution, therefore we have to mimic StableValue.supplier(…).

An immediate benefit is that Java 25++ users will get concurrency guarding while our Lazy implementation uses a best effort non-locking approach for value resolution that may observe race conditions as we don't guarantee single Supplier access for the backing supplier object.

We're using Java's preview features through a multi-release jar keeping our Java 17 baseline but enabling Java 25 StableValue feature consumption. Using the 4.0.0-STABLE-VALUE-SNAPSHOT version requires enabling Java preview features during compilation and runtime.

<dependencies>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>4.0.0-STABLE-VALUE-SNAPSHOT</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>spring-snapshot</id>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

@mp911de mp911de added the type: enhancement A general enhancement label Sep 25, 2025
We now use Java's StableValue to back our Lazy implementation. StableValue suggests an Optional orElse…(…) usage pattern and it is not primarily intended for lazifying value resolution, therefore we have to mimic StableValue.supplier(…).
@mp911de mp911de added status: waiting-for-triage An issue we've not yet triaged for: team-attention An issue we need to discuss as a team to make progress labels Sep 25, 2025
@mp911de mp911de added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged for: team-attention An issue we need to discuss as a team to make progress type: enhancement A general enhancement labels Sep 29, 2025
@mp911de
Copy link
Member Author

mp911de commented Sep 29, 2025

Will be superseded by LazyConstant.

@mp911de mp911de closed this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant