RFR: 8301120: Cleanup utility classes java.util.Arrays and java.util.Collections [v2]
Stuart Marks
smarks at openjdk.org
Fri Jan 27 00:36:19 UTC 2023
On Wed, 25 Jan 2023 22:23:26 GMT, Tagir F. Valeev <tvaleev at openjdk.org> wrote:
>> 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
>
> Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:
>
> Revert cast removal
Overall looks good, no changes necessary, comments are just observations.
I'll come back and approve this when my CI build finishes.
src/java.base/share/classes/java/util/Collections.java line 1636:
> 1634: @SuppressWarnings({"unchecked"})
> 1635: UnmodifiableEntrySet(Set<? extends Map.Entry<? extends K, ? extends V>> s) {
> 1636: super((Set<Map.Entry<K, V>>)s);
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.
src/java.base/share/classes/java/util/Collections.java line 5428:
> 5426: return (o == this) ||
> 5427: (o instanceof ReverseComparator2<?> that &&
> 5428: cmp.equals(that.cmp));
Nice, using an instanceof pattern where we had missed it previously.
-------------
PR: https://git.openjdk.org/jdk/pull/12207
More information about the core-libs-dev
mailing list