Skip to content

Commit

Permalink
优化beanTest,修复抽象方法错误
Browse files Browse the repository at this point in the history
  • Loading branch information
leaderli committed Aug 20, 2024
1 parent fa5aefe commit 1de4b3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -24,8 +23,8 @@

public class BeanMethodUtil {

private static String methodID(int access, String name, String desc) {
return Modifier.toString(access) + " " + name + ":" + desc;
private static String methodID(String name, String desc) {
return name + ":" + desc;
}


Expand All @@ -41,7 +40,7 @@ public static Method[] scanSimpleMethod(final Class<?> clazz, boolean allowInit)
methodDeclaredClasses.add(temp);
for (Method method : temp.getDeclaredMethods()) {
if (!method.isSynthetic()) {
String id = methodID(method.getModifiers(), method.getName(), MethodUtil.getMethodDescriptor(method));
String id = methodID(method.getName(), MethodUtil.getMethodDescriptor(method));
methodMap.putIfAbsent(id, method);
}
}
Expand Down Expand Up @@ -97,7 +96,7 @@ private static void visitMethod(Class<?> methodDeclaredClass, Map<String, Method
ClassVisitor classVisitor = new ClassVisitor(ASM6) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
String id = methodID(access, name, desc);
String id = methodID(name, desc);
Method method = methodMap.get(id);
if (method != null && method.getDeclaringClass() == methodDeclaredClass) {
MethodNode methodNode = new MethodNode(ASM6, access, name, desc, signature, exceptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ void test() {

}

class Base {
abstract class Base {
public void setMap(Map<String, String> map) {

}

public abstract void setMap2(Map<String, String> map);


}

class Util {
Expand Down Expand Up @@ -94,6 +98,9 @@ public void setMap(Map<String, String> map) {
map.put("1", "1");
}

public void setMap2(Map<String, String> map) {
map.put("1", "1");
}
public void init() {
this.age = new Person().age;
}
Expand Down

0 comments on commit 1de4b3d

Please sign in to comment.