Skip to content

Commit

Permalink
fix: hide first argument instead remove for constructor in inner class
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Mar 2, 2019
1 parent cbdc249 commit 653bb2a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ private void addMethods(CodeWriter code) {
code.newLine().addMultiLine(Utils.getStackTrace(e));
code.newLine().add("*/");
code.setIndent(savedIndent);
mth.addError("Method generation error: " + e.getMessage(), e);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public boolean addDefinition(CodeWriter code) {
} else {
mth.addComment("JADX WARN: Incorrect number of args for enum constructor: " + args.size() + " (expected >= 2)");
}
} else if (mth.contains(AFlag.SKIP_FIRST_ARG)) {
args = args.subList(1, args.size());
}
addMethodArguments(code, args);
code.add(')');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,7 @@ public void use(RegisterArg arg) {
}

public void removeUse(RegisterArg arg) {
for (int i = 0, useListSize = useList.size(); i < useListSize; i++) {
if (useList.get(i) == arg) {
useList.remove(i);
break;
}
}
useList.removeIf(registerArg -> registerArg == arg);
}

public void setUsedInPhi(@Nullable PhiInsn usedInPhi) {
Expand Down
3 changes: 1 addition & 2 deletions jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,8 @@ public List<RegisterArg> getArguments(boolean includeThis) {
return argsList;
}

public RegisterArg removeFirstArgument() {
public void skipFirstArgument() {
this.add(AFlag.SKIP_FIRST_ARG);
return argsList.remove(0);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static boolean removeFieldUsageFromConstructor(MethodNode mth, FieldNode
if (!fieldInfo.equals(field.getFieldInfo()) || !putInsn.getArg(0).equals(arg)) {
return false;
}
mth.removeFirstArgument();
mth.skipFirstArgument();
InstructionRemover.remove(mth, block, insn);
// other arg usage -> wrap with IGET insn
if (arg.getSVar().getUseCount() != 0) {
Expand Down

0 comments on commit 653bb2a

Please sign in to comment.