static O collectionMutex(O o) { if (o instanceof L) ret o; S c = className(o); if (eq(c, "java.util.TreeMap$KeySet")) c = className(o = getOpt(o, 'm)); else if (eq(c, "java.util.HashMap$KeySet")) c = className(o = get_raw(o, 'this$0)); ifdef collectionMutex_debug print("Class name: " + className(o)); endifdef if (eqOneOf(c, "java.util.TreeMap$AscendingSubMap", "java.util.TreeMap$DescendingSubMap")) c = className(o = get_raw(o, 'm)); ifclass WeakHashSet if (o instanceof WeakHashSet) c = className(o = o/WeakHashSet.mutex()); endif ret o; }