Skip to content

Conversation

@minborg
Copy link
Contributor

@minborg minborg commented May 2, 2025

This PR proposes to address comments in the initial PR for Stable Values, which were deferred until after integration.

Most of the efforts in this PR are to retain "stability" as long as possible so that views of stable collections remain stable and do not evaluate on toString() for example.

Unfortunately, this PR shows the total commit history for stable values.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change requires CSR request JDK-8356081 to be approved
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issues

  • JDK-8356080: Address post-integration comments for Stable Values (Bug - P4)
  • JDK-8356081: Address post-integration comments for Stable Values (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25004

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label May 5, 2025
@minborg minborg marked this pull request as ready for review May 6, 2025 08:59
@openjdk openjdk bot added the rfr Pull request is ready for review label May 6, 2025
@mlbridge
Copy link

mlbridge bot commented May 6, 2025

Webrevs

Copy link
Contributor

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

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

StableAPI javadoc changes look good!

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.

Looks good, some bikeshedding

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.

lgtm!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 12, 2025
@lukellmann
Copy link

I noticed that this code will throw NoSuchElementException instead of IndexOutOfBoundsException and will swallow the message because of the try/catch in ImmutableCollections.ListItr.next/previous:

StableValue
    .list(42, _ -> {throw new IndexOutOfBoundsException("important message");})
    .listIterator(5)
    .next(); // same for previous()

@lukellmann
Copy link

Do you plan to implement this suggestion: #23972 (comment)?

@minborg
Copy link
Contributor Author

minborg commented May 13, 2025

I noticed that this code will throw NoSuchElementException instead of IndexOutOfBoundsException and will swallow the message because of the try/catch in ImmutableCollections.ListItr.next/previous:

StableValue
    .list(42, _ -> {throw new IndexOutOfBoundsException("important message");})
    .listIterator(5)
    .next(); // same for previous()

We will take a look at this under a separate issue: https://bugs.openjdk.org/browse/JDK-8356842

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 13, 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 change set looks fine.

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

minborg commented May 13, 2025

/integrate

Thank you all reviewers for reviewing this PR!

@openjdk
Copy link

openjdk bot commented May 13, 2025

Going to push as commit 066477d.
Since your change was applied there have been 36 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 13, 2025
@openjdk openjdk bot closed this May 13, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 13, 2025
@openjdk
Copy link

openjdk bot commented May 13, 2025

@minborg Pushed as commit 066477d.

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

return o instanceof Map.Entry<?, ?> e
&& Objects.equals(getKey(), e.getKey())
// Invoke `getValue()` as late as possible to avoid evaluation
&& Objects.equals(getValue(), e.getValue());

Choose a reason for hiding this comment

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

Suggested change
&& Objects.equals(getValue(), e.getValue());
&& Objects.equals(e.getValue(), getValue());

You already integrated and it's probably not that important, but this would additionally avoid evaluation if e.getValue() throws.

Copy link
Member

Choose a reason for hiding this comment

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

This is in the realms of microoptimization now...

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

Labels

core-libs [email protected] integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

7 participants