package freemarker.template;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

public class EmptyMap implements Map, Cloneable {
    public static final EmptyMap instance = new EmptyMap(); 
    
    public void clear() {
        throw new UnsupportedOperationException("This Map is read-only.");
    }
    
    public boolean containsKey(Object arg0) {
        return false;
    }
    
    public boolean containsValue(Object arg0) {
        return false;
    }
    
    public Set entrySet() {
        return Collections.EMPTY_SET;
    }
    
    public Object get(Object arg0) {
        return null;
    }
    
    public boolean isEmpty() {
        return true;
    }
    
    public Set keySet() {
        return Collections.EMPTY_SET;
    }
    
    public Object put(Object arg0, Object arg1) {
        throw new UnsupportedOperationException("This Map is read-only.");
    }
    
    public void putAll(Map arg0) {
        throw new UnsupportedOperationException("This Map is read-only.");
    }
    
    public Object remove(Object arg0) {
        throw new UnsupportedOperationException("This Map is read-only.");
    }
    
    public int size() {
        return 0;
    }
    
    public Collection values() {
        return Collections.EMPTY_LIST;
    }

}

@@ -127,16 +127,306 @@
 l.Set;%0A%0A
+/**%0A * Read-only empty map. %7B@link #remove(Object)%7D, %7B@link #clear()%7D and%0A * %7B@link #putAll(Map)%7D with an empty %7B@link Map%7D as parameter are supported%0A * operations (and do nothing) since FreeMarker 2.3.20. %0A * %0A * @deprecated Use %7B@link Collections#EMPTY_MAP%7D on J2SE 1.3 or later.   %0A */%0A
 public c
@@ -571,74 +571,16 @@
     
-throw new UnsupportedOperationException(%22This Map is read-only.%22);
+// no op
 %0A   
@@ -1194,32 +1194,199 @@
 All(Map arg0) %7B%0A
+        // Checking for arg0.isEmpty() wouldn't reflect precisely how putAll in%0A        // AbstractMap works. %0A        if (arg0.entrySet().iterator().hasNext()) %7B%0A    
         throw ne
@@ -1436,38 +1436,48 @@
 s read-only.%22);%0A
+    
     %7D%0A
+    %7D%0A
     %0A    public 
@@ -1517,73 +1517,19 @@
     
-throw new UnsupportedOperationException(%22This Map is read-only.%22)
+return null
 ;%0A  

Allow no-op modifying operations in EmptyMap where Collections.EMPTY_MAP allows it too. Adding some javadocs too.