Commit 554e119e authored by Skylot's avatar Skylot

fix: don't rename constructors

parent aad70c71
package jadx.core.dex.visitors;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -152,7 +153,14 @@ public class RenameVisitor extends AbstractVisitor {
}
private static void checkMethods(Deobfuscator deobfuscator, ClassNode cls, JadxArgs args) {
for (MethodNode mth : cls.getMethods()) {
List<MethodNode> methods = new ArrayList<>(cls.getMethods().size());
for (MethodNode method : cls.getMethods()) {
if (!method.getAccessFlags().isConstructor()) {
methods.add(method);
}
}
for (MethodNode mth : methods) {
String alias = mth.getAlias();
boolean notValid = args.isRenameValid() && !NameMapper.isValidIdentifier(alias);
......@@ -162,12 +170,10 @@ public class RenameVisitor extends AbstractVisitor {
mth.addAttr(new RenameReasonAttr(mth, notValid, notPrintable));
}
}
Set<String> names = new HashSet<>();
for (MethodNode mth : cls.getMethods()) {
Set<String> names = new HashSet<>(methods.size());
for (MethodNode mth : methods) {
AccessInfo accessFlags = mth.getAccessFlags();
if (accessFlags.isConstructor()
|| accessFlags.isBridge()
|| accessFlags.isSynthetic()
if (accessFlags.isBridge() || accessFlags.isSynthetic()
|| mth.contains(AFlag.DONT_GENERATE) /* this flag not set yet */) {
continue;
}
......
......@@ -50,6 +50,6 @@ public class TestDuplicatedNames extends SmaliTest {
assertThat(code, containsOne("this.f0fieldName"));
assertThat(code, containsOne("public Object run() {"));
assertThat(code, containsOne("public String m1run() {"));
assertThat(code, containsOne("public String m0run() {"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment