Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
d5f42662
Commit
d5f42662
authored
Mar 22, 2019
by
Ahmed Ashour
Committed by
skylot
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: rename class with reserved java keywords (#485) (PR #488)
parent
988ada3c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
RenameVisitor.java
...e/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
+3
-0
TestReservedClassNames.java
.../jadx/tests/integration/names/TestReservedClassNames.java
+27
-0
TestReservedClassNames.smali
jadx-core/src/test/smali/names/TestReservedClassNames.smali
+12
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
View file @
d5f42662
...
@@ -92,6 +92,9 @@ public class RenameVisitor extends AbstractVisitor {
...
@@ -92,6 +92,9 @@ public class RenameVisitor extends AbstractVisitor {
if
(
firstChar
==
'$'
)
{
if
(
firstChar
==
'$'
)
{
return
'C'
+
NameMapper
.
removeInvalidCharsMiddle
(
clsName
);
return
'C'
+
NameMapper
.
removeInvalidCharsMiddle
(
clsName
);
}
}
if
(!
NameMapper
.
isValidIdentifier
(
clsName
))
{
return
'C'
+
clsName
;
}
return
NameMapper
.
removeInvalidChars
(
clsName
,
"C"
);
return
NameMapper
.
removeInvalidChars
(
clsName
,
"C"
);
}
}
...
...
jadx-core/src/test/java/jadx/tests/integration/names/TestReservedClassNames.java
0 → 100644
View file @
d5f42662
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
;
import
java.io.File
;
public
class
TestReservedClassNames
extends
SmaliTest
{
/*
public class do {
}
*/
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNodeFromSmali
(
"names"
+
File
.
separatorChar
+
"TestReservedClassNames"
,
"do"
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
not
(
containsString
(
"public class do"
)));
}
}
jadx-core/src/test/smali/names/TestReservedClassNames.smali
0 → 100644
View file @
d5f42662
.class public Ldo;
.super Ljava/lang/Object;
# direct methods
.method public constructor <init>()V
.locals 0
.line 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment