forked from skylot/jadx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: force rename fields and methods with reserved names (skylot#364)
- Loading branch information
Showing
8 changed files
with
101 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ out/ | |
*.iml | ||
*.ipr | ||
*.iws | ||
.attach_pid* | ||
|
||
**/.DS_Store | ||
|
||
|
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
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
32 changes: 32 additions & 0 deletions
32
jadx-core/src/test/java/jadx/tests/integration/names/TestReservedNames.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,32 @@ | ||
package jadx.tests.integration.names; | ||
|
||
import org.junit.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.SmaliTest; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class TestReservedNames extends SmaliTest { | ||
/* | ||
public static class TestCls { | ||
public String do; // reserved name | ||
public String 0f; // invalid identifier | ||
public String try() { | ||
return this.do; | ||
} | ||
} | ||
*/ | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmaliWithPath("names", "TestReservedNames"); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, not(containsString("public String do;"))); | ||
} | ||
} |
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,32 @@ | ||
.class public LTestReservedNames; | ||
.super Ljava/lang/Object; | ||
.source "TestReservedNames.java" | ||
|
||
|
||
# instance fields | ||
.field public do:Ljava/lang/String; # reserved name | ||
.field public 0f:Ljava/lang/String; # invalid identifier | ||
|
||
|
||
# direct methods | ||
.method public constructor <init>()V | ||
.registers 1 | ||
|
||
.prologue | ||
.line 3 | ||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
|
||
return-void | ||
.end method | ||
|
||
|
||
# virtual methods | ||
.method public try()Ljava/lang/String; | ||
.registers 2 | ||
|
||
.prologue | ||
.line 8 | ||
iget-object v0, p0, LTestReservedNames;->do:Ljava/lang/String; | ||
|
||
return-object v0 | ||
.end method |