-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
5.0
-
generic, x86
-
solaris_8, windows_xp
The new rewrite rules invalidate the following snippet of code from ConcurrentHashMap.java.
public void putAll(Map<? extends K, ? extends V> t) {
Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
while (it.hasNext()) {
Entry<? extends K, ? extends V> e = it.next();
put(e.getKey(), e.getValue());
}
}
==========$ cat T.java
import java.util.*;
class Main<K, V> {
public void main(Map<? extends K, ? extends V> t) {
Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
}
}
==========$ newjavac T.java
+ exec /usr/java1.5/bin/javac -J-esa -source 1.5 -target 1.4 T.java
T.java:5: incompatible types
found : ? extends java.util.Iterator<? extends java.util.Map.Entry<? extends K,? extends V>>
required: java.util.Iterator<java.util.Map.Entry<? extends K,? extends V>>
Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
^
1 error
==========$
public void putAll(Map<? extends K, ? extends V> t) {
Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
while (it.hasNext()) {
Entry<? extends K, ? extends V> e = it.next();
put(e.getKey(), e.getValue());
}
}
==========$ cat T.java
import java.util.*;
class Main<K, V> {
public void main(Map<? extends K, ? extends V> t) {
Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
}
}
==========$ newjavac T.java
+ exec /usr/java1.5/bin/javac -J-esa -source 1.5 -target 1.4 T.java
T.java:5: incompatible types
found : ? extends java.util.Iterator<? extends java.util.Map.Entry<? extends K,? extends V>>
required: java.util.Iterator<java.util.Map.Entry<? extends K,? extends V>>
Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
^
1 error
==========$
- duplicates
-
JDK-5046169 REGRESSION:Casting the result of Collections.singleton doesn't work
-
- Closed
-