Bug 80566 - 3.1M3 AbstractMethodError for generic Map
Summary: 3.1M3 AbstractMethodError for generic Map
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-08 22:33 EST by mike andrews CLA
Modified: 2004-12-09 07:33 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mike andrews CLA 2004-12-08 22:33:34 EST
have a map: "public class MyMap<KEY extends Serializable, VALUE extends
Serializable> implements Map<KEY, VALUE>"

and the remove(...) method looks like: "public synchronized VALUE remove(Object
key)"

when i do a getClass().getMethods[] on an instance of this object, i get TWO
remove methods, and one is erroneously abstract: 

1. public synchronized java.io.Serializable MyMap.remove(java.lang.Object)

2. public abstract java.lang.Object java.util.Map.remove(java.lang.Object)

and thus the method #2 causes an AbstractMethodError exception to be thrown when
i try to remove() keys from instances of this MyMap class.

note that other methods with similar generic signature patterns, like 'put',
don't have this problem for some odd reason.

short term workaround for me: getting rid of "extends Serializable" clauses in
generic class parameters fixes things. basically it gets rid of method #1, which
i guess causes less confusion to the compiler so that method #2 is not abstract
anymore. but getting rid of 'extends Serializable' defeats part of the benefit
of generics, so i eagerly await a fix! 

thanks,
Comment 1 Jerome Lanneluc CLA 2004-12-09 07:33:43 EST
Verified that the following class runs without an AbstractMethodError using HEAD:
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

public class X<KEY extends Serializable, VALUE extends Serializable> implements
Map<KEY, VALUE> {
	public void clear() {
	}
	public boolean containsKey(Object key) {
		return false;
	}
	public boolean containsValue(Object value) {
		return false;
	}
	public Set<Entry<KEY, VALUE>> entrySet() {
		return null;
	}
	public VALUE get(Object key) {
		return null;
	}
	public boolean isEmpty() {
		return false;
	}
	public Set<KEY> keySet() {
		return null;
	}
	public VALUE put(KEY key, VALUE value) {
		return null;
	}
	public void putAll(Map< ? extends KEY, ? extends VALUE> t) {
	}
	public synchronized VALUE remove(Object key) {
		return null;
	}
	public int size() {
		return 0;
	}
	public Collection<VALUE> values() {
		return null;
	}
	public static void main(String[] args) {
		new X().remove("key");
	}
}