-
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: rename packages with reserved names (#711)
- Loading branch information
Showing
5 changed files
with
119 additions
and
24 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
59 changes: 59 additions & 0 deletions
59
jadx-core/src/test/java/jadx/tests/integration/names/TestReservedPackageNames.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,59 @@ | ||
package jadx.tests.integration.names; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.SmaliTest; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
public class TestReservedPackageNames extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
package do.if; | ||
public class A {} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
List<ClassNode> clsList = loadFromSmaliFiles(); | ||
for (ClassNode cls : clsList) { | ||
String code = cls.getCode().toString(); | ||
assertThat(code, not(containsString("package do.if;"))); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDeobf() { | ||
enableDeobfuscation(); | ||
List<ClassNode> clsList = loadFromSmaliFiles(); | ||
for (ClassNode cls : clsList) { | ||
String code = cls.getCode().toString(); | ||
assertThat(code, not(containsString("package do.if;"))); | ||
} | ||
} | ||
|
||
@Test | ||
public void testRenameDisabled() { | ||
args.setRenameCaseSensitive(false); | ||
args.setRenameValid(false); | ||
args.setRenamePrintable(false); | ||
|
||
disableCompilation(); | ||
|
||
List<ClassNode> clsList = loadFromSmaliFiles(); | ||
for (ClassNode cls : clsList) { | ||
String code = cls.getCode().toString(); | ||
if (cls.getShortName().equals("A")) { | ||
assertThat(code, containsString("package do.if;")); | ||
} | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
jadx-core/src/test/smali/names/TestReservedPackageNames/a.smali
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,2 @@ | ||
.class public Ldo/if/A; | ||
.super Ljava/lang/Object; |