CrackMe.apk
Download file
package com.google.common.collect;
import com.google.common.base.Preconditions;
import com.google.common.collect.Multiset;
import com.google.common.collect.Serialization;
import com.google.common.primitives.Ints;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
public final class ConcurrentHashMultiset<E> extends AbstractMultiset<E> implements Serializable {
private static final long serialVersionUID = 1;
/* access modifiers changed from: private */
public final transient ConcurrentMap<E, AtomicInteger> countMap;
public /* bridge */ /* synthetic */ boolean contains(@CheckForNull Object obj) {
return super.contains(obj);
}
public /* bridge */ /* synthetic */ Set elementSet() {
return super.elementSet();
}
public /* bridge */ /* synthetic */ Set entrySet() {
return super.entrySet();
}
private static class FieldSettersHolder {
static final Serialization.FieldSetter<ConcurrentHashMultiset> COUNT_MAP_FIELD_SETTER = Serialization.getFieldSetter(ConcurrentHashMultiset.class, "countMap");
private FieldSettersHolder() {
}
}
public static <E> ConcurrentHashMultiset<E> create() {
return new ConcurrentHashMultiset<>(new ConcurrentHashMap());
}
public static <E> ConcurrentHashMultiset<E> create(Iterable<? extends E> iterable) {
ConcurrentHashMultiset<E> create = create();
Iterables.addAll(create, iterable);
return create;
}
public static <E> ConcurrentHashMultiset<E> create(ConcurrentMap<E, AtomicInteger> concurrentMap) {
return new ConcurrentHashMultiset<>(concurrentMap);
}
ConcurrentHashMultiset(ConcurrentMap<E, AtomicInteger> concurrentMap) {
Preconditions.checkArgument(concurrentMap.isEmpty(), "the backing map (%s) must be empty", (Object) concurrentMap);
this.countMap = concurrentMap;
}
public int count(@CheckForNull Object obj) {
AtomicInteger atomicInteger = (AtomicInteger) Maps.safeGet(this.countMap, obj);
if (atomicInteger == null) {
return 0;
}
return atomicInteger.get();
}
public int size() {
long j = 0;
for (AtomicInteger atomicInteger : this.countMap.values()) {
j += (long) atomicInteger.get();
}
return Ints.saturatedCast(j);
}
public Object[] toArray() {
return snapshot().toArray();
}
public <T> T[] toArray(T[] tArr) {
return snapshot().toArray(tArr);
}
private List<E> snapshot() {
ArrayList newArrayListWithExpectedSize = Lists.newArrayListWithExpectedSize(size());
for (Multiset.Entry entry : entrySet()) {
Object element = entry.getElement();
for (int count = entry.getCount(); count > 0; count--) {
newArrayListWithExpectedSize.add(element);
}
}
return newArrayListWithExpectedSize;
}
/* JADX WARNING: Code restructure failed: missing block: B:19:0x005c, code lost:
r2 = new java.util.concurrent.atomic.AtomicInteger(r6);
*/
/* JADX WARNING: Code restructure failed: missing block: B:20:0x0067, code lost:
if (r4.countMap.putIfAbsent(r5, r2) == null) goto L_0x0071;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
public int add(E r5, int r6) {
/*
r4 = this;
com.google.common.base.Preconditions.checkNotNull(r5)
if (r6 != 0) goto L_0x000a
int r5 = r4.count(r5)
return r5
L_0x000a:
java.lang.String r0 = "occurrences"
com.google.common.collect.CollectPreconditions.checkPositive(r6, r0)
L_0x000f:
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r0 = r4.countMap
java.lang.Object r0 = com.google.common.collect.Maps.safeGet(r0, r5)
java.util.concurrent.atomic.AtomicInteger r0 = (java.util.concurrent.atomic.AtomicInteger) r0
r1 = 0
if (r0 != 0) goto L_0x002a
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r0 = r4.countMap
java.util.concurrent.atomic.AtomicInteger r2 = new java.util.concurrent.atomic.AtomicInteger
r2.<init>(r6)
java.lang.Object r0 = r0.putIfAbsent(r5, r2)
java.util.concurrent.atomic.AtomicInteger r0 = (java.util.concurrent.atomic.AtomicInteger) r0
if (r0 != 0) goto L_0x002a
return r1
L_0x002a:
int r2 = r0.get()
if (r2 == 0) goto L_0x005c
int r3 = com.google.common.math.IntMath.checkedAdd(r2, r6) // Catch:{ ArithmeticException -> 0x003b }
boolean r3 = r0.compareAndSet(r2, r3) // Catch:{ ArithmeticException -> 0x003b }
if (r3 == 0) goto L_0x002a
return r2
L_0x003b:
java.lang.IllegalArgumentException r5 = new java.lang.IllegalArgumentException
r0 = 65
java.lang.StringBuilder r1 = new java.lang.StringBuilder
r1.<init>(r0)
java.lang.String r0 = "Overflow adding "
r1.append(r0)
r1.append(r6)
java.lang.String r6 = " occurrences to a count of "
r1.append(r6)
r1.append(r2)
java.lang.String r6 = r1.toString()
r5.<init>(r6)
throw r5
L_0x005c:
java.util.concurrent.atomic.AtomicInteger r2 = new java.util.concurrent.atomic.AtomicInteger
r2.<init>(r6)
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r3 = r4.countMap
java.lang.Object r3 = r3.putIfAbsent(r5, r2)
if (r3 == 0) goto L_0x0071
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r3 = r4.countMap
boolean r0 = r3.replace(r5, r0, r2)
if (r0 == 0) goto L_0x000f
L_0x0071:
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.common.collect.ConcurrentHashMultiset.add(java.lang.Object, int):int");
}
public int remove(@CheckForNull Object obj, int i) {
int i2;
int max;
if (i == 0) {
return count(obj);
}
CollectPreconditions.checkPositive(i, "occurrences");
AtomicInteger atomicInteger = (AtomicInteger) Maps.safeGet(this.countMap, obj);
if (atomicInteger == null) {
return 0;
}
do {
i2 = atomicInteger.get();
if (i2 == 0) {
return 0;
}
max = Math.max(0, i2 - i);
} while (!atomicInteger.compareAndSet(i2, max));
if (max == 0) {
this.countMap.remove(obj, atomicInteger);
}
return i2;
}
public boolean removeExactly(@CheckForNull Object obj, int i) {
int i2;
int i3;
if (i == 0) {
return true;
}
CollectPreconditions.checkPositive(i, "occurrences");
AtomicInteger atomicInteger = (AtomicInteger) Maps.safeGet(this.countMap, obj);
if (atomicInteger == null) {
return false;
}
do {
i2 = atomicInteger.get();
if (i2 < i) {
return false;
}
i3 = i2 - i;
} while (!atomicInteger.compareAndSet(i2, i3));
if (i3 == 0) {
this.countMap.remove(obj, atomicInteger);
}
return true;
}
/* JADX WARNING: Code restructure failed: missing block: B:10:0x002c, code lost:
if (r6 != 0) goto L_0x002f;
*/
/* JADX WARNING: Code restructure failed: missing block: B:11:0x002e, code lost:
return 0;
*/
/* JADX WARNING: Code restructure failed: missing block: B:12:0x002f, code lost:
r2 = new java.util.concurrent.atomic.AtomicInteger(r6);
*/
/* JADX WARNING: Code restructure failed: missing block: B:13:0x003a, code lost:
if (r4.countMap.putIfAbsent(r5, r2) == null) goto L_0x0044;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
public int setCount(E r5, int r6) {
/*
r4 = this;
com.google.common.base.Preconditions.checkNotNull(r5)
java.lang.String r0 = "count"
com.google.common.collect.CollectPreconditions.checkNonnegative((int) r6, (java.lang.String) r0)
L_0x0008:
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r0 = r4.countMap
java.lang.Object r0 = com.google.common.collect.Maps.safeGet(r0, r5)
java.util.concurrent.atomic.AtomicInteger r0 = (java.util.concurrent.atomic.AtomicInteger) r0
r1 = 0
if (r0 != 0) goto L_0x0026
if (r6 != 0) goto L_0x0016
return r1
L_0x0016:
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r0 = r4.countMap
java.util.concurrent.atomic.AtomicInteger r2 = new java.util.concurrent.atomic.AtomicInteger
r2.<init>(r6)
java.lang.Object r0 = r0.putIfAbsent(r5, r2)
java.util.concurrent.atomic.AtomicInteger r0 = (java.util.concurrent.atomic.AtomicInteger) r0
if (r0 != 0) goto L_0x0026
return r1
L_0x0026:
int r2 = r0.get()
if (r2 != 0) goto L_0x0045
if (r6 != 0) goto L_0x002f
return r1
L_0x002f:
java.util.concurrent.atomic.AtomicInteger r2 = new java.util.concurrent.atomic.AtomicInteger
r2.<init>(r6)
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r3 = r4.countMap
java.lang.Object r3 = r3.putIfAbsent(r5, r2)
if (r3 == 0) goto L_0x0044
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r3 = r4.countMap
boolean r0 = r3.replace(r5, r0, r2)
if (r0 == 0) goto L_0x0008
L_0x0044:
return r1
L_0x0045:
boolean r3 = r0.compareAndSet(r2, r6)
if (r3 == 0) goto L_0x0026
if (r6 != 0) goto L_0x0052
java.util.concurrent.ConcurrentMap<E, java.util.concurrent.atomic.AtomicInteger> r6 = r4.countMap
r6.remove(r5, r0)
L_0x0052:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.common.collect.ConcurrentHashMultiset.setCount(java.lang.Object, int):int");
}
public boolean setCount(E e, int i, int i2) {
Preconditions.checkNotNull(e);
CollectPreconditions.checkNonnegative(i, "oldCount");
CollectPreconditions.checkNonnegative(i2, "newCount");
AtomicInteger atomicInteger = (AtomicInteger) Maps.safeGet(this.countMap, e);
if (atomicInteger != null) {
int i3 = atomicInteger.get();
if (i3 == i) {
if (i3 == 0) {
if (i2 == 0) {
this.countMap.remove(e, atomicInteger);
return true;
}
AtomicInteger atomicInteger2 = new AtomicInteger(i2);
if (this.countMap.putIfAbsent(e, atomicInteger2) == null || this.countMap.replace(e, atomicInteger, atomicInteger2)) {
return true;
}
return false;
} else if (atomicInteger.compareAndSet(i3, i2)) {
if (i2 == 0) {
this.countMap.remove(e, atomicInteger);
}
return true;
}
}
return false;
} else if (i != 0) {
return false;
} else {
if (i2 == 0 || this.countMap.putIfAbsent(e, new AtomicInteger(i2)) == null) {
return true;
}
return false;
}
}
/* access modifiers changed from: package-private */
public Set<E> createElementSet() {
final Set keySet = this.countMap.keySet();
return new ForwardingSet<E>(this) {
/* access modifiers changed from: protected */
public Set<E> delegate() {
return keySet;
}
public boolean contains(@CheckForNull Object obj) {
return obj != null && Collections2.safeContains(keySet, obj);
}
public boolean containsAll(Collection<?> collection) {
return standardContainsAll(collection);
}
public boolean remove(@CheckForNull Object obj) {
return obj != null && Collections2.safeRemove(keySet, obj);
}
public boolean removeAll(Collection<?> collection) {
return standardRemoveAll(collection);
}
};
}
/* access modifiers changed from: package-private */
public Iterator<E> elementIterator() {
throw new AssertionError("should never be called");
}
@Deprecated
public Set<Multiset.Entry<E>> createEntrySet() {
return new EntrySet();
}
/* access modifiers changed from: package-private */
public int distinctElements() {
return this.countMap.size();
}
public boolean isEmpty() {
return this.countMap.isEmpty();
}
/* access modifiers changed from: package-private */
public Iterator<Multiset.Entry<E>> entryIterator() {
final AnonymousClass2 r0 = new AbstractIterator<Multiset.Entry<E>>() {
private final Iterator<Map.Entry<E, AtomicInteger>> mapEntries;
{
this.mapEntries = ConcurrentHashMultiset.this.countMap.entrySet().iterator();
}
/* access modifiers changed from: protected */
@CheckForNull
public Multiset.Entry<E> computeNext() {
while (this.mapEntries.hasNext()) {
Map.Entry next = this.mapEntries.next();
int i = ((AtomicInteger) next.getValue()).get();
if (i != 0) {
return Multisets.immutableEntry(next.getKey(), i);
}
}
return (Multiset.Entry) endOfData();
}
};
return new ForwardingIterator<Multiset.Entry<E>>() {
@CheckForNull
private Multiset.Entry<E> last;
/* access modifiers changed from: protected */
public Iterator<Multiset.Entry<E>> delegate() {
return r0;
}
public Multiset.Entry<E> next() {
Multiset.Entry<E> entry = (Multiset.Entry) super.next();
this.last = entry;
return entry;
}
public void remove() {
Preconditions.checkState(this.last != null, "no calls to next() since the last call to remove()");
ConcurrentHashMultiset.this.setCount(this.last.getElement(), 0);
this.last = null;
}
};
}
public Iterator<E> iterator() {
return Multisets.iteratorImpl(this);
}
public void clear() {
this.countMap.clear();
}
private class EntrySet extends AbstractMultiset<E>.EntrySet {
private EntrySet() {
super();
}
/* access modifiers changed from: package-private */
public ConcurrentHashMultiset<E> multiset() {
return ConcurrentHashMultiset.this;
}
public Object[] toArray() {
return snapshot().toArray();
}
public <T> T[] toArray(T[] tArr) {
return snapshot().toArray(tArr);
}
private List<Multiset.Entry<E>> snapshot() {
ArrayList newArrayListWithExpectedSize = Lists.newArrayListWithExpectedSize(size());
Iterators.addAll(newArrayListWithExpectedSize, iterator());
return newArrayListWithExpectedSize;
}
}
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
objectOutputStream.defaultWriteObject();
objectOutputStream.writeObject(this.countMap);
}
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
objectInputStream.defaultReadObject();
FieldSettersHolder.COUNT_MAP_FIELD_SETTER.set(this, (Object) (ConcurrentMap) objectInputStream.readObject());
}
}
Download file