This discussion is archived
5 Replies Latest reply: Jul 15, 2011 6:22 AM by 800268 RSS

Uncompilable source code - Erroneous tree type: <any>

800965 Newbie
Currently Being Moderated
Hi, I have an example class SlowMap taken from a book, unfortunatelly it doesn't compile and throws this exception:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
     at chapter17.SlowMap.entrySet(
     at java.util.AbstractMap.toString(
     at java.lang.String.valueOf(
     at chapter17.SlowMap.main(
Java Result: 1
This is the code:
import java.util.*;

public class SlowMap<K, V> extends AbstractMap<K, V> {
    private List<K> keys = new ArrayList<K>();
    private List<V> values = new ArrayList<V>();
    public V put(K key, V value) {
        V oldValue = get(key);
        if (!keys.contains(key)) {
        } else
            values.set(keys.indexOf(key), value);
        return oldValue;
    public V get(Object key) {
        if (!keys.contains(key))
            return null;
        return values.get(keys.indexOf(key));
    public Set<Map.Entry<K, V>> entrySet() {
        Set<Map.Entry<K, V>> set = new HashSet<Map.Entry<K, V>>();
        Iterator<K> ki = keys.iterator();
        Iterator<V> vi = values.iterator();
        while (ki.hasNext())
            // this line throws exception
            set.add(new Map.Entry<K, V>(,;
        return set;
    public static void main(String[] args) {
        SlowMap<String, String> m = new SlowMap<String, String>();
I don't understand the exception message, so I have no clue how to fix the code. Can anyone tell me what is wrong with this code?



  • Correct Answers - 10 points
  • Helpful Answers - 5 points