Skip to content

Commit

Permalink
Optimized getWrapper of bytecode Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
zrlw committed Feb 22, 2025
1 parent cedc583 commit f3e58c7
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,17 @@ public Object invokeMethod(Object instance, String mn, Class<?>[] types, Object[
* @return Wrapper instance(not null).
*/
public static Wrapper getWrapper(Class<?> c) {
while (ClassGenerator.isDynamicClass(c)) // can not wrapper on dynamic class.
{
c = c.getSuperclass();
}

if (c == Object.class) {
return OBJECT_WRAPPER;
}
return ConcurrentHashMapUtils.computeIfAbsent(WRAPPER_MAP, c, (clazz) -> {
while (ClassGenerator.isDynamicClass(clazz)) // can not wrapper on dynamic class.
{
clazz = clazz.getSuperclass();
}

return ConcurrentHashMapUtils.computeIfAbsent(WRAPPER_MAP, c, Wrapper::makeWrapper);
if (clazz == Object.class) {
return OBJECT_WRAPPER;
}
return makeWrapper(clazz);
});
}

private static Wrapper makeWrapper(Class<?> c) {
Expand Down

0 comments on commit f3e58c7

Please sign in to comment.