-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't remove empty default constructor if other constructors exi…
…sts (#460)
- Loading branch information
Showing
2 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
jadx-core/src/test/java/jadx/tests/integration/others/TestDefConstructorNotRemoved.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package jadx.tests.integration.others; | ||
|
||
import org.junit.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.JadxMatchers.containsOne; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class TestDefConstructorNotRemoved extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
|
||
static { | ||
// empty | ||
} | ||
|
||
public static class A { | ||
private final String s; | ||
|
||
public A() { | ||
s = "a"; | ||
} | ||
|
||
public A(String str) { | ||
s = str; | ||
} | ||
} | ||
|
||
public static class B extends A { | ||
public B() { | ||
super(); | ||
} | ||
|
||
public B(String s) { | ||
super(s); | ||
} | ||
} | ||
|
||
public void check() { | ||
new A(); | ||
new A("a"); | ||
new B(); | ||
new B("b"); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, not(containsString("super();"))); | ||
assertThat(code, not(containsString("static {"))); | ||
assertThat(code, containsOne("public B() {")); | ||
} | ||
} |