Skip to content

8384062: Add a new method List::removeAtIndex to avoid overload confusion#31064

Open
minborg wants to merge 1 commit intoopenjdk:masterfrom
minborg:rfe-list-remove-at-index
Open

8384062: Add a new method List::removeAtIndex to avoid overload confusion#31064
minborg wants to merge 1 commit intoopenjdk:masterfrom
minborg:rfe-list-remove-at-index

Conversation

@minborg
Copy link
Copy Markdown
Contributor

@minborg minborg commented May 7, 2026

This PR proposes to add a new default method List::removeAtIndex.

There are two overloads of the method List::remove, and if the list is of type List<Integer>, the overload resolution could pick a surprising variant.

Hence, it is better to add a separate method that removes an element based on its index.

It is proposed that the E remove(int index) method is not @Deprecated. Instead, we add verbiage to promote the new method over the old one.



Progress

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

Issues

  • JDK-8384062: Add a new method List::removeAtIndex to avoid overload confusion (Enhancement - P4)
  • JDK-8384074: Add a new method List::removeAtIndex to avoid overload confusion (CSR)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31064

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented May 7, 2026

👋 Welcome back pminborg! 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
Copy Markdown

openjdk Bot commented May 7, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the core-libs core-libs-dev@openjdk.org label May 7, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 7, 2026

@minborg The following label will be automatically applied to this pull request:

  • core-libs

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

@minborg minborg force-pushed the rfe-list-remove-at-index branch from db6d6d4 to d5fa4ee Compare May 7, 2026 07:25
@minborg
Copy link
Copy Markdown
Contributor Author

minborg commented May 7, 2026

/csr

@openjdk openjdk Bot added the csr Pull request needs approved CSR before integration label May 7, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 7, 2026

@minborg has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@minborg please create a CSR request for issue JDK-8384062 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@minborg minborg marked this pull request as ready for review May 7, 2026 08:13
@openjdk openjdk Bot added the rfr Pull request is ready for review label May 7, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented May 7, 2026

Webrevs

@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented May 7, 2026

Mailing list message from Remi Forax on core-libs-dev:

Hello,
the problem with java.util.List (unlike say Runtime.Version or Optional#get) is that List is *both* used directly and implemented.

For users, it is clear that removeAtIndex() should be used.

For implementors of java.util.List, it is not clear how to guarantee that remove(index) and removeAtIndex() are always in sync,
especially because most of the named implementation of java.util.List can be inherited.

We do not want to be in a situation where remove(index) and removeAtIndex() have two different implementations.

So I think it's premature to create a PR until we discuss what can be done/should be done to solve that problem.

Should we changed the tooling (javac, IDEs?) so implementation drift are recognized and reported ?
Are there other solutions ?

regards,
Rémi

----- Original Message -----

From: "Per Minborg" <pminborg@openjdk.org>
To: "core-libs-dev" <core-libs-dev@openjdk.org>
Sent: Thursday, May 7, 2026 10:19:39 AM
Subject: RFR: 8384062: Add a new method List::removeAtIndex to avoid overload confusion

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

Labels

core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant