Skip to content

Commit

Permalink
优化beanTest,移除连续属性调用
Browse files Browse the repository at this point in the history
  • Loading branch information
leaderli committed Aug 21, 2024
1 parent e29935b commit dd147c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.*;

import java.io.IOException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -115,6 +112,11 @@ private static boolean isSimpleMethod(String ownerNameDesc, Map<String, LiTuple<
}
return false;

} else if (ins instanceof FieldInsnNode && ins.getOpcode() == Opcodes.GETFIELD) {
// 连续两次属性调用,视为复杂指令
if (ins.getNext() instanceof FieldInsnNode && ins.getNext().getOpcode() == Opcodes.GETFIELD) {
return false;
}
} else if (ins instanceof InsnNode) {
if (ins.getOpcode() == Opcodes.ATHROW) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public Person(int age) {
}

private int age;
private Person person;

public Person() {
this.age = 1;
Expand Down Expand Up @@ -146,6 +147,9 @@ public void init() {
this.age = new Person().age;
}

public void init2() {
this.age = person.age;
}
public void error(int a) {
if (a == 0) {
throw new IllegalStateException();
Expand Down

0 comments on commit dd147c2

Please sign in to comment.