CrackMe.apk
Download file
package com.google.common.util.concurrent;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.AbstractFuture;
import com.google.common.util.concurrent.CollectionFuture;
import com.google.common.util.concurrent.ImmediateFuture;
import com.google.common.util.concurrent.internal.InternalFutureFailureAccess;
import com.google.common.util.concurrent.internal.InternalFutures;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
public final class Futures extends GwtFuturesCatchingSpecialization {
private Futures() {
}
public static <V> ListenableFuture<V> immediateFuture(@ParametricNullness V v) {
if (v == null) {
return ImmediateFuture.NULL;
}
return new ImmediateFuture(v);
}
public static ListenableFuture<Void> immediateVoidFuture() {
return ImmediateFuture.NULL;
}
public static <V> ListenableFuture<V> immediateFailedFuture(Throwable th) {
Preconditions.checkNotNull(th);
return new ImmediateFuture.ImmediateFailedFuture(th);
}
public static <V> ListenableFuture<V> immediateCancelledFuture() {
return new ImmediateFuture.ImmediateCancelledFuture();
}
public static <O> ListenableFuture<O> submit(Callable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> create = TrustedListenableFutureTask.create(callable);
executor.execute(create);
return create;
}
public static ListenableFuture<Void> submit(Runnable runnable, Executor executor) {
TrustedListenableFutureTask create = TrustedListenableFutureTask.create(runnable, null);
executor.execute(create);
return create;
}
public static <O> ListenableFuture<O> submitAsync(AsyncCallable<O> asyncCallable, Executor executor) {
TrustedListenableFutureTask<O> create = TrustedListenableFutureTask.create(asyncCallable);
executor.execute(create);
return create;
}
public static <O> ListenableFuture<O> scheduleAsync(AsyncCallable<O> asyncCallable, long j, TimeUnit timeUnit, ScheduledExecutorService scheduledExecutorService) {
TrustedListenableFutureTask<O> create = TrustedListenableFutureTask.create(asyncCallable);
final ScheduledFuture<?> schedule = scheduledExecutorService.schedule(create, j, timeUnit);
create.addListener(new Runnable() {
public void run() {
schedule.cancel(false);
}
}, MoreExecutors.directExecutor());
return create;
}
public static <V, X extends Throwable> ListenableFuture<V> catching(ListenableFuture<? extends V> listenableFuture, Class<X> cls, Function<? super X, ? extends V> function, Executor executor) {
return AbstractCatchingFuture.create(listenableFuture, cls, function, executor);
}
public static <V, X extends Throwable> ListenableFuture<V> catchingAsync(ListenableFuture<? extends V> listenableFuture, Class<X> cls, AsyncFunction<? super X, ? extends V> asyncFunction, Executor executor) {
return AbstractCatchingFuture.create(listenableFuture, cls, asyncFunction, executor);
}
public static <V> ListenableFuture<V> withTimeout(ListenableFuture<V> listenableFuture, long j, TimeUnit timeUnit, ScheduledExecutorService scheduledExecutorService) {
if (listenableFuture.isDone()) {
return listenableFuture;
}
return TimeoutFuture.create(listenableFuture, j, timeUnit, scheduledExecutorService);
}
public static <I, O> ListenableFuture<O> transformAsync(ListenableFuture<I> listenableFuture, AsyncFunction<? super I, ? extends O> asyncFunction, Executor executor) {
return AbstractTransformFuture.create(listenableFuture, asyncFunction, executor);
}
public static <I, O> ListenableFuture<O> transform(ListenableFuture<I> listenableFuture, Function<? super I, ? extends O> function, Executor executor) {
return AbstractTransformFuture.create(listenableFuture, function, executor);
}
public static <I, O> Future<O> lazyTransform(final Future<I> future, final Function<? super I, ? extends O> function) {
Preconditions.checkNotNull(future);
Preconditions.checkNotNull(function);
return new Future<O>() {
public boolean cancel(boolean z) {
return future.cancel(z);
}
public boolean isCancelled() {
return future.isCancelled();
}
public boolean isDone() {
return future.isDone();
}
public O get() throws InterruptedException, ExecutionException {
return applyTransformation(future.get());
}
public O get(long j, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
return applyTransformation(future.get(j, timeUnit));
}
private O applyTransformation(I i) throws ExecutionException {
try {
return function.apply(i);
} catch (Throwable th) {
throw new ExecutionException(th);
}
}
};
}
@SafeVarargs
public static <V> ListenableFuture<List<V>> allAsList(ListenableFuture<? extends V>... listenableFutureArr) {
return new CollectionFuture.ListFuture(ImmutableList.copyOf((E[]) listenableFutureArr), true);
}
public static <V> ListenableFuture<List<V>> allAsList(Iterable<? extends ListenableFuture<? extends V>> iterable) {
return new CollectionFuture.ListFuture(ImmutableList.copyOf(iterable), true);
}
@SafeVarargs
public static <V> FutureCombiner<V> whenAllComplete(ListenableFuture<? extends V>... listenableFutureArr) {
return new FutureCombiner<>(false, ImmutableList.copyOf((E[]) listenableFutureArr));
}
public static <V> FutureCombiner<V> whenAllComplete(Iterable<? extends ListenableFuture<? extends V>> iterable) {
return new FutureCombiner<>(false, ImmutableList.copyOf(iterable));
}
@SafeVarargs
public static <V> FutureCombiner<V> whenAllSucceed(ListenableFuture<? extends V>... listenableFutureArr) {
return new FutureCombiner<>(true, ImmutableList.copyOf((E[]) listenableFutureArr));
}
public static <V> FutureCombiner<V> whenAllSucceed(Iterable<? extends ListenableFuture<? extends V>> iterable) {
return new FutureCombiner<>(true, ImmutableList.copyOf(iterable));
}
public static final class FutureCombiner<V> {
private final boolean allMustSucceed;
private final ImmutableList<ListenableFuture<? extends V>> futures;
private FutureCombiner(boolean z, ImmutableList<ListenableFuture<? extends V>> immutableList) {
this.allMustSucceed = z;
this.futures = immutableList;
}
public <C> ListenableFuture<C> callAsync(AsyncCallable<C> asyncCallable, Executor executor) {
return new CombinedFuture((ImmutableCollection<? extends ListenableFuture<?>>) this.futures, this.allMustSucceed, executor, asyncCallable);
}
public <C> ListenableFuture<C> call(Callable<C> callable, Executor executor) {
return new CombinedFuture((ImmutableCollection<? extends ListenableFuture<?>>) this.futures, this.allMustSucceed, executor, callable);
}
public ListenableFuture<?> run(final Runnable runnable, Executor executor) {
return call(new Callable<Void>(this) {
@CheckForNull
public Void call() throws Exception {
runnable.run();
return null;
}
}, executor);
}
}
public static <V> ListenableFuture<V> nonCancellationPropagating(ListenableFuture<V> listenableFuture) {
if (listenableFuture.isDone()) {
return listenableFuture;
}
NonCancellationPropagatingFuture nonCancellationPropagatingFuture = new NonCancellationPropagatingFuture(listenableFuture);
listenableFuture.addListener(nonCancellationPropagatingFuture, MoreExecutors.directExecutor());
return nonCancellationPropagatingFuture;
}
private static final class NonCancellationPropagatingFuture<V> extends AbstractFuture.TrustedFuture<V> implements Runnable {
@CheckForNull
private ListenableFuture<V> delegate;
NonCancellationPropagatingFuture(ListenableFuture<V> listenableFuture) {
this.delegate = listenableFuture;
}
public void run() {
ListenableFuture<V> listenableFuture = this.delegate;
if (listenableFuture != null) {
setFuture(listenableFuture);
}
}
/* access modifiers changed from: protected */
@CheckForNull
public String pendingToString() {
ListenableFuture<V> listenableFuture = this.delegate;
if (listenableFuture == null) {
return null;
}
String valueOf = String.valueOf(listenableFuture);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 11);
sb.append("delegate=[");
sb.append(valueOf);
sb.append("]");
return sb.toString();
}
/* access modifiers changed from: protected */
public void afterDone() {
this.delegate = null;
}
}
@SafeVarargs
public static <V> ListenableFuture<List<V>> successfulAsList(ListenableFuture<? extends V>... listenableFutureArr) {
return new CollectionFuture.ListFuture(ImmutableList.copyOf((E[]) listenableFutureArr), false);
}
public static <V> ListenableFuture<List<V>> successfulAsList(Iterable<? extends ListenableFuture<? extends V>> iterable) {
return new CollectionFuture.ListFuture(ImmutableList.copyOf(iterable), false);
}
public static <T> ImmutableList<ListenableFuture<T>> inCompletionOrder(Iterable<? extends ListenableFuture<? extends T>> iterable) {
ListenableFuture[] gwtCompatibleToArray = gwtCompatibleToArray(iterable);
final InCompletionOrderState inCompletionOrderState = new InCompletionOrderState(gwtCompatibleToArray);
ImmutableList.Builder builderWithExpectedSize = ImmutableList.builderWithExpectedSize(gwtCompatibleToArray.length);
for (int i = 0; i < gwtCompatibleToArray.length; i++) {
builderWithExpectedSize.add((Object) new InCompletionOrderFuture(inCompletionOrderState));
}
final ImmutableList<ListenableFuture<T>> build = builderWithExpectedSize.build();
for (final int i2 = 0; i2 < gwtCompatibleToArray.length; i2++) {
gwtCompatibleToArray[i2].addListener(new Runnable() {
public void run() {
InCompletionOrderState.this.recordInputCompletion(build, i2);
}
}, MoreExecutors.directExecutor());
}
return build;
}
/* JADX WARNING: type inference failed for: r1v0, types: [java.lang.Iterable<? extends com.google.common.util.concurrent.ListenableFuture<? extends T>>, java.lang.Iterable] */
/* JADX WARNING: Unknown variable types count: 1 */
/* Code decompiled incorrectly, please refer to instructions dump. */
private static <T> com.google.common.util.concurrent.ListenableFuture<? extends T>[] gwtCompatibleToArray(java.lang.Iterable<? extends com.google.common.util.concurrent.ListenableFuture<? extends T>> r1) {
/*
boolean r0 = r1 instanceof java.util.Collection
if (r0 == 0) goto L_0x0007
java.util.Collection r1 = (java.util.Collection) r1
goto L_0x000b
L_0x0007:
com.google.common.collect.ImmutableList r1 = com.google.common.collect.ImmutableList.copyOf(r1)
L_0x000b:
r0 = 0
com.google.common.util.concurrent.ListenableFuture[] r0 = new com.google.common.util.concurrent.ListenableFuture[r0]
java.lang.Object[] r1 = r1.toArray(r0)
com.google.common.util.concurrent.ListenableFuture[] r1 = (com.google.common.util.concurrent.ListenableFuture[]) r1
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.common.util.concurrent.Futures.gwtCompatibleToArray(java.lang.Iterable):com.google.common.util.concurrent.ListenableFuture[]");
}
private static final class InCompletionOrderFuture<T> extends AbstractFuture<T> {
@CheckForNull
private InCompletionOrderState<T> state;
private InCompletionOrderFuture(InCompletionOrderState<T> inCompletionOrderState) {
this.state = inCompletionOrderState;
}
public boolean cancel(boolean z) {
InCompletionOrderState<T> inCompletionOrderState = this.state;
if (!super.cancel(z)) {
return false;
}
Objects.requireNonNull(inCompletionOrderState);
InCompletionOrderState inCompletionOrderState2 = inCompletionOrderState;
inCompletionOrderState.recordOutputCancellation(z);
return true;
}
/* access modifiers changed from: protected */
public void afterDone() {
this.state = null;
}
/* access modifiers changed from: protected */
@CheckForNull
public String pendingToString() {
InCompletionOrderState<T> inCompletionOrderState = this.state;
if (inCompletionOrderState == null) {
return null;
}
int length = inCompletionOrderState.inputFutures.length;
int i = inCompletionOrderState.incompleteOutputCount.get();
StringBuilder sb = new StringBuilder(49);
sb.append("inputCount=[");
sb.append(length);
sb.append("], remaining=[");
sb.append(i);
sb.append("]");
return sb.toString();
}
}
private static final class InCompletionOrderState<T> {
private volatile int delegateIndex;
/* access modifiers changed from: private */
public final AtomicInteger incompleteOutputCount;
/* access modifiers changed from: private */
public final ListenableFuture<? extends T>[] inputFutures;
private boolean shouldInterrupt;
private boolean wasCancelled;
private InCompletionOrderState(ListenableFuture<? extends T>[] listenableFutureArr) {
this.wasCancelled = false;
this.shouldInterrupt = true;
this.delegateIndex = 0;
this.inputFutures = listenableFutureArr;
this.incompleteOutputCount = new AtomicInteger(listenableFutureArr.length);
}
/* access modifiers changed from: private */
public void recordOutputCancellation(boolean z) {
this.wasCancelled = true;
if (!z) {
this.shouldInterrupt = false;
}
recordCompletion();
}
/* access modifiers changed from: private */
public void recordInputCompletion(ImmutableList<AbstractFuture<T>> immutableList, int i) {
ListenableFuture<? extends T> listenableFuture = this.inputFutures[i];
Objects.requireNonNull(listenableFuture);
ListenableFuture listenableFuture2 = listenableFuture;
this.inputFutures[i] = null;
for (int i2 = this.delegateIndex; i2 < immutableList.size(); i2++) {
if (((AbstractFuture) immutableList.get(i2)).setFuture(listenableFuture)) {
recordCompletion();
this.delegateIndex = i2 + 1;
return;
}
}
this.delegateIndex = immutableList.size();
}
private void recordCompletion() {
if (this.incompleteOutputCount.decrementAndGet() == 0 && this.wasCancelled) {
for (ListenableFuture<? extends T> listenableFuture : this.inputFutures) {
if (listenableFuture != null) {
listenableFuture.cancel(this.shouldInterrupt);
}
}
}
}
}
public static <V> void addCallback(ListenableFuture<V> listenableFuture, FutureCallback<? super V> futureCallback, Executor executor) {
Preconditions.checkNotNull(futureCallback);
listenableFuture.addListener(new CallbackListener(listenableFuture, futureCallback), executor);
}
private static final class CallbackListener<V> implements Runnable {
final FutureCallback<? super V> callback;
final Future<V> future;
CallbackListener(Future<V> future2, FutureCallback<? super V> futureCallback) {
this.future = future2;
this.callback = futureCallback;
}
public void run() {
Throwable tryInternalFastPathGetFailure;
Future<V> future2 = this.future;
if (!(future2 instanceof InternalFutureFailureAccess) || (tryInternalFastPathGetFailure = InternalFutures.tryInternalFastPathGetFailure((InternalFutureFailureAccess) future2)) == null) {
try {
this.callback.onSuccess(Futures.getDone(this.future));
} catch (ExecutionException e) {
this.callback.onFailure(e.getCause());
} catch (Error | RuntimeException e2) {
this.callback.onFailure(e2);
}
} else {
this.callback.onFailure(tryInternalFastPathGetFailure);
}
}
public String toString() {
return MoreObjects.toStringHelper((Object) this).addValue((Object) this.callback).toString();
}
}
@ParametricNullness
public static <V> V getDone(Future<V> future) throws ExecutionException {
Preconditions.checkState(future.isDone(), "Future was expected to be done: %s", (Object) future);
return Uninterruptibles.getUninterruptibly(future);
}
@ParametricNullness
public static <V, X extends Exception> V getChecked(Future<V> future, Class<X> cls) throws Exception {
return FuturesGetChecked.getChecked(future, cls);
}
@ParametricNullness
public static <V, X extends Exception> V getChecked(Future<V> future, Class<X> cls, long j, TimeUnit timeUnit) throws Exception {
return FuturesGetChecked.getChecked(future, cls, j, timeUnit);
}
@ParametricNullness
public static <V> V getUnchecked(Future<V> future) {
Preconditions.checkNotNull(future);
try {
return Uninterruptibles.getUninterruptibly(future);
} catch (ExecutionException e) {
wrapAndThrowUnchecked(e.getCause());
throw new AssertionError();
}
}
private static void wrapAndThrowUnchecked(Throwable th) {
if (th instanceof Error) {
throw new ExecutionError((Error) th);
}
throw new UncheckedExecutionException(th);
}
}
Download file