87 lines
3 KiB
Java
87 lines
3 KiB
Java
package c.e.b;
|
|
|
|
import java.lang.ref.WeakReference;
|
|
import java.lang.reflect.Method;
|
|
import java.security.ProtectionDomain;
|
|
import java.util.WeakHashMap;
|
|
/* compiled from: AccessClassLoader */
|
|
public class a extends ClassLoader {
|
|
public static final WeakHashMap<ClassLoader, WeakReference<a>> a = new WeakHashMap<>();
|
|
public static final ClassLoader b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public static volatile a f341c;
|
|
public static volatile Method d;
|
|
|
|
static {
|
|
ClassLoader classLoader = a.class.getClassLoader();
|
|
if (classLoader == null) {
|
|
classLoader = ClassLoader.getSystemClassLoader();
|
|
}
|
|
b = classLoader;
|
|
f341c = new a(classLoader);
|
|
}
|
|
|
|
public a(ClassLoader classLoader) {
|
|
super(classLoader);
|
|
}
|
|
|
|
public static a b(Class cls) {
|
|
ClassLoader classLoader = cls.getClassLoader();
|
|
if (classLoader == null) {
|
|
classLoader = ClassLoader.getSystemClassLoader();
|
|
}
|
|
ClassLoader classLoader2 = b;
|
|
if (classLoader2.equals(classLoader)) {
|
|
if (f341c == null) {
|
|
synchronized (a) {
|
|
if (f341c == null) {
|
|
f341c = new a(classLoader2);
|
|
}
|
|
}
|
|
}
|
|
return f341c;
|
|
}
|
|
WeakHashMap<ClassLoader, WeakReference<a>> weakHashMap = a;
|
|
synchronized (weakHashMap) {
|
|
WeakReference<a> weakReference = weakHashMap.get(classLoader);
|
|
if (weakReference != null) {
|
|
a aVar = weakReference.get();
|
|
if (aVar != null) {
|
|
return aVar;
|
|
}
|
|
weakHashMap.remove(classLoader);
|
|
}
|
|
a aVar2 = new a(classLoader);
|
|
weakHashMap.put(classLoader, new WeakReference<>(aVar2));
|
|
return aVar2;
|
|
}
|
|
}
|
|
|
|
public static Method c() throws Exception {
|
|
if (d == null) {
|
|
synchronized (a) {
|
|
Class cls = Integer.TYPE;
|
|
d = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, cls, cls, ProtectionDomain.class);
|
|
try {
|
|
d.setAccessible(true);
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
}
|
|
return d;
|
|
}
|
|
|
|
public Class<?> a(String str, byte[] bArr) throws ClassFormatError {
|
|
try {
|
|
return (Class) c().invoke(getParent(), str, bArr, 0, Integer.valueOf(bArr.length), getClass().getProtectionDomain());
|
|
} catch (Exception unused) {
|
|
return defineClass(str, bArr, 0, bArr.length, a.class.getProtectionDomain());
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.ClassLoader
|
|
public Class<?> loadClass(String str, boolean z2) throws ClassNotFoundException {
|
|
return str.equals(c.class.getName()) ? c.class : str.equals(d.class.getName()) ? d.class : str.equals(b.class.getName()) ? b.class : str.equals(e.class.getName()) ? e.class : super.loadClass(str, z2);
|
|
}
|
|
}
|