diff --git a/core/java/src/net/i2p/util/ObjectCounter.java b/core/java/src/net/i2p/util/ObjectCounter.java index 9e04cd20ea62e57f7c1d1b386e059afe94fd18e7..67f979cf3bd24adc74ad5b19c8f17cdc7a0d75cb 100644 --- a/core/java/src/net/i2p/util/ObjectCounter.java +++ b/core/java/src/net/i2p/util/ObjectCounter.java @@ -2,6 +2,7 @@ package net.i2p.util; import java.io.Serializable; import java.util.Set; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; @@ -45,8 +46,15 @@ public class ObjectCounter<K> implements Serializable { /** * @return set of objects with counts > 0 + * + * note that on Android ConcurrentMap.keySet() returns a Set instead of a + * keySetView. The workaround is to cast it to a map before returning the + * keySet on Android. */ public Set<K> objects() { + if (System.getProperty("java.vendor").toUpperCase().contains("ANDROID")){ + return ((Map< K, ?>)this.map).keySet(); + } return this.map.keySet(); }