Skip to content

8301120: Cleanup utility classes java.util.Arrays and java.util.Collections #12207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

amaembo
Copy link
Contributor

@amaembo amaembo commented Jan 25, 2023

number of minor cleanups could be done in Arrays and Collections utility classes.
In Arrays:

  • Redundant import jdk.internal.misc.Unsafe;
  • C-style array declaration is used in public static boolean equals(short[] a, short a2[]) (that's the only place in the whole file)

In Collections:

  • A few obsolete "unchecked" and "rawtypes" suppressions
  • Unnecessary local variable initializer in get() method
  • Raw type can be avoided in a number of casts
  • Explicit type parameters could be omitted or converted to diamonds
  • A couple of javadoc links on private APIs are malformed

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8301120: Cleanup utility classes java.util.Arrays and java.util.Collections

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12207

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 25, 2023

👋 Welcome back tvaleev! 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 openjdk bot added the rfr Pull request is ready for review label Jan 25, 2023
@openjdk
Copy link

openjdk bot commented Jan 25, 2023

@amaembo 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.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Jan 25, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 25, 2023

Webrevs

@@ -1067,7 +1065,7 @@ public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c
public String toString() {return c.toString();}

public Iterator<E> iterator() {
return new Iterator<E>() {
return new Iterator<>() {
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, this whole family of changes is now possible because the original version of diamond didn't allow it to be used in the context of an anonymous inner class, because of non-denotability of types or some such. That restriction has been relaxed, but we never went back to fix these up.

I also note think that Martin objected to this sort of change in java.util.concurrent, but I'm OK with it here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the improved version of diamond was
JDK-8062373: Project Coin: diamond and anonymous classes
as part of JEP 213.

UnmodifiableEntrySet(Set<? extends Map.Entry<? extends K, ? extends V>> s) {
// Need to cast to raw in order to work around a limitation in the type system
super((Set)s);
super((Set<Map.Entry<K, V>>)s);
Copy link
Member

Choose a reason for hiding this comment

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

Huh, good catch, there doesn't appear to be a "limitation in the type system" here, either currently or in older versions of javac going back to JDK 7.

(o instanceof ReverseComparator2 &&
cmp.equals(((ReverseComparator2)o).cmp));
(o instanceof ReverseComparator2<?> that &&
cmp.equals(that.cmp));
Copy link
Member

Choose a reason for hiding this comment

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

Nice, using an instanceof pattern where we had missed it previously.

Copy link
Member

@stuart-marks stuart-marks left a comment

Choose a reason for hiding this comment

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

Overall looks good, no changes necessary, comments are just observations.

I'll come back and approve this when my CI build finishes.

Copy link
Member

@stuart-marks stuart-marks left a comment

Choose a reason for hiding this comment

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

Test run looks good, ok to integrate.

@openjdk
Copy link

openjdk bot commented Jan 27, 2023

@amaembo 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:

8301120: Cleanup utility classes java.util.Arrays and java.util.Collections

Reviewed-by: smarks, darcy

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 46 new commits pushed to the master branch:

  • 22c976a: 8177418: NPE is not apparent for methods in java.util.TimeZone API docs
  • 7aaf76c: 8300924: Method::invoke throws wrong exception type when passing wrong number of arguments to method with 4 or more parameters
  • 49ff520: 8300241: Replace NULL with nullptr in share/classfile/
  • f52d35c: 8300240: Replace NULL with nullptr in share/ci/
  • 5c1ec82: 8301077: Replace NULL with nullptr in share/services/
  • dff4131: 8285850: [AIX] unreachable code in basic_tools.m4 -> BASIC_CHECK_TAR
  • e2a3b20: 8301187: Memory leaks in OopMapCache
  • fccf818: 8301123: Enable Symbol refcounting underflow checks in PRODUCT
  • e4252bb: 8300823: UB: Compile::_phase_optimize_finished is initialized too late
  • db8fa1b: 8300405: Screen capture for test JFileChooserSetLocationTest.java, failure case
  • ... and 36 more: https://git.openjdk.org/jdk/compare/adcfd257358fcd810f75d41bda7b916595e5dcdf...master

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 openjdk bot added the ready Pull request is ready to be integrated label Jan 27, 2023
@amaembo
Copy link
Contributor Author

amaembo commented Jan 27, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jan 27, 2023

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

  • b8e5abc: 8301097: Update GHA XCode to 12.5.1
  • 9c4bc2c: 8301132: Test update for deprecated sprintf in Xcode 14
  • 7f05d57: 8217920: Lookup.defineClass injects a class that can access private members of any class in its own module
  • 22c976a: 8177418: NPE is not apparent for methods in java.util.TimeZone API docs
  • 7aaf76c: 8300924: Method::invoke throws wrong exception type when passing wrong number of arguments to method with 4 or more parameters
  • 49ff520: 8300241: Replace NULL with nullptr in share/classfile/
  • f52d35c: 8300240: Replace NULL with nullptr in share/ci/
  • 5c1ec82: 8301077: Replace NULL with nullptr in share/services/
  • dff4131: 8285850: [AIX] unreachable code in basic_tools.m4 -> BASIC_CHECK_TAR
  • e2a3b20: 8301187: Memory leaks in OopMapCache
  • ... and 39 more: https://git.openjdk.org/jdk/compare/adcfd257358fcd810f75d41bda7b916595e5dcdf...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 27, 2023

@amaembo Pushed as commit ae0e76d.

💡 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
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants