Skip to content

Conversation

@theRealAph
Copy link
Contributor

@theRealAph theRealAph commented Apr 28, 2025

Propose to finalize scoped values.
The only functional change is that the orElse() method no longer accepts a null argument.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)
  • Change requires CSR request JDK-8355023 to be approved

Issues

  • JDK-8355022: Implement JEP 506: Scoped Values (Enhancement - P4)
  • JDK-8355023: Implement JEP 506: Scoped Values (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24923/head:pull/24923
$ git checkout pull/24923

Update a local copy of the PR:
$ git checkout pull/24923
$ git pull https://git.openjdk.org/jdk.git pull/24923/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24923

View PR using the GUI difftool:
$ git pr show -t 24923

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24923.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 28, 2025

👋 Welcome back aph! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 28, 2025

@theRealAph This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8355022: Implement JEP 506: Scoped Values

Reviewed-by: liach, alanb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 16 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Apr 28, 2025

@theRealAph The following labels will be automatically applied to this pull request:

  • compiler
  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@liach
Copy link
Member

liach commented Apr 28, 2025

Nit: is the no-arg constructor of Snapshot supposed to be private instead?

@AlanBateman
Copy link
Contributor

AlanBateman commented Apr 28, 2025

@theRealAph There are test updates in the loom repo that will also need to be included in this PR. test/jdk/java/lang/ScopedValue/ScopedValueAPI.java at least.

@theRealAph theRealAph changed the title Implement JEP 506: Scoped Values 8355720: Implement JEP 506: Scoped Values Apr 29, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 29, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 29, 2025

Webrevs

@theRealAph theRealAph changed the title 8355720: Implement JEP 506: Scoped Values 8355022: Implement JEP 506: Scoped Values Apr 29, 2025
@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Apr 29, 2025
* @throws StructureViolationException if a structure violation is detected
* @throws X if {@code op} completes with an exception
* @since 23
* @since 25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @since on the method be dropped once Carrier is bumped to 25.

@AlanBateman
Copy link
Contributor

@theRealAph Can you include the update to javax/security/auth/Subject.java as part of this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurred to me that ScopedValue.NEW_THREAD_BINDINGS can be made package‑private and used in Thread, removing duplication in Thread.NEW_THREAD_BINDINGS.


This was done this way back when ScopedValue lived under the jdk.incubator.* package tree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better not change that in this PR, as this PR is about making the feature permanent.

@openjdk
Copy link

openjdk bot commented May 2, 2025

@theRealAph this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8355022
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added merge-conflict Pull request has merge conflict with target branch and removed rfr Pull request is ready for review labels May 2, 2025
@theRealAph
Copy link
Contributor Author

@theRealAph Can you include the update to javax/security/auth/Subject.java as part of this?

Fixed now.

* @return the value of the scoped value if bound, otherwise {@code other}
*/
public T orElse(T other) {
Objects.requireNonNull(other);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the NPE be specified in the Javadoc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the class specification, right above the API notes:

 * <p> Unless otherwise specified, passing a {@code null} argument to a method in this
 * class will cause a {@link NullPointerException} to be thrown.

@liach
Copy link
Member

liach commented May 8, 2025

I noted that ThreadFlock is using scoped values but throwing StructureViolationException introduced by structured concurrency - is it considered an implementation artifact and part of structured concurrency instead?

Context: test/jdk/jdk/internal/misc/ThreadFlock/WithScopedValue.java

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the Javadoc and specification updates and @enablePreview removals for the end of preview. These are all related tests that can have the directive removed, aside from the thread flock test I asked about.

@liach
Copy link
Member

liach commented May 8, 2025

/reviewers 2 reviewer

@openjdk
Copy link

openjdk bot commented May 8, 2025

@liach
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@AlanBateman
Copy link
Contributor

I noted that ThreadFlock is using scoped values but throwing StructureViolationException introduced by structured concurrency - is it considered an implementation artifact and part of structured concurrency instead?

ThreadFlock supports the inheritance of scoped values into structured concurrency contexts. No changes in this PR to that construct.

@AlanBateman
Copy link
Contributor

@theRealAph One other test that will need attention is runtime/ClassFile/ClassFileVersionTest.java.

@liach
Copy link
Member

liach commented May 8, 2025

May I provide a quick patch to use an alternative mechanism to test preview class file versions for that class instead of changing that in this PR?

I have created #25128 addressing this issue.

@AlanBateman
Copy link
Contributor

May I provide a quick patch to use an alternative mechanism to test preview class file versions for that class instead of changing that in this PR?

That would be good as it shouldn't depend on ScopedValue being a preview API class.

@theRealAph
Copy link
Contributor Author

I noted that ThreadFlock is using scoped values but throwing StructureViolationException introduced by structured concurrency - is it considered an implementation artifact and part of structured concurrency instead?

Context: test/jdk/jdk/internal/misc/ThreadFlock/WithScopedValue.java

That's an interesting question that I'll leave to @AlanBateman .

@AlanBateman
Copy link
Contributor

I'm getting a test failure in ClassFileVersionTest.java because ScopedValue is not a Preview API. Should I just fix the test to use some other Preview Class?

Chen offered to change this test to use the ClassFile API and construct the class with the preview minor number. The PR to change this test is reviewed so I think all good, nothing more to do here.

@AlanBateman
Copy link
Contributor

That's an interesting question that I'll leave to @AlanBateman .

Nothing to do as the test uses StructureViolationException so needs to continue to be compile/run with preview features enabled.

@AlanBateman
Copy link
Contributor

I ran tier1-6 so I think we are good and there isn't anything left to bring over from the loom repo. There are a few files that will need their copyright header updated before integration. The CSR also needs to be finalized.

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 15, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label May 22, 2025
Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest master merge looks good.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label May 22, 2025
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSR is approved, I think this update is ready to integrate.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 23, 2025
@theRealAph
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented May 28, 2025

Going to push as commit 4e1878c.
Since your change was applied there have been 89 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 28, 2025
@openjdk openjdk bot closed this May 28, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 28, 2025
@openjdk
Copy link

openjdk bot commented May 28, 2025

@theRealAph Pushed as commit 4e1878c.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants