-
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: deep reload for inner classes, const values and anonymous classes
- Loading branch information
Showing
7 changed files
with
156 additions
and
18 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
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
34 changes: 34 additions & 0 deletions
34
jadx-core/src/test/java/jadx/tests/integration/rename/TestAnonymousInline.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,34 @@ | ||
package jadx.tests.integration.rename; | ||
|
||
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 TestAnonymousInline extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
public Runnable test() { | ||
return new Runnable() { | ||
@Override | ||
public void run() { | ||
System.out.println("run"); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
assertThat(cls.getCode()) | ||
.containsOnlyOnce("return new Runnable() {"); | ||
|
||
assertThat(cls.reloadCode()) | ||
.print() | ||
.containsOnlyOnce("return new Runnable() {") | ||
.doesNotContain("AnonymousClass1"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
jadx-core/src/test/java/jadx/tests/integration/rename/TestConstReplace.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,30 @@ | ||
package jadx.tests.integration.rename; | ||
|
||
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 TestConstReplace extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
public static final String CONST = "SOME_CONST"; | ||
|
||
public String test() { | ||
return CONST; | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
assertThat(cls.getCode()) | ||
.containsOnlyOnce("return CONST;"); | ||
|
||
assertThat(cls.reloadCode()) | ||
.print() | ||
.containsOnlyOnce("return CONST;"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
jadx-core/src/test/java/jadx/tests/integration/rename/TestRenameEnum.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,44 @@ | ||
package jadx.tests.integration.rename; | ||
|
||
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 TestRenameEnum extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
|
||
public enum A implements Runnable { | ||
ONE { | ||
@Override | ||
public void run() { | ||
System.out.println("ONE"); | ||
} | ||
}, | ||
TWO { | ||
@Override | ||
public void run() { | ||
System.out.println("TWO"); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
assertThat(cls.getCode()) | ||
.containsOnlyOnce("public enum A ") | ||
.containsOnlyOnce("ONE {"); | ||
|
||
cls.getInnerClasses().get(0).getClassInfo().changeShortName("ARenamed"); | ||
|
||
assertThat(cls.reloadCode()) | ||
.print() | ||
.containsOnlyOnce("public enum ARenamed ") | ||
.containsOnlyOnce("ONE {"); | ||
} | ||
} |