CrackMe.apk
Download file
package com.google.common.base;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.ref.PhantomReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
@ElementTypesAreNonnullByDefault
public class FinalizableReferenceQueue implements Closeable {
private static final String FINALIZER_CLASS_NAME = "com.google.common.base.internal.Finalizer";
/* access modifiers changed from: private */
public static final Logger logger = Logger.getLogger(FinalizableReferenceQueue.class.getName());
private static final Method startFinalizer = getStartFinalizer(loadFinalizer(new SystemLoader(), new DecoupledLoader(), new DirectLoader()));
final PhantomReference<Object> frqRef;
final ReferenceQueue<Object> queue;
final boolean threadStarted;
interface FinalizerLoader {
@CheckForNull
Class<?> loadFinalizer();
}
public FinalizableReferenceQueue() {
ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
this.queue = referenceQueue;
PhantomReference<Object> phantomReference = new PhantomReference<>(this, referenceQueue);
this.frqRef = phantomReference;
boolean z = true;
try {
startFinalizer.invoke((Object) null, new Object[]{FinalizableReference.class, referenceQueue, phantomReference});
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (Throwable th) {
logger.log(Level.INFO, "Failed to start reference finalizer thread. Reference cleanup will only occur when new references are created.", th);
z = false;
}
this.threadStarted = z;
}
public void close() {
this.frqRef.enqueue();
cleanUp();
}
/* access modifiers changed from: package-private */
public void cleanUp() {
if (!this.threadStarted) {
while (true) {
Reference<? extends Object> poll = this.queue.poll();
if (poll != null) {
poll.clear();
try {
((FinalizableReference) poll).finalizeReferent();
} catch (Throwable th) {
logger.log(Level.SEVERE, "Error cleaning up after reference.", th);
}
} else {
return;
}
}
}
}
private static Class<?> loadFinalizer(FinalizerLoader... finalizerLoaderArr) {
for (FinalizerLoader loadFinalizer : finalizerLoaderArr) {
Class<?> loadFinalizer2 = loadFinalizer.loadFinalizer();
if (loadFinalizer2 != null) {
return loadFinalizer2;
}
}
throw new AssertionError();
}
static class SystemLoader implements FinalizerLoader {
static boolean disabled;
SystemLoader() {
}
@CheckForNull
public Class<?> loadFinalizer() {
if (disabled) {
return null;
}
try {
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
if (systemClassLoader != null) {
try {
return systemClassLoader.loadClass(FinalizableReferenceQueue.FINALIZER_CLASS_NAME);
} catch (ClassNotFoundException unused) {
}
}
return null;
} catch (SecurityException unused2) {
FinalizableReferenceQueue.logger.info("Not allowed to access system class loader.");
return null;
}
}
}
static class DecoupledLoader implements FinalizerLoader {
private static final String LOADING_ERROR = "Could not load Finalizer in its own class loader. Loading Finalizer in the current class loader instead. As a result, you will not be able to garbage collect this class loader. To support reclaiming this class loader, either resolve the underlying issue, or move Guava to your system class path.";
DecoupledLoader() {
}
@CheckForNull
public Class<?> loadFinalizer() {
try {
return newLoader(getBaseUrl()).loadClass(FinalizableReferenceQueue.FINALIZER_CLASS_NAME);
} catch (Exception e) {
FinalizableReferenceQueue.logger.log(Level.WARNING, LOADING_ERROR, e);
return null;
}
}
/* access modifiers changed from: package-private */
public URL getBaseUrl() throws IOException {
String concat = String.valueOf(FinalizableReferenceQueue.FINALIZER_CLASS_NAME.replace(FilenameUtils.EXTENSION_SEPARATOR, IOUtils.DIR_SEPARATOR_UNIX)).concat(".class");
URL resource = getClass().getClassLoader().getResource(concat);
if (resource != null) {
String url = resource.toString();
if (url.endsWith(concat)) {
return new URL(resource, url.substring(0, url.length() - concat.length()));
}
String valueOf = String.valueOf(url);
throw new IOException(valueOf.length() != 0 ? "Unsupported path style: ".concat(valueOf) : new String("Unsupported path style: "));
}
throw new FileNotFoundException(concat);
}
/* access modifiers changed from: package-private */
public URLClassLoader newLoader(URL url) {
return new URLClassLoader(new URL[]{url}, (ClassLoader) null);
}
}
static class DirectLoader implements FinalizerLoader {
DirectLoader() {
}
public Class<?> loadFinalizer() {
try {
return Class.forName(FinalizableReferenceQueue.FINALIZER_CLASS_NAME);
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
}
}
static Method getStartFinalizer(Class<?> cls) {
try {
return cls.getMethod("startFinalizer", new Class[]{Class.class, ReferenceQueue.class, PhantomReference.class});
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
}
Download file