-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow to regenerate class code (#791)
- Loading branch information
Showing
4 changed files
with
70 additions
and
14 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
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
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
41 changes: 41 additions & 0 deletions
41
jadx-core/src/test/java/jadx/tests/integration/others/TestClassReGen.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,41 @@ | ||
package jadx.tests.integration.others; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestClassReGen extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
private int intField = 5; | ||
|
||
public static class A { | ||
} | ||
|
||
public int test() { | ||
return 0; | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
assertThat(cls.getCode()) | ||
.containsOnlyOnce("private int intField = 5;") | ||
.containsOnlyOnce("public static class A {") | ||
.containsOnlyOnce("public int test() {"); | ||
|
||
cls.getInnerClasses().get(0).getClassInfo().changeShortName("ARenamed"); | ||
cls.searchMethodByShortName("test").getMethodInfo().setAlias("testRenamed"); | ||
cls.searchFieldByName("intField").getFieldInfo().setAlias("intFieldRenamed"); | ||
|
||
assertThat(cls.reloadCode()) | ||
.print() | ||
.containsOnlyOnce("private int intFieldRenamed = 5;") | ||
.containsOnlyOnce("public static class ARenamed {") | ||
.containsOnlyOnce("public int testRenamed() {"); | ||
} | ||
} |