Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
f87bf3f1
Commit
f87bf3f1
authored
Apr 05, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix class renaming by source file info
parent
87347c0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
16 deletions
+24
-16
Deobfuscator.java
jadx-core/src/main/java/jadx/core/deobf/Deobfuscator.java
+24
-16
No files found.
jadx-core/src/main/java/jadx/core/deobf/Deobfuscator.java
View file @
f87bf3f1
...
...
@@ -211,29 +211,37 @@ public class Deobfuscator {
}
private
String
makeClsAlias
(
ClassNode
cls
)
{
SourceFileAttr
sourceFileAttr
=
cls
.
get
(
AType
.
SOURCE_FILE
);
if
(
sourceFileAttr
!=
null
)
{
String
name
=
sourceFileAttr
.
getFileName
();
if
(
name
.
endsWith
(
".java"
))
{
name
=
name
.
substring
(
0
,
name
.
length
()
-
".java"
.
length
());
}
if
(
NameMapper
.
isValidIdentifier
(
name
)
&&
!
NameMapper
.
isReserved
(
name
))
{
// TODO: check if no class with this name exists or already renamed
cls
.
remove
(
AType
.
SOURCE_FILE
);
return
name
;
}
}
ClassInfo
classInfo
=
cls
.
getClassInfo
();
String
clsName
=
classInfo
.
getShortName
();
String
alias
=
String
.
format
(
"C%04d%s"
,
clsIndex
++,
makeName
(
clsName
));
String
alias
=
getAliasFromSourceFile
(
cls
);
if
(
alias
==
null
)
{
String
clsName
=
classInfo
.
getShortName
();
alias
=
String
.
format
(
"C%04d%s"
,
clsIndex
++,
makeName
(
clsName
));
}
PackageNode
pkg
=
getPackageNode
(
classInfo
.
getPackage
(),
true
);
clsMap
.
put
(
classInfo
,
new
DeobfClsInfo
(
this
,
cls
,
pkg
,
alias
));
return
alias
;
}
@Nullable
private
String
getAliasFromSourceFile
(
ClassNode
cls
)
{
SourceFileAttr
sourceFileAttr
=
cls
.
get
(
AType
.
SOURCE_FILE
);
if
(
sourceFileAttr
==
null
)
{
return
null
;
}
String
name
=
sourceFileAttr
.
getFileName
();
if
(
name
.
endsWith
(
".java"
))
{
name
=
name
.
substring
(
0
,
name
.
length
()
-
".java"
.
length
());
}
if
(
NameMapper
.
isValidIdentifier
(
name
)
&&
!
NameMapper
.
isReserved
(
name
))
{
// TODO: check if no class with this name exists or already renamed
cls
.
remove
(
AType
.
SOURCE_FILE
);
return
name
;
}
return
null
;
}
@Nullable
public
String
getFieldAlias
(
FieldNode
field
)
{
FieldInfo
fieldInfo
=
field
.
getFieldInfo
();
String
alias
=
fldMap
.
get
(
fieldInfo
);
...
...
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