Skip to content

Commit

Permalink
fix: don't rename constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jun 15, 2019
1 parent aad70c7 commit 554e119
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand Down Expand Up @@ -152,7 +153,14 @@ private static void checkFields(Deobfuscator deobfuscator, ClassNode cls, JadxAr
}

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);
Expand All @@ -162,12 +170,10 @@ private static void checkMethods(Deobfuscator deobfuscator, ClassNode cls, JadxA
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ private void commonChecks() {
assertThat(code, containsOne("this.f0fieldName"));

assertThat(code, containsOne("public Object run() {"));
assertThat(code, containsOne("public String m1run() {"));
assertThat(code, containsOne("public String m0run() {"));
}
}

0 comments on commit 554e119

Please sign in to comment.