Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 18069)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 18070)
@@ -16,4 +16,5 @@
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URI;
@@ -69,6 +70,4 @@
 import org.openstreetmap.josm.spi.preferences.Config;
 
-import com.kitfox.svg.xml.XMLParseUtil;
-
 /**
  * Basic utils, that can be useful in different parts of the program.
@@ -98,4 +97,17 @@
     private static final double TO_DEGREES = 180.0 / Math.PI;
     private static final double TO_RADIANS = Math.PI / 180.0;
+
+    /**
+     * A reference to {@code Map.ofEntries()} available since Java 9
+     */
+    static final Method mapOfEntries = mapOfEntriesMethod();
+
+    private static Method mapOfEntriesMethod() {
+        try {
+            return Map.class.getMethod("ofEntries", Map.Entry[].class);
+        } catch (NoSuchMethodException e) {
+            return null;
+        }
+    }
 
     private Utils() {
@@ -659,5 +671,18 @@
      */
     public static <K, V> Map<K, V> toUnmodifiableMap(Map<K, V> map) {
-        return XMLParseUtil.toUnmodifiableMap(map);
+        if (map == null || map.isEmpty()) {
+            return Collections.emptyMap();
+        } else if (map.size() == 1) {
+            final Map.Entry<K, V> entry = map.entrySet().iterator().next();
+            return Collections.singletonMap(entry.getKey(), entry.getValue());
+        } else if (mapOfEntries != null) {
+            try {
+                // Java 9: use Map.ofEntries(...)
+                return (Map<K, V>) mapOfEntries.invoke(null, new Object[]{map.entrySet().toArray(new Map.Entry[0])});
+            } catch (Exception ignore) {
+                Logging.trace(ignore);
+            }
+        }
+        return Collections.unmodifiableMap(map);
     }
 
