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 9ab76fa commit e29935b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static boolean isSimpleMethod(String ownerNameDesc, Map<String, LiTuple<
if (ins instanceof MethodInsnNode) {
MethodInsnNode mi = (MethodInsnNode) ins;
if (allowInit) {
if (mi.name.equals("<init>")) {
if (mi.name.equals("<init>") && mi.desc.equals("()V")) {
continue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public static int init(int age) {
}

class Person extends Base<String> {

public Person(int age) {
this.age = age;
if (this.age == 0) {
throw new IllegalArgumentException();
}
}

private int age;

public Person() {
Expand Down Expand Up @@ -101,6 +109,9 @@ public static void newAge3(Person person) {
person.setAge(1);
}

public static Person newAge4(int age) {
return new Person(age);
}
public void setMap(Map<String, String> map) {
map.put("1", "1");
}
Expand Down Expand Up @@ -130,6 +141,7 @@ public int setInt(Integer integer) {
public Integer setInt(int integer) {
return integer + 1;
}

public void init() {
this.age = new Person().age;
}
Expand Down

0 comments on commit e29935b

Please sign in to comment.