Community
Participate
Working Groups
I don't know if these problems arise from a misunderstanding on my part, or if it's a problem with Eclipse. Everything that I have been able to find indicates that I'm on the right track. The code is at the end of the report. 1. I've implemented a Map, and I'm having problems with the #entrySet method. The message I get (from Eclipse) is: "Type mismatch: Cannot convert from Set<Map<K,V>.Entry<String, V> to Set<Map.Entry<String, V>>" (javac has no problem) 2. Javac 1.5.0-beta2 complains "GenericMap.java:7: test.GenericMap is not abstract and does not override abstract method putAll(java.util.Map<? extends java.lang.String,? extends V>) in java.util.Map public class GenericMap<V> implements Map<String, V> {" while Eclipse accepts the class. package test; import java.util.Collection; import java.util.Map; import java.util.Set; public class GenericMap<V> implements Map<String, V> { private Map<String, V> backingMap; public int size() { return 0; } public boolean isEmpty() { return false; } public boolean containsKey(Object key) { return false; } public boolean containsValue(Object value) { return false; } public V get(Object key) { return null; } public V put(String key, V value) { return null; } public V remove(Object key) { return null; } public void clear() { } public Set<String> keySet() { return null; } public Collection<V> values() { return null; } public void putAll(Map<String, ? extends V> t) { } public Set<Map.Entry<String, V>> entrySet() { return this.backingMap.entrySet(); } }
The line in #entrySet that causes the problem is "return this.backingMap.entrySet();"
Re: the first problem. If you define #entrySet() as: public Set<Entry<String, V>> entrySet() { return backingMap.entrySet(); } (ie/ you're not specifying Map.Entry, you're only saying Entry) Then your error message turns into: "Type mismatch: cannot convert from Set<Map<K,V>.Entry<String,V>> to Set<Map<String,V>.Entry<String,V>>"
*** Bug 73608 has been marked as a duplicate of this bug. ***
I was able to work around bug73608 using non-generic types and a cast. Not pretty, but ok for now.
There was a problem constructed binding for parameterized static member types, resulting in non comparable types being built. Fixed in latest, added regression tests: GenericTypeTest#test297 & test298.
Verified that problem 1 is fixed for 3.1 M2 with build I200409231635. I'll open a other bug for problem 2 (putAll overriding not warned) which is still not fixed.