Skip to content

Commit 5a1dcb1

Browse files
committed
Cleanup warnings in java.util.Collections.
2016-03-18 Andrew John Hughes <[email protected]> Cleanup warnings in java.util.Collections. * java/util/Collections.java: (EMPTY_SET): Suppress warnings generated by this legacy raw type. (EMPTY_LIST): Likewise. (EMPTY_MAP): Likewise. (compare(T, T, Comparator): Suppress warning generated by casting to Comparable. (binarySearch(List, Comparator)): Remove unneeded casts. (reverse(List)): Suppress warnings when casting to ListIterator<Object>. Cast is necessary as lists are modified. (reverseOrder(Comparator)): Return reverseOrder() rather than rcInstance. (reverseOrder()): Create appropriately typed ReverseComparator rather than using set instance. (rcInstance): Removed. (ReverseComparator.compare(T,T)): Suppress warnings from casting to Comparable<T>. (rotate(List,int)): Suppress warnings when casting to List<Object>. Cast is necessary to modify list. (shuffle(List,Random)): Likewise. (disjoint(Collection,Collection)): Remove unnecessary casting. (sort(List,Comparator)): Suppress warnings when casting the returned array. Arrays of a generic type can not be created. (swap(List,int,int)): Suppress warnings when casting list to List<Object>. This is necessary to use the set method. (entrySet().SynchronizedMapEntry): Type should not have its own type parameters which hide those of the map. (entrySet().SynchronizedSet.iterator()): Remove type parameters from SynchronizedMapEntry creation. (UnmodifiableList.list): Retain input type parameter so as to avoid casting. (UnmodifiableList.UnmodifiableList): Remove cast. (UnmodifiableList.li): Retain input type parameter so as to avoid casting. (UnmodifiableListIterator(ListIterator)): Likewise. (UnmodifiableMap(Map)): Suppress warnings from casting down to Map<K,V>. (UnmodifiableMap.entrySet()): Remove type parameters from UnmodifiableEntrySet creation. (UnmodifiableMap.UnmodifiableEntrySet): Remove type parameters and make instance-specific so we can use the UnmodifiableMap's type parameters. (UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableMapEntry): Likewise. (UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableMapEntry.e): Retain input type parameters so as to avoid casting. (UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableMapEntry.UnmodifiableMapEntry(Map.Entry)): Likewise. (UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableEntrySet(Set)): Likewise. (UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableIterator.next()): Remove type parameters from UnmodifiableMapEntry creation. (UnmodifiableMap.toArray()): Likewise and improve method structure. (UnmodifiableMap.toArray(S[])): Remove type parameters from UnmodifiableMapEntry and suppress warnings from casting array members. (UnmodifiableSortedMap.sm): Retain input type parameters so as to avoid casting. (UnmodifiableSortedMap.UnmodifiableSortedMap(SortedMap)): Remove cast. (CheckedList.addAll(int,Collection)): Replace iterator with for-each loop, removing the need for casting. (CheckedMap.entrySet()): Remove type parameters from CheckedEntrySet creation and klass argument. (CheckedMap.CheckedEntrySet): Don't create additional type parameters, use those of the containing map as a instance class, not a static class. (keyType): Type should be K to match enclosing CheckedMap. (valueType): Type should be V to match enclosing CheckedMap. (CheckedMap.CheckedEntrySet.CheckedEntrySet(Set,Class,Class)): Suppress warnings when casting Map.Entry class. (CheckedMap.CheckedEntrySet.iterator()): Make return type Map.Entry<K,V> and create corresponding CheckedIterator instance. (CheckedMap.CheckedEntrySet.CheckedIterator.next()): Likewise with Map.Entry instance. (CheckedMap.CheckedEntrySet.CheckedIterator.Map.Entry.getKey()): Make return type K. (CheckedMap.CheckedEntrySet.CheckedIterator.Map.Entry.getValue()): Make return type V. (CheckedMap.CheckedEntrySet.CheckedIterator.Map.Entry.setValue(Object)): Likewise. (CheckedMap.putAll(Map)): Use for-each loop instead of Iterator, avoiding casting.
1 parent e7c13ee commit 5a1dcb1

File tree

2 files changed

+178
-81
lines changed

2 files changed

+178
-81
lines changed

ChangeLog

+92
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,95 @@
1+
2016-03-18 Andrew John Hughes <[email protected]>
2+
3+
* java/util/Collections.java:
4+
(EMPTY_SET): Suppress warnings generated by this
5+
legacy raw type.
6+
(EMPTY_LIST): Likewise.
7+
(EMPTY_MAP): Likewise.
8+
(compare(T, T, Comparator): Suppress warning
9+
generated by casting to Comparable.
10+
(binarySearch(List, Comparator)): Remove unneeded
11+
casts.
12+
(reverse(List)): Suppress warnings when casting
13+
to ListIterator<Object>. Cast is necessary as
14+
lists are modified.
15+
(reverseOrder(Comparator)): Return reverseOrder()
16+
rather than rcInstance.
17+
(reverseOrder()): Create appropriately typed
18+
ReverseComparator rather than using set instance.
19+
(rcInstance): Removed.
20+
(ReverseComparator.compare(T,T)): Suppress warnings
21+
from casting to Comparable<T>.
22+
(rotate(List,int)): Suppress warnings when casting
23+
to List<Object>. Cast is necessary to modify list.
24+
(shuffle(List,Random)): Likewise.
25+
(disjoint(Collection,Collection)): Remove unnecessary
26+
casting.
27+
(sort(List,Comparator)): Suppress warnings when casting
28+
the returned array. Arrays of a generic type can not
29+
be created.
30+
(swap(List,int,int)): Suppress warnings when casting
31+
list to List<Object>. This is necessary to use the
32+
set method.
33+
(entrySet().SynchronizedMapEntry): Type should not have its
34+
own type parameters which hide those of the map.
35+
(entrySet().SynchronizedSet.iterator()): Remove type
36+
parameters from SynchronizedMapEntry creation.
37+
(UnmodifiableList.list): Retain input type parameter
38+
so as to avoid casting.
39+
(UnmodifiableList.UnmodifiableList): Remove cast.
40+
(UnmodifiableList.li): Retain input type parameter
41+
so as to avoid casting.
42+
(UnmodifiableListIterator(ListIterator)): Likewise.
43+
(UnmodifiableMap(Map)): Suppress warnings from casting
44+
down to Map<K,V>.
45+
(UnmodifiableMap.entrySet()): Remove type parameters
46+
from UnmodifiableEntrySet creation.
47+
(UnmodifiableMap.UnmodifiableEntrySet): Remove type
48+
parameters and make instance-specific so we can
49+
use the UnmodifiableMap's type parameters.
50+
(UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableMapEntry):
51+
Likewise.
52+
(UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableMapEntry.e):
53+
Retain input type parameters so as to avoid casting.
54+
(UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableMapEntry.UnmodifiableMapEntry(Map.Entry)):
55+
Likewise.
56+
(UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableEntrySet(Set)):
57+
Likewise.
58+
(UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableIterator.next()):
59+
Remove type parameters from UnmodifiableMapEntry creation.
60+
(UnmodifiableMap.toArray()): Likewise and improve method
61+
structure.
62+
(UnmodifiableMap.toArray(S[])): Remove type parameters from
63+
UnmodifiableMapEntry and suppress warnings from casting
64+
array members.
65+
(UnmodifiableSortedMap.sm): Retain input type parameters
66+
so as to avoid casting.
67+
(UnmodifiableSortedMap.UnmodifiableSortedMap(SortedMap)):
68+
Remove cast.
69+
(CheckedList.addAll(int,Collection)): Replace iterator with for-each
70+
loop, removing the need for casting.
71+
(CheckedMap.entrySet()): Remove type parameters from CheckedEntrySet
72+
creation and klass argument.
73+
(CheckedMap.CheckedEntrySet): Don't create additional
74+
type parameters, use those of the containing map as
75+
a instance class, not a static class.
76+
(keyType): Type should be K to match enclosing CheckedMap.
77+
(valueType): Type should be V to match enclosing CheckedMap.
78+
(CheckedMap.CheckedEntrySet.CheckedEntrySet(Set,Class,Class)):
79+
Suppress warnings when casting Map.Entry class.
80+
(CheckedMap.CheckedEntrySet.iterator()): Make return type
81+
Map.Entry<K,V> and create corresponding CheckedIterator instance.
82+
(CheckedMap.CheckedEntrySet.CheckedIterator.next()): Likewise
83+
with Map.Entry instance.
84+
(CheckedMap.CheckedEntrySet.CheckedIterator.Map.Entry.getKey()):
85+
Make return type K.
86+
(CheckedMap.CheckedEntrySet.CheckedIterator.Map.Entry.getValue()):
87+
Make return type V.
88+
(CheckedMap.CheckedEntrySet.CheckedIterator.Map.Entry.setValue(Object)):
89+
Likewise.
90+
(CheckedMap.putAll(Map)): Use for-each loop instead of Iterator,
91+
avoiding casting.
92+
193
2016-01-04 Andrew John Hughes <[email protected]>
294

395
Cleanup warnings in gnu.xml.transform.* and

0 commit comments

Comments
 (0)