mirror of
https://github.com/skylot/jadx.git
synced 2024-11-23 04:39:46 +00:00
Fix self constructor call
This commit is contained in:
parent
4e7ef9f4d2
commit
a55f4c59ce
@ -211,15 +211,12 @@ public class RegionGen extends InsnGen {
|
||||
|
||||
private void makeCaseBlock(IContainer c, CodeWriter code) throws CodegenException {
|
||||
if (RegionUtils.notEmpty(c)) {
|
||||
boolean closeBlock = RegionUtils.hasExitEdge(c);
|
||||
if (closeBlock) {
|
||||
code.add(" {");
|
||||
}
|
||||
code.add(" {");
|
||||
makeRegionIndent(code, c);
|
||||
if (closeBlock) {
|
||||
if (RegionUtils.hasExitEdge(c)) {
|
||||
code.startLine(1, "break;");
|
||||
code.startLine('}');
|
||||
}
|
||||
code.startLine('}');
|
||||
} else {
|
||||
code.startLine(1, "break;");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class ConstructorInsn extends InsnNode {
|
||||
SELF // call itself
|
||||
}
|
||||
|
||||
private final CallType callType;
|
||||
private CallType callType;
|
||||
|
||||
public ConstructorInsn(MethodNode mth, InvokeNode invoke) {
|
||||
super(InsnType.CONSTRUCTOR, invoke.getArgsCount() - 1);
|
||||
@ -28,16 +28,17 @@ public class ConstructorInsn extends InsnNode {
|
||||
|
||||
if (invoke.getArg(0).isThis()) {
|
||||
if (classType.equals(mth.getParentClass().getClassInfo())) {
|
||||
// self constructor
|
||||
if (callMth.getShortId().equals(mth.getMethodInfo().getShortId())) {
|
||||
// self constructor
|
||||
callType = CallType.SELF;
|
||||
} else {
|
||||
} else if (mth.getMethodInfo().isConstructor()) {
|
||||
callType = CallType.THIS;
|
||||
}
|
||||
} else {
|
||||
callType = CallType.SUPER;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (callType == null) {
|
||||
callType = CallType.CONSTRUCTOR;
|
||||
setResult((RegisterArg) invoke.getArg(0));
|
||||
}
|
||||
|
@ -207,7 +207,10 @@ public class RegionMaker {
|
||||
// found cross
|
||||
if (next.getCleanSuccessors().size() == 1) {
|
||||
BlockNode r = BlockUtils.getNextBlock(next);
|
||||
if (r != null && r.getAttributes().contains(AttributeFlag.RETURN)) {
|
||||
if (r != null
|
||||
&& r.getAttributes().contains(AttributeFlag.RETURN)
|
||||
&& r.getInstructions().size() > 0
|
||||
&& r.getInstructions().get(0).getType() == InsnType.RETURN) {
|
||||
next.getAttributes().add(new ForceReturnAttr(r.getInstructions().get(0)));
|
||||
} else {
|
||||
next.getAttributes().add(AttributeFlag.BREAK);
|
||||
|
@ -3,9 +3,16 @@ package jadx.samples;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TestInvoke extends AbstractTest {
|
||||
|
||||
private int f;
|
||||
|
||||
public TestInvoke() {
|
||||
this(-1);
|
||||
}
|
||||
|
||||
public TestInvoke(int f) {
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
private void parse(String[] args) {
|
||||
if (args.length > 0)
|
||||
f = Integer.parseInt(args[0]);
|
||||
@ -30,6 +37,13 @@ public class TestInvoke extends AbstractTest {
|
||||
return s;
|
||||
}
|
||||
|
||||
public TestInvoke testConstructor(int flag) {
|
||||
if (getF() == flag)
|
||||
return new TestInvoke(flag);
|
||||
else
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testRun() throws Exception {
|
||||
TestInvoke inv = new TestInvoke();
|
||||
@ -41,6 +55,8 @@ public class TestInvoke extends AbstractTest {
|
||||
|
||||
assertTrue(inv.testVarArgs("a", "2", "III"));
|
||||
assertTrue(inv.testVarArgs2("a".toCharArray(), new char[] { '1', '2' }).equals("a12"));
|
||||
|
||||
assertTrue(testConstructor(f) != this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user