what-the-bank/sources/com/google/common/reflect/Reflection.java

37 lines
1.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.reflect;
import com.google.common.base.Preconditions;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
/* loaded from: classes2.dex */
public final class Reflection {
public static String getPackageName(Class<?> cls) {
return getPackageName(cls.getName());
}
public static String getPackageName(String str) {
int lastIndexOf = str.lastIndexOf(46);
return lastIndexOf < 0 ? "" : str.substring(0, lastIndexOf);
}
public static void initialize(Class<?>... clsArr) {
for (Class<?> cls : clsArr) {
try {
Class.forName(cls.getName(), true, cls.getClassLoader());
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
}
}
public static <T> T newProxy(Class<T> cls, InvocationHandler invocationHandler) {
Preconditions.checkNotNull(invocationHandler);
Preconditions.checkArgument(cls.isInterface(), "%s is not an interface", cls);
return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(), new Class[]{cls}, invocationHandler));
}
private Reflection() {
}
}