From 8d158425c6336a5aafb4e1081db3918343c9a72a Mon Sep 17 00:00:00 2001 From: Milk <1871357815@qq.com> Date: Sat, 19 Feb 2022 13:42:15 +0800 Subject: [PATCH] fix get field bug --- .../blackreflection/BlackReflection.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java b/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java index 0134fe4..a987784 100644 --- a/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java +++ b/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java @@ -52,15 +52,15 @@ public static T create(Class clazz, final Object caller, boolean withExce return (T) o; } } -// else { -// Map, Object> callerClassMap = sCallerProxyCache.get(caller); -// if (callerClassMap != null) { -// Object o = callerClassMap.get(clazz); -// if (o != null) { -// return (T) o; -// } -// } -// } + else { + Map, Object> callerClassMap = sCallerProxyCache.get(caller); + if (callerClassMap != null) { + Object o = callerClassMap.get(clazz); + if (o != null) { + return (T) o; + } + } + } } final WeakReference weakCaller = caller == null ? null : new WeakReference<>(caller); @@ -84,7 +84,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl Object call; Reflector on = Reflector.on(aClass).field(name); if (isStatic) { - call = on.get(args); + call = on.get(); } else { if (callerByWeak == null) { return generateNullValue(returnType); @@ -169,12 +169,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl if (caller == null) { sProxyCache.put(clazz, o); } else { -// Map, Object> callerClassMap = sCallerProxyCache.get(caller); -// if (callerClassMap == null) { -// callerClassMap = new HashMap<>(); -// sCallerProxyCache.put(caller, callerClassMap); -// } -// callerClassMap.put(clazz, o); + Map, Object> callerClassMap = sCallerProxyCache.get(caller); + if (callerClassMap == null) { + callerClassMap = new HashMap<>(); + sCallerProxyCache.put(caller, callerClassMap); + } + callerClassMap.put(clazz, o); } return (T) o; } catch (ClassNotFoundException e) {