Skip to content

Commit

Permalink
Fix hashCode crash
Browse files Browse the repository at this point in the history
nnjun committed Feb 28, 2022
1 parent f68b4d3 commit 405a603
Showing 1 changed file with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -45,24 +45,9 @@ public class BlackReflection {

public static <T> T create(Class<T> clazz, final Object caller, boolean withException) {
try {
if (!withException) {
if (caller == null) {
Object o = sProxyCache.get(clazz);
if (o != null) {
return (T) o;
}
}
else {
Map<Class<?>, Object> callerClassMap = sCallerProxyCache.get(caller);
if (callerClassMap != null) {
Object o = callerClassMap.get(clazz);
if (o != null) {
return (T) o;
}
}
}
}

T proxy = getProxy(clazz, caller, withException);
if (proxy != null)
return proxy;
final WeakReference<Object> weakCaller = caller == null ? null : new WeakReference<>(caller);

final Class<?> aClass = getClassNameByBlackClass(clazz);
@@ -194,6 +179,30 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
return null;
}

private static <T> T getProxy(Class<T> clazz, final Object caller, boolean withException) {
try {
if (!withException) {
if (caller == null) {
Object o = sProxyCache.get(clazz);
if (o != null) {
return (T) o;
}
}
else {
Map<Class<?>, Object> callerClassMap = sCallerProxyCache.get(caller);
if (callerClassMap != null) {
Object o = callerClassMap.get(clazz);
if (o != null) {
return (T) o;
}
}
}
}
} catch (Throwable ignore) {
}
return null;
}

private static Class<?>[] getParamClass(Method method) throws Throwable {
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
Class<?>[] parameterTypes = method.getParameterTypes();

0 comments on commit 405a603

Please sign in to comment.