Skip to content

Commit

Permalink
Pick from apache#7517 68062c1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed May 28, 2021
1 parent 8574f8c commit 7325f47
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.ReflectUtils;

import javassist.ClassPool;
import javassist.CtMethod;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.stream.Collectors;

/**
* Wrapper.
Expand Down Expand Up @@ -150,7 +155,23 @@ private static Wrapper makeWrapper(Class<?> c) {
pts.put(fn, ft);
}

Method[] methods = c.getMethods();
final ClassPool classPool = new ClassPool(ClassPool.getDefault());
classPool.appendClassPath(new CustomizedLoaderClassPath(cl));

List<String> allMethod = new ArrayList<>();
try {
final CtMethod[] ctMethods = classPool.get(c.getName()).getMethods();
for (CtMethod method : ctMethods) {
allMethod.add(ReflectUtils.getDesc(method));
}
} catch (Exception e) {
throw new RuntimeException(e);
}

Method[] methods = Arrays.stream(c.getMethods())
.filter(method -> allMethod.contains(ReflectUtils.getDesc(method)))
.collect(Collectors.toList())
.toArray(new Method[] {});
// get all public method.
boolean hasMethod = hasMethods(methods);
if (hasMethod) {
Expand All @@ -159,7 +180,7 @@ private static Wrapper makeWrapper(Class<?> c) {
sameNameMethodCount.compute(m.getName(),
(key, oldValue) -> oldValue == null ? 1 : oldValue + 1);
}

c3.append(" try{");
for (Method m : methods) {
//ignore Object's method.
Expand Down

0 comments on commit 7325f47

Please sign in to comment.