-
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: check class name collisions (#1526)
- Loading branch information
Showing
4 changed files
with
94 additions
and
6 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
59 changes: 59 additions & 0 deletions
59
jadx-core/src/test/java/jadx/tests/integration/names/TestCollisionWithJavaLangClasses.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.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestCollisionWithJavaLangClasses extends IntegrationTest { | ||
|
||
public static class TestCls1 { | ||
public static class System { | ||
public static void main(String[] args) { | ||
java.lang.System.out.println("Hello world"); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void test1() { | ||
assertThat(getClassNode(TestCls1.class)) | ||
.code() | ||
.containsOne("java.lang.System.out.println"); | ||
} | ||
|
||
public static class TestCls2 { | ||
public void doSomething() { | ||
System.doSomething(); | ||
java.lang.System.out.println("Hello World"); | ||
} | ||
|
||
public static class System { | ||
public static void doSomething() { | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
assertThat(getClassNode(TestCls2.class)) | ||
.code() | ||
.containsLine(2, "System.doSomething();") | ||
.containsOne("java.lang.System.out.println"); | ||
} | ||
|
||
@Test | ||
public void test3() { | ||
List<ClassNode> classes = getClassNodes( | ||
jadx.tests.integration.names.pkg2.System.class, | ||
jadx.tests.integration.names.pkg2.TestCls.class); | ||
assertThat(searchCls(classes, "TestCls")) | ||
.code() | ||
.containsLine(2, "System.doSomething();") | ||
.containsOne("java.lang.System.out.println"); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
jadx-core/src/test/java/jadx/tests/integration/names/pkg2/System.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,6 @@ | ||
package jadx.tests.integration.names.pkg2; | ||
|
||
public class System { | ||
public static void doSomething() { | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
jadx-core/src/test/java/jadx/tests/integration/names/pkg2/TestCls.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,8 @@ | ||
package jadx.tests.integration.names.pkg2; | ||
|
||
public class TestCls { | ||
public void doSomething() { | ||
System.doSomething(); | ||
java.lang.System.out.println("Hello World"); | ||
} | ||
} |