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
3c84975a
Commit
3c84975a
authored
Feb 22, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code style issues
parent
bb4ef4f0
Show whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
352 additions
and
367 deletions
+352
-367
JadxCLIArgs.java
jadx-cli/src/main/java/jadx/cli/JadxCLIArgs.java
+13
-11
Decompiler.java
jadx-core/src/main/java/jadx/api/Decompiler.java
+11
-12
Jadx.java
jadx-core/src/main/java/jadx/core/Jadx.java
+2
-2
ProcessClass.java
jadx-core/src/main/java/jadx/core/ProcessClass.java
+5
-9
AnnotationGen.java
jadx-core/src/main/java/jadx/core/codegen/AnnotationGen.java
+1
-1
ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+4
-5
CodeWriter.java
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
+2
-2
ConditionGen.java
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
+1
-1
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+4
-3
MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+3
-2
RegionGen.java
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
+39
-107
NameMapper.java
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
+2
-1
AttributeFlag.java
...src/main/java/jadx/core/dex/attributes/AttributeFlag.java
+2
-0
AttributeType.java
...src/main/java/jadx/core/dex/attributes/AttributeType.java
+2
-1
BlockRegState.java
...src/main/java/jadx/core/dex/attributes/BlockRegState.java
+1
-1
DeclareVariablesAttr.java
...n/java/jadx/core/dex/attributes/DeclareVariablesAttr.java
+33
-0
JadxErrorAttr.java
...src/main/java/jadx/core/dex/attributes/JadxErrorAttr.java
+1
-1
JumpAttribute.java
...src/main/java/jadx/core/dex/attributes/JumpAttribute.java
+1
-5
ClassInfo.java
jadx-core/src/main/java/jadx/core/dex/info/ClassInfo.java
+14
-14
MethodInfo.java
jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java
+3
-5
ArgType.java
...rc/main/java/jadx/core/dex/instructions/args/ArgType.java
+1
-1
RegisterArg.java
...ain/java/jadx/core/dex/instructions/args/RegisterArg.java
+2
-8
TypedVar.java
...c/main/java/jadx/core/dex/instructions/args/TypedVar.java
+3
-3
ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+1
-1
InsnNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
+3
-5
RootNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
+1
-1
AnnotationsParser.java
...in/java/jadx/core/dex/nodes/parser/AnnotationsParser.java
+17
-6
DebugInfoParser.java
...main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
+17
-12
LoopRegion.java
...-core/src/main/java/jadx/core/dex/regions/LoopRegion.java
+2
-2
TernaryRegion.java
...re/src/main/java/jadx/core/dex/regions/TernaryRegion.java
+1
-1
BlockMakerVisitor.java
...c/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
+11
-10
ClassModifier.java
...e/src/main/java/jadx/core/dex/visitors/ClassModifier.java
+8
-10
CodeShrinker.java
...re/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
+2
-4
ConstInlinerVisitor.java
...main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
+2
-4
DotGraphVisitor.java
...src/main/java/jadx/core/dex/visitors/DotGraphVisitor.java
+4
-11
MethodInlineVisitor.java
...main/java/jadx/core/dex/visitors/MethodInlineVisitor.java
+10
-7
ModVisitor.java
...core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
+4
-4
CheckRegions.java
...ain/java/jadx/core/dex/visitors/regions/CheckRegions.java
+5
-12
ProcessTryCatchRegions.java
...adx/core/dex/visitors/regions/ProcessTryCatchRegions.java
+2
-2
ProcessVariables.java
...java/jadx/core/dex/visitors/regions/ProcessVariables.java
+7
-7
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+6
-6
TracedRegionVisitor.java
...a/jadx/core/dex/visitors/regions/TracedRegionVisitor.java
+1
-1
TypeResolver.java
...ava/jadx/core/dex/visitors/typeresolver/TypeResolver.java
+7
-8
CheckTypeVisitor.java
...re/dex/visitors/typeresolver/finish/CheckTypeVisitor.java
+4
-5
BlockUtils.java
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
+4
-11
ErrorsCounter.java
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
+1
-1
InsnUtils.java
jadx-core/src/main/java/jadx/core/utils/InsnUtils.java
+1
-1
RegionUtils.java
jadx-core/src/main/java/jadx/core/utils/RegionUtils.java
+3
-5
InternalJadxTest.java
jadx-core/src/test/java/jadx/api/InternalJadxTest.java
+3
-0
TestSyntheticInline.java
.../java/jadx/tests/internal/inline/TestSyntheticInline.java
+49
-0
JClass.java
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
+5
-6
JField.java
jadx-gui/src/main/java/jadx/gui/treemodel/JField.java
+0
-4
JMethod.java
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
+0
-4
JNode.java
jadx-gui/src/main/java/jadx/gui/treemodel/JNode.java
+0
-2
JPackage.java
jadx-gui/src/main/java/jadx/gui/treemodel/JPackage.java
+4
-5
JRoot.java
jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java
+5
-6
TextNode.java
jadx-gui/src/main/java/jadx/gui/treemodel/TextNode.java
+0
-4
Utils.java
jadx-gui/src/main/java/jadx/gui/utils/Utils.java
+12
-4
No files found.
jadx-cli/src/main/java/jadx/cli/JadxCLIArgs.java
View file @
3c84975a
...
@@ -68,25 +68,25 @@ public final class JadxCLIArgs implements IJadxArgs {
...
@@ -68,25 +68,25 @@ public final class JadxCLIArgs implements IJadxArgs {
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
try
{
try
{
if
(
threadsCount
<=
0
)
if
(
threadsCount
<=
0
)
{
throw
new
JadxException
(
"Threads count must be positive"
);
throw
new
JadxException
(
"Threads count must be positive"
);
}
if
(
files
!=
null
)
{
if
(
files
!=
null
)
{
for
(
String
fileName
:
files
)
{
for
(
String
fileName
:
files
)
{
File
file
=
new
File
(
fileName
);
File
file
=
new
File
(
fileName
);
if
(
file
.
exists
())
if
(
file
.
exists
())
{
input
.
add
(
file
);
input
.
add
(
file
);
else
}
else
{
throw
new
JadxException
(
"File not found: "
+
file
);
throw
new
JadxException
(
"File not found: "
+
file
);
}
}
}
}
}
if
(
input
.
size
()
>
1
)
if
(
input
.
size
()
>
1
)
{
throw
new
JadxException
(
"Only one input file is supported"
);
throw
new
JadxException
(
"Only one input file is supported"
);
}
if
(
outDirName
!=
null
)
if
(
outDirName
!=
null
)
{
outputDir
=
new
File
(
outDirName
);
outputDir
=
new
File
(
outDirName
);
}
if
(
isVerbose
())
{
if
(
isVerbose
())
{
ch
.
qos
.
logback
.
classic
.
Logger
rootLogger
=
ch
.
qos
.
logback
.
classic
.
Logger
rootLogger
=
(
ch
.
qos
.
logback
.
classic
.
Logger
)
LoggerFactory
.
getLogger
(
Logger
.
ROOT_LOGGER_NAME
);
(
ch
.
qos
.
logback
.
classic
.
Logger
)
LoggerFactory
.
getLogger
(
Logger
.
ROOT_LOGGER_NAME
);
...
@@ -114,9 +114,10 @@ public final class JadxCLIArgs implements IJadxArgs {
...
@@ -114,9 +114,10 @@ public final class JadxCLIArgs implements IJadxArgs {
int
maxNamesLen
=
0
;
int
maxNamesLen
=
0
;
for
(
ParameterDescription
p
:
params
)
{
for
(
ParameterDescription
p
:
params
)
{
int
len
=
p
.
getNames
().
length
();
int
len
=
p
.
getNames
().
length
();
if
(
len
>
maxNamesLen
)
if
(
len
>
maxNamesLen
)
{
maxNamesLen
=
len
;
maxNamesLen
=
len
;
}
}
}
Field
[]
fields
=
this
.
getClass
().
getDeclaredFields
();
Field
[]
fields
=
this
.
getClass
().
getDeclaredFields
();
for
(
Field
f
:
fields
)
{
for
(
Field
f
:
fields
)
{
...
@@ -137,9 +138,10 @@ public final class JadxCLIArgs implements IJadxArgs {
...
@@ -137,9 +138,10 @@ public final class JadxCLIArgs implements IJadxArgs {
}
}
private
static
void
addSpaces
(
StringBuilder
str
,
int
count
)
{
private
static
void
addSpaces
(
StringBuilder
str
,
int
count
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
str
.
append
(
' '
);
str
.
append
(
' '
);
}
}
}
public
List
<
File
>
getInput
()
{
public
List
<
File
>
getInput
()
{
return
input
;
return
input
;
...
...
jadx-core/src/main/java/jadx/api/Decompiler.java
View file @
3c84975a
...
@@ -16,7 +16,6 @@ import jadx.core.utils.files.InputFile;
...
@@ -16,7 +16,6 @@ import jadx.core.utils.files.InputFile;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -80,7 +79,7 @@ public final class Decompiler {
...
@@ -80,7 +79,7 @@ public final class Decompiler {
}
}
public
void
loadFile
(
File
file
)
throws
IOException
,
DecodeException
{
public
void
loadFile
(
File
file
)
throws
IOException
,
DecodeException
{
loadFiles
(
Arrays
.
as
List
(
file
));
loadFiles
(
Collections
.
singleton
List
(
file
));
}
}
public
void
loadFiles
(
List
<
File
>
files
)
throws
IOException
,
DecodeException
{
public
void
loadFiles
(
List
<
File
>
files
)
throws
IOException
,
DecodeException
{
...
@@ -110,15 +109,20 @@ public final class Decompiler {
...
@@ -110,15 +109,20 @@ public final class Decompiler {
int
threadsCount
=
args
.
getThreadsCount
();
int
threadsCount
=
args
.
getThreadsCount
();
LOG
.
debug
(
"processing threads count: {}"
,
threadsCount
);
LOG
.
debug
(
"processing threads count: {}"
,
threadsCount
);
Array
List
<
IDexTreeVisitor
>
passList
=
new
ArrayList
<
IDexTreeVisitor
>(
passes
);
final
List
<
IDexTreeVisitor
>
passList
=
new
ArrayList
<
IDexTreeVisitor
>(
passes
);
SaveCode
savePass
=
new
SaveCode
(
outDir
,
args
);
SaveCode
savePass
=
new
SaveCode
(
outDir
,
args
);
passList
.
add
(
savePass
);
passList
.
add
(
savePass
);
LOG
.
info
(
"processing ..."
);
LOG
.
info
(
"processing ..."
);
ThreadPoolExecutor
executor
=
(
ThreadPoolExecutor
)
Executors
.
newFixedThreadPool
(
threadsCount
);
ThreadPoolExecutor
executor
=
(
ThreadPoolExecutor
)
Executors
.
newFixedThreadPool
(
threadsCount
);
for
(
ClassNode
cls
:
root
.
getClasses
(
false
))
{
for
(
final
ClassNode
cls
:
root
.
getClasses
(
false
))
{
if
(
cls
.
getCode
()
==
null
)
{
if
(
cls
.
getCode
()
==
null
)
{
ProcessClass
job
=
new
ProcessClass
(
cls
,
passList
);
Runnable
job
=
new
Runnable
()
{
@Override
public
void
run
()
{
ProcessClass
.
process
(
cls
,
passList
);
}
};
executor
.
execute
(
job
);
executor
.
execute
(
job
);
}
else
{
}
else
{
try
{
try
{
...
@@ -183,13 +187,8 @@ public final class Decompiler {
...
@@ -183,13 +187,8 @@ public final class Decompiler {
}
}
void
processClass
(
ClassNode
cls
)
{
void
processClass
(
ClassNode
cls
)
{
try
{
ProcessClass
job
=
new
ProcessClass
(
cls
,
passes
);
LOG
.
info
(
"processing class {} ..."
,
cls
);
LOG
.
info
(
"processing class {} ..."
,
cls
);
job
.
run
();
ProcessClass
.
process
(
cls
,
passes
);
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Process class error"
,
e
);
}
}
}
RootNode
getRoot
()
{
RootNode
getRoot
()
{
...
...
jadx-core/src/main/java/jadx/core/Jadx.java
View file @
3c84975a
...
@@ -10,7 +10,7 @@ import jadx.core.dex.visitors.DotGraphVisitor;
...
@@ -10,7 +10,7 @@ import jadx.core.dex.visitors.DotGraphVisitor;
import
jadx.core.dex.visitors.EnumVisitor
;
import
jadx.core.dex.visitors.EnumVisitor
;
import
jadx.core.dex.visitors.FallbackModeVisitor
;
import
jadx.core.dex.visitors.FallbackModeVisitor
;
import
jadx.core.dex.visitors.IDexTreeVisitor
;
import
jadx.core.dex.visitors.IDexTreeVisitor
;
import
jadx.core.dex.visitors.MethodInline
r
Visitor
;
import
jadx.core.dex.visitors.MethodInlineVisitor
;
import
jadx.core.dex.visitors.ModVisitor
;
import
jadx.core.dex.visitors.ModVisitor
;
import
jadx.core.dex.visitors.SimplifyVisitor
;
import
jadx.core.dex.visitors.SimplifyVisitor
;
import
jadx.core.dex.visitors.regions.CheckRegions
;
import
jadx.core.dex.visitors.regions.CheckRegions
;
...
@@ -79,7 +79,7 @@ public class Jadx {
...
@@ -79,7 +79,7 @@ public class Jadx {
passes
.
add
(
new
DotGraphVisitor
(
outDir
,
true
));
passes
.
add
(
new
DotGraphVisitor
(
outDir
,
true
));
}
}
passes
.
add
(
new
MethodInline
r
Visitor
());
passes
.
add
(
new
MethodInlineVisitor
());
passes
.
add
(
new
ClassModifier
());
passes
.
add
(
new
ClassModifier
());
}
}
passes
.
add
(
new
CodeGen
(
args
));
passes
.
add
(
new
CodeGen
(
args
));
...
...
jadx-core/src/main/java/jadx/core/ProcessClass.java
View file @
3c84975a
...
@@ -10,19 +10,13 @@ import java.util.List;
...
@@ -10,19 +10,13 @@ import java.util.List;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
public
final
class
ProcessClass
implements
Runnable
{
public
final
class
ProcessClass
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ProcessClass
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ProcessClass
.
class
);
private
final
ClassNode
cls
;
private
ProcessClass
()
{
private
final
List
<
IDexTreeVisitor
>
passes
;
public
ProcessClass
(
ClassNode
cls
,
List
<
IDexTreeVisitor
>
passes
)
{
this
.
cls
=
cls
;
this
.
passes
=
passes
;
}
}
@Override
public
static
void
process
(
ClassNode
cls
,
List
<
IDexTreeVisitor
>
passes
)
{
public
void
run
()
{
try
{
try
{
cls
.
load
();
cls
.
load
();
for
(
IDexTreeVisitor
visitor
:
passes
)
{
for
(
IDexTreeVisitor
visitor
:
passes
)
{
...
@@ -30,6 +24,8 @@ public final class ProcessClass implements Runnable {
...
@@ -30,6 +24,8 @@ public final class ProcessClass implements Runnable {
}
}
}
catch
(
DecodeException
e
)
{
}
catch
(
DecodeException
e
)
{
LOG
.
error
(
"Decode exception: "
+
cls
,
e
);
LOG
.
error
(
"Decode exception: "
+
cls
,
e
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Class process exception: "
+
cls
,
e
);
}
finally
{
}
finally
{
cls
.
unload
();
cls
.
unload
();
}
}
...
...
jadx-core/src/main/java/jadx/core/codegen/AnnotationGen.java
View file @
3c84975a
...
@@ -76,7 +76,7 @@ public class AnnotationGen {
...
@@ -76,7 +76,7 @@ public class AnnotationGen {
code
.
add
(
'@'
);
code
.
add
(
'@'
);
code
.
add
(
classGen
.
useClass
(
a
.
getType
()));
code
.
add
(
classGen
.
useClass
(
a
.
getType
()));
Map
<
String
,
Object
>
vl
=
a
.
getValues
();
Map
<
String
,
Object
>
vl
=
a
.
getValues
();
if
(
vl
.
size
()
!=
0
)
{
if
(
!
vl
.
isEmpty
()
)
{
code
.
add
(
'('
);
code
.
add
(
'('
);
if
(
vl
.
size
()
==
1
&&
vl
.
containsKey
(
"value"
))
{
if
(
vl
.
size
()
==
1
&&
vl
.
containsKey
(
"value"
))
{
code
.
add
(
encValueToString
(
vl
.
get
(
"value"
)));
code
.
add
(
encValueToString
(
vl
.
get
(
"value"
)));
...
...
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
View file @
3c84975a
...
@@ -379,13 +379,12 @@ public class ClassGen {
...
@@ -379,13 +379,12 @@ public class ClassGen {
if
(
searchCollision
(
cls
.
dex
(),
useCls
,
shortName
))
{
if
(
searchCollision
(
cls
.
dex
(),
useCls
,
shortName
))
{
return
clsStr
;
return
clsStr
;
}
}
for
(
ClassInfo
c
ls
:
imports
)
{
for
(
ClassInfo
importC
ls
:
imports
)
{
if
(!
cls
.
equals
(
classInfo
))
{
if
(!
importCls
.
equals
(
classInfo
)
if
(
c
ls
.
getShortName
().
equals
(
shortName
))
{
&&
importC
ls
.
getShortName
().
equals
(
shortName
))
{
return
clsStr
;
return
clsStr
;
}
}
}
}
}
addImport
(
classInfo
);
addImport
(
classInfo
);
return
shortName
;
return
shortName
;
}
}
...
...
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
View file @
3c84975a
...
@@ -82,7 +82,7 @@ public class CodeWriter {
...
@@ -82,7 +82,7 @@ public class CodeWriter {
attachAnnotation
(
entry
.
getKey
(),
line
+
entry
.
getValue
());
attachAnnotation
(
entry
.
getKey
(),
line
+
entry
.
getValue
());
}
}
line
+=
code
.
line
;
line
+=
code
.
line
;
buf
.
append
(
code
.
toString
()
);
buf
.
append
(
code
);
return
this
;
return
this
;
}
}
...
@@ -116,7 +116,7 @@ public class CodeWriter {
...
@@ -116,7 +116,7 @@ public class CodeWriter {
return
this
;
return
this
;
}
}
private
static
final
String
[]
INDENT_CACHE
=
new
String
[]
{
private
static
final
String
[]
INDENT_CACHE
=
{
""
,
""
,
INDENT
,
INDENT
,
INDENT
+
INDENT
,
INDENT
+
INDENT
,
...
...
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
View file @
3c84975a
...
@@ -42,7 +42,7 @@ public class ConditionGen {
...
@@ -42,7 +42,7 @@ public class ConditionGen {
}
}
return
sb
.
toString
();
return
sb
.
toString
();
default
:
default
:
return
"??"
+
condition
.
toString
()
;
return
"??"
+
condition
;
}
}
}
}
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
3c84975a
...
@@ -114,7 +114,7 @@ public class InsnGen {
...
@@ -114,7 +114,7 @@ public class InsnGen {
public
String
assignVar
(
InsnNode
insn
)
throws
CodegenException
{
public
String
assignVar
(
InsnNode
insn
)
throws
CodegenException
{
RegisterArg
arg
=
insn
.
getResult
();
RegisterArg
arg
=
insn
.
getResult
();
if
(
insn
.
getAttributes
().
contains
(
Attribute
Type
.
DECLARE_VARIABLE
))
{
if
(
insn
.
getAttributes
().
contains
(
Attribute
Flag
.
DECLARE_VAR
))
{
return
declareVar
(
arg
);
return
declareVar
(
arg
);
}
else
{
}
else
{
return
arg
(
arg
).
toString
();
return
arg
(
arg
).
toString
();
...
@@ -125,7 +125,7 @@ public class InsnGen {
...
@@ -125,7 +125,7 @@ public class InsnGen {
return
useType
(
arg
.
getType
())
+
" "
+
mgen
.
assignArg
(
arg
);
return
useType
(
arg
.
getType
())
+
" "
+
mgen
.
assignArg
(
arg
);
}
}
private
String
lit
(
LiteralArg
arg
)
{
private
static
String
lit
(
LiteralArg
arg
)
{
return
TypeGen
.
literalToString
(
arg
.
getLiteral
(),
arg
.
getType
());
return
TypeGen
.
literalToString
(
arg
.
getLiteral
(),
arg
.
getType
());
}
}
...
@@ -483,7 +483,8 @@ public class InsnGen {
...
@@ -483,7 +483,8 @@ public class InsnGen {
if
(!
elType
.
equals
(
insnElementType
)
&&
!
insnArrayType
.
equals
(
ArgType
.
OBJECT
))
{
if
(!
elType
.
equals
(
insnElementType
)
&&
!
insnArrayType
.
equals
(
ArgType
.
OBJECT
))
{
ErrorsCounter
.
methodError
(
mth
,
ErrorsCounter
.
methodError
(
mth
,
"Incorrect type for fill-array insn "
+
InsnUtils
.
formatOffset
(
insn
.
getOffset
())
"Incorrect type for fill-array insn "
+
InsnUtils
.
formatOffset
(
insn
.
getOffset
())
+
", element type: "
+
elType
+
", insn element type: "
+
insnElementType
);
+
", element type: "
+
elType
+
", insn element type: "
+
insnElementType
);
if
(!
elType
.
isTypeKnown
())
{
if
(!
elType
.
isTypeKnown
())
{
elType
=
insnElementType
.
isTypeKnown
()
?
insnElementType
:
elType
.
selectFirst
();
elType
=
insnElementType
.
isTypeKnown
()
?
insnElementType
:
elType
.
selectFirst
();
}
}
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
View file @
3c84975a
...
@@ -105,7 +105,8 @@ public class MethodGen {
...
@@ -105,7 +105,8 @@ public class MethodGen {
}
else
{
}
else
{
LOG
.
warn
(
ErrorsCounter
.
formatErrorMsg
(
mth
,
LOG
.
warn
(
ErrorsCounter
.
formatErrorMsg
(
mth
,
"Incorrect number of args for enum constructor: "
+
args
.
size
()
"Incorrect number of args for enum constructor: "
+
args
.
size
()
+
" (expected >= 2)"
));
+
" (expected >= 2)"
));
}
}
}
}
code
.
add
(
makeArguments
(
args
));
code
.
add
(
makeArguments
(
args
));
...
@@ -269,7 +270,7 @@ public class MethodGen {
...
@@ -269,7 +270,7 @@ public class MethodGen {
code
.
startLine
(
"*/"
);
code
.
startLine
(
"*/"
);
}
}
private
void
makeFallbackMethod
(
CodeWriter
code
,
MethodNode
mth
)
{
private
static
void
makeFallbackMethod
(
CodeWriter
code
,
MethodNode
mth
)
{
if
(
mth
.
getInstructions
()
==
null
)
{
if
(
mth
.
getInstructions
()
==
null
)
{
// loadFile original instructions
// loadFile original instructions
try
{
try
{
...
...
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
View file @
3c84975a
...
@@ -2,19 +2,13 @@ package jadx.core.codegen;
...
@@ -2,19 +2,13 @@ package jadx.core.codegen;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.attributes.DeclareVariableAttr
;
import
jadx.core.dex.attributes.DeclareVariable
s
Attr
;
import
jadx.core.dex.attributes.ForceReturnAttr
;
import
jadx.core.dex.attributes.ForceReturnAttr
;
import
jadx.core.dex.attributes.IAttribute
;
import
jadx.core.dex.attributes.IAttribute
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.instructions.ArithNode
;
import
jadx.core.dex.instructions.IfOp
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.SwitchNode
;
import
jadx.core.dex.instructions.SwitchNode
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
import
jadx.core.dex.instructions.args.LiteralArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.IBlock
;
import
jadx.core.dex.nodes.IBlock
;
...
@@ -22,7 +16,6 @@ import jadx.core.dex.nodes.IContainer;
...
@@ -22,7 +16,6 @@ import jadx.core.dex.nodes.IContainer;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.Compare
;
import
jadx.core.dex.regions.IfCondition
;
import
jadx.core.dex.regions.IfCondition
;
import
jadx.core.dex.regions.IfRegion
;
import
jadx.core.dex.regions.IfRegion
;
import
jadx.core.dex.regions.LoopRegion
;
import
jadx.core.dex.regions.LoopRegion
;
...
@@ -32,7 +25,6 @@ import jadx.core.dex.regions.SynchronizedRegion;
...
@@ -32,7 +25,6 @@ import jadx.core.dex.regions.SynchronizedRegion;
import
jadx.core.dex.trycatch.CatchAttr
;
import
jadx.core.dex.trycatch.CatchAttr
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
import
jadx.core.dex.trycatch.TryCatchBlock
;
import
jadx.core.dex.trycatch.TryCatchBlock
;
import
jadx.core.utils.ErrorsCounter
;
import
jadx.core.utils.RegionUtils
;
import
jadx.core.utils.RegionUtils
;
import
jadx.core.utils.exceptions.CodegenException
;
import
jadx.core.utils.exceptions.CodegenException
;
...
@@ -49,22 +41,12 @@ public class RegionGen extends InsnGen {
...
@@ -49,22 +41,12 @@ public class RegionGen extends InsnGen {
}
}
public
void
makeRegion
(
CodeWriter
code
,
IContainer
cont
)
throws
CodegenException
{
public
void
makeRegion
(
CodeWriter
code
,
IContainer
cont
)
throws
CodegenException
{
assert
cont
!=
null
;
if
(
cont
instanceof
IBlock
)
{
if
(
cont
instanceof
IBlock
)
{
makeSimpleBlock
((
IBlock
)
cont
,
code
);
makeSimpleBlock
((
IBlock
)
cont
,
code
);
}
else
if
(
cont
instanceof
IRegion
)
{
}
else
if
(
cont
instanceof
IRegion
)
{
declareVars
(
code
,
cont
);
declareVars
(
code
,
cont
);
if
(
cont
instanceof
Region
)
{
if
(
cont
instanceof
Region
)
{
Region
r
=
(
Region
)
cont
;
makeSimpleRegion
(
code
,
(
Region
)
cont
);
CatchAttr
tc
=
(
CatchAttr
)
r
.
getAttributes
().
get
(
AttributeType
.
CATCH_BLOCK
);
if
(
tc
!=
null
)
{
makeTryCatch
(
cont
,
tc
.
getTryBlock
(),
code
);
}
else
{
for
(
IContainer
c
:
r
.
getSubBlocks
())
{
makeRegion
(
code
,
c
);
}
}
}
else
if
(
cont
instanceof
IfRegion
)
{
}
else
if
(
cont
instanceof
IfRegion
)
{
makeIf
((
IfRegion
)
cont
,
code
,
true
);
makeIf
((
IfRegion
)
cont
,
code
,
true
);
}
else
if
(
cont
instanceof
SwitchRegion
)
{
}
else
if
(
cont
instanceof
SwitchRegion
)
{
...
@@ -75,13 +57,13 @@ public class RegionGen extends InsnGen {
...
@@ -75,13 +57,13 @@ public class RegionGen extends InsnGen {
makeSynchronizedRegion
((
SynchronizedRegion
)
cont
,
code
);
makeSynchronizedRegion
((
SynchronizedRegion
)
cont
,
code
);
}
}
}
else
{
}
else
{
throw
new
CodegenException
(
"Not processed container: "
+
cont
.
toString
()
);
throw
new
CodegenException
(
"Not processed container: "
+
cont
);
}
}
}
}
private
void
declareVars
(
CodeWriter
code
,
IContainer
cont
)
{
private
void
declareVars
(
CodeWriter
code
,
IContainer
cont
)
{
DeclareVariableAttr
declVars
=
DeclareVariable
s
Attr
declVars
=
(
DeclareVariable
Attr
)
cont
.
getAttributes
().
get
(
AttributeType
.
DECLARE_VARIABLE
);
(
DeclareVariable
sAttr
)
cont
.
getAttributes
().
get
(
AttributeType
.
DECLARE_VARIABLES
);
if
(
declVars
!=
null
)
{
if
(
declVars
!=
null
)
{
for
(
RegisterArg
v
:
declVars
.
getVars
())
{
for
(
RegisterArg
v
:
declVars
.
getVars
())
{
code
.
startLine
(
declareVar
(
v
)).
add
(
';'
);
code
.
startLine
(
declareVar
(
v
)).
add
(
';'
);
...
@@ -89,6 +71,17 @@ public class RegionGen extends InsnGen {
...
@@ -89,6 +71,17 @@ public class RegionGen extends InsnGen {
}
}
}
}
private
void
makeSimpleRegion
(
CodeWriter
code
,
Region
region
)
throws
CodegenException
{
CatchAttr
tc
=
(
CatchAttr
)
region
.
getAttributes
().
get
(
AttributeType
.
CATCH_BLOCK
);
if
(
tc
!=
null
)
{
makeTryCatch
(
region
,
tc
.
getTryBlock
(),
code
);
}
else
{
for
(
IContainer
c
:
region
.
getSubBlocks
())
{
makeRegion
(
code
,
c
);
}
}
}
public
void
makeRegionIndent
(
CodeWriter
code
,
IContainer
region
)
throws
CodegenException
{
public
void
makeRegionIndent
(
CodeWriter
code
,
IContainer
region
)
throws
CodegenException
{
code
.
incIndent
();
code
.
incIndent
();
makeRegion
(
code
,
region
);
makeRegion
(
code
,
region
);
...
@@ -125,8 +118,19 @@ public class RegionGen extends InsnGen {
...
@@ -125,8 +118,19 @@ public class RegionGen extends InsnGen {
IContainer
els
=
region
.
getElseRegion
();
IContainer
els
=
region
.
getElseRegion
();
if
(
els
!=
null
&&
RegionUtils
.
notEmpty
(
els
))
{
if
(
els
!=
null
&&
RegionUtils
.
notEmpty
(
els
))
{
code
.
add
(
" else "
);
code
.
add
(
" else "
);
if
(
connectElseIf
(
code
,
els
))
{
return
;
}
code
.
add
(
'{'
);
makeRegionIndent
(
code
,
els
);
code
.
startLine
(
'}'
);
}
}
// connect if-else-if block
/**
* Connect if-else-if block
*/
private
boolean
connectElseIf
(
CodeWriter
code
,
IContainer
els
)
throws
CodegenException
{
if
(
els
instanceof
Region
)
{
if
(
els
instanceof
Region
)
{
Region
re
=
(
Region
)
els
;
Region
re
=
(
Region
)
els
;
List
<
IContainer
>
subBlocks
=
re
.
getSubBlocks
();
List
<
IContainer
>
subBlocks
=
re
.
getSubBlocks
();
...
@@ -134,15 +138,11 @@ public class RegionGen extends InsnGen {
...
@@ -134,15 +138,11 @@ public class RegionGen extends InsnGen {
IfRegion
ifRegion
=
(
IfRegion
)
subBlocks
.
get
(
0
);
IfRegion
ifRegion
=
(
IfRegion
)
subBlocks
.
get
(
0
);
if
(
ifRegion
.
getAttributes
().
contains
(
AttributeFlag
.
ELSE_IF_CHAIN
))
{
if
(
ifRegion
.
getAttributes
().
contains
(
AttributeFlag
.
ELSE_IF_CHAIN
))
{
makeIf
(
ifRegion
,
code
,
false
);
makeIf
(
ifRegion
,
code
,
false
);
return
;
return
true
;
}
}
}
}
}
code
.
add
(
'{'
);
makeRegionIndent
(
code
,
els
);
code
.
startLine
(
'}'
);
}
}
return
false
;
}
}
private
CodeWriter
makeLoop
(
LoopRegion
region
,
CodeWriter
code
)
throws
CodegenException
{
private
CodeWriter
makeLoop
(
LoopRegion
region
,
CodeWriter
code
)
throws
CodegenException
{
...
@@ -152,7 +152,8 @@ public class RegionGen extends InsnGen {
...
@@ -152,7 +152,8 @@ public class RegionGen extends InsnGen {
if
(
headerInsns
.
size
()
>
1
)
{
if
(
headerInsns
.
size
()
>
1
)
{
// write not inlined instructions from header
// write not inlined instructions from header
mth
.
getAttributes
().
add
(
AttributeFlag
.
INCONSISTENT_CODE
);
mth
.
getAttributes
().
add
(
AttributeFlag
.
INCONSISTENT_CODE
);
for
(
int
i
=
0
;
i
<
headerInsns
.
size
()
-
1
;
i
++)
{
int
last
=
headerInsns
.
size
()
-
1
;
for
(
int
i
=
0
;
i
<
last
;
i
++)
{
InsnNode
insn
=
headerInsns
.
get
(
i
);
InsnNode
insn
=
headerInsns
.
get
(
i
);
makeInsn
(
insn
,
code
);
makeInsn
(
insn
,
code
);
}
}
...
@@ -187,75 +188,6 @@ public class RegionGen extends InsnGen {
...
@@ -187,75 +188,6 @@ public class RegionGen extends InsnGen {
code
.
startLine
(
'}'
);
code
.
startLine
(
'}'
);
}
}
private
String
makeCondition
(
IfCondition
condition
)
throws
CodegenException
{
switch
(
condition
.
getMode
())
{
case
COMPARE:
return
makeCompare
(
condition
.
getCompare
());
case
NOT:
return
"!"
+
makeCondition
(
condition
.
getArgs
().
get
(
0
));
case
AND:
case
OR:
String
mode
=
condition
.
getMode
()
==
IfCondition
.
Mode
.
AND
?
" && "
:
" || "
;
StringBuilder
sb
=
new
StringBuilder
();
for
(
IfCondition
arg
:
condition
.
getArgs
())
{
if
(
sb
.
length
()
!=
0
)
{
sb
.
append
(
mode
);
}
String
s
=
makeCondition
(
arg
);
if
(
arg
.
isCompare
())
{
sb
.
append
(
s
);
}
else
{
sb
.
append
(
'('
).
append
(
s
).
append
(
')'
);
}
}
return
sb
.
toString
();
default
:
return
"??"
+
condition
.
toString
();
}
}
private
String
makeCompare
(
Compare
compare
)
throws
CodegenException
{
IfOp
op
=
compare
.
getOp
();
InsnArg
firstArg
=
compare
.
getA
();
InsnArg
secondArg
=
compare
.
getB
();
if
(
firstArg
.
getType
().
equals
(
ArgType
.
BOOLEAN
)
&&
secondArg
.
isLiteral
()
&&
secondArg
.
getType
().
equals
(
ArgType
.
BOOLEAN
))
{
LiteralArg
lit
=
(
LiteralArg
)
secondArg
;
if
(
lit
.
getLiteral
()
==
0
)
{
op
=
op
.
invert
();
}
if
(
op
==
IfOp
.
EQ
)
{
return
arg
(
firstArg
,
false
).
toString
();
// == true
}
else
if
(
op
==
IfOp
.
NE
)
{
return
"!"
+
arg
(
firstArg
);
// != true
}
LOG
.
warn
(
ErrorsCounter
.
formatErrorMsg
(
mth
,
"Unsupported boolean condition "
+
op
.
getSymbol
()));
}
return
arg
(
firstArg
,
isWrapNeeded
(
firstArg
))
+
" "
+
op
.
getSymbol
()
+
" "
+
arg
(
secondArg
,
isWrapNeeded
(
secondArg
));
}
private
boolean
isWrapNeeded
(
InsnArg
arg
)
{
if
(!
arg
.
isInsnWrap
())
{
return
false
;
}
InsnNode
insn
=
((
InsnWrapArg
)
arg
).
getWrapInsn
();
if
(
insn
.
getType
()
==
InsnType
.
ARITH
)
{
ArithNode
arith
=
((
ArithNode
)
insn
);
switch
(
arith
.
getOp
())
{
case
ADD:
case
SUB:
case
MUL:
case
DIV:
case
REM:
return
false
;
}
}
return
true
;
}
private
CodeWriter
makeSwitch
(
SwitchRegion
sw
,
CodeWriter
code
)
throws
CodegenException
{
private
CodeWriter
makeSwitch
(
SwitchRegion
sw
,
CodeWriter
code
)
throws
CodegenException
{
SwitchNode
insn
=
(
SwitchNode
)
sw
.
getHeader
().
getInstructions
().
get
(
0
);
SwitchNode
insn
=
(
SwitchNode
)
sw
.
getHeader
().
getInstructions
().
get
(
0
);
InsnArg
arg
=
insn
.
getArg
(
0
);
InsnArg
arg
=
insn
.
getArg
(
0
);
...
@@ -324,7 +256,7 @@ public class RegionGen extends InsnGen {
...
@@ -324,7 +256,7 @@ public class RegionGen extends InsnGen {
private
void
makeCatchBlock
(
CodeWriter
code
,
ExceptionHandler
handler
)
private
void
makeCatchBlock
(
CodeWriter
code
,
ExceptionHandler
handler
)
throws
CodegenException
{
throws
CodegenException
{
IContainer
region
=
handler
.
getHandlerRegion
();
IContainer
region
=
handler
.
getHandlerRegion
();
if
(
region
!=
null
/* && RegionUtils.notEmpty(region) */
)
{
if
(
region
!=
null
)
{
code
.
startLine
(
"} catch ("
);
code
.
startLine
(
"} catch ("
);
code
.
add
(
handler
.
isCatchAll
()
?
"Throwable"
:
useClass
(
handler
.
getCatchType
()));
code
.
add
(
handler
.
isCatchAll
()
?
"Throwable"
:
useClass
(
handler
.
getCatchType
()));
code
.
add
(
' '
);
code
.
add
(
' '
);
...
...
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
View file @
3c84975a
...
@@ -61,7 +61,8 @@ public class NameMapper {
...
@@ -61,7 +61,8 @@ public class NameMapper {
"void"
,
"void"
,
"volatile"
,
"volatile"
,
"while"
,
"while"
,
}));
})
);
public
static
boolean
isReserved
(
String
str
)
{
public
static
boolean
isReserved
(
String
str
)
{
return
RESERVED_NAMES
.
contains
(
str
);
return
RESERVED_NAMES
.
contains
(
str
);
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/AttributeFlag.java
View file @
3c84975a
...
@@ -12,6 +12,8 @@ public enum AttributeFlag {
...
@@ -12,6 +12,8 @@ public enum AttributeFlag {
BREAK
,
BREAK
,
RETURN
,
// block contains only return instruction
RETURN
,
// block contains only return instruction
DECLARE_VAR
,
DONT_SHRINK
,
DONT_SHRINK
,
DONT_GENERATE
,
DONT_GENERATE
,
SKIP
,
SKIP
,
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/AttributeType.java
View file @
3c84975a
...
@@ -27,7 +27,8 @@ public enum AttributeType {
...
@@ -27,7 +27,8 @@ public enum AttributeType {
SOURCE_FILE
(
true
),
SOURCE_FILE
(
true
),
DECLARE_VARIABLE
(
true
);
// for regions
DECLARE_VARIABLES
(
true
);
private
static
final
int
NOT_UNIQ_COUNT
;
private
static
final
int
NOT_UNIQ_COUNT
;
private
final
boolean
uniq
;
private
final
boolean
uniq
;
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/BlockRegState.java
View file @
3c84975a
...
@@ -48,7 +48,7 @@ public final class BlockRegState {
...
@@ -48,7 +48,7 @@ public final class BlockRegState {
if
(
str
.
length
()
!=
0
)
{
if
(
str
.
length
()
!=
0
)
{
str
.
append
(
", "
);
str
.
append
(
", "
);
}
}
str
.
append
(
reg
.
toString
()
);
str
.
append
(
reg
);
}
}
}
}
return
str
.
toString
();
return
str
.
toString
();
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/DeclareVariableAttr.java
→
jadx-core/src/main/java/jadx/core/dex/attributes/DeclareVariable
s
Attr.java
View file @
3c84975a
...
@@ -3,37 +3,27 @@ package jadx.core.dex.attributes;
...
@@ -3,37 +3,27 @@ package jadx.core.dex.attributes;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.Utils
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
public
class
DeclareVariableAttr
implements
IAttribute
{
/**
* List of variables to be declared at region start.
*/
public
class
DeclareVariablesAttr
implements
IAttribute
{
private
final
List
<
RegisterArg
>
vars
;
private
final
List
<
RegisterArg
>
vars
=
new
LinkedList
<
RegisterArg
>()
;
public
DeclareVariableAttr
()
{
public
Iterable
<
RegisterArg
>
getVars
()
{
this
.
vars
=
null
;
// for instruction use result
}
public
DeclareVariableAttr
(
List
<
RegisterArg
>
vars
)
{
this
.
vars
=
vars
;
// for regions
}
public
List
<
RegisterArg
>
getVars
()
{
return
vars
;
return
vars
;
}
}
public
void
addVar
(
RegisterArg
arg
)
{
public
void
addVar
(
RegisterArg
arg
)
{
int
i
;
if
((
i
=
vars
.
indexOf
(
arg
))
!=
-
1
)
{
if
(
vars
.
get
(
i
).
getType
().
equals
(
arg
.
getType
()))
{
return
;
}
}
vars
.
add
(
arg
);
vars
.
add
(
arg
);
}
}
@Override
@Override
public
AttributeType
getType
()
{
public
AttributeType
getType
()
{
return
AttributeType
.
DECLARE_VARIABLE
;
return
AttributeType
.
DECLARE_VARIABLE
S
;
}
}
@Override
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/JadxErrorAttr.java
View file @
3c84975a
...
@@ -26,7 +26,7 @@ public class JadxErrorAttr implements IAttribute {
...
@@ -26,7 +26,7 @@ public class JadxErrorAttr implements IAttribute {
if
(
cause
==
null
)
{
if
(
cause
==
null
)
{
str
.
append
(
"null"
);
str
.
append
(
"null"
);
}
else
{
}
else
{
str
.
append
(
cause
.
getClass
()
.
toString
()
);
str
.
append
(
cause
.
getClass
());
str
.
append
(
":"
);
str
.
append
(
":"
);
str
.
append
(
cause
.
getMessage
());
str
.
append
(
cause
.
getMessage
());
str
.
append
(
"\n"
);
str
.
append
(
"\n"
);
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/JumpAttribute.java
View file @
3c84975a
...
@@ -32,11 +32,7 @@ public class JumpAttribute implements IAttribute {
...
@@ -32,11 +32,7 @@ public class JumpAttribute implements IAttribute {
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
final
int
prime
=
31
;
return
31
*
dest
+
src
;
int
result
=
1
;
result
=
prime
*
result
+
dest
;
result
=
prime
*
result
+
src
;
return
result
;
}
}
@Override
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/info/ClassInfo.java
View file @
3c84975a
...
@@ -58,37 +58,37 @@ public final class ClassInfo {
...
@@ -58,37 +58,37 @@ public final class ClassInfo {
String
fullObjectName
=
type
.
getObject
();
String
fullObjectName
=
type
.
getObject
();
assert
fullObjectName
.
indexOf
(
'/'
)
==
-
1
:
"Raw type: "
+
type
;
assert
fullObjectName
.
indexOf
(
'/'
)
==
-
1
:
"Raw type: "
+
type
;
String
n
ame
;
String
clsN
ame
;
int
dot
=
fullObjectName
.
lastIndexOf
(
'.'
);
int
dot
=
fullObjectName
.
lastIndexOf
(
'.'
);
if
(
dot
==
-
1
)
{
if
(
dot
==
-
1
)
{
// rename default package if it used from class with package (often for obfuscated apps),
// rename default package if it used from class with package (often for obfuscated apps),
pkg
=
Consts
.
DEFAULT_PACKAGE_NAME
;
pkg
=
Consts
.
DEFAULT_PACKAGE_NAME
;
n
ame
=
fullObjectName
;
clsN
ame
=
fullObjectName
;
}
else
{
}
else
{
pkg
=
fullObjectName
.
substring
(
0
,
dot
);
pkg
=
fullObjectName
.
substring
(
0
,
dot
);
n
ame
=
fullObjectName
.
substring
(
dot
+
1
);
clsN
ame
=
fullObjectName
.
substring
(
dot
+
1
);
}
}
int
sep
=
n
ame
.
lastIndexOf
(
'$'
);
int
sep
=
clsN
ame
.
lastIndexOf
(
'$'
);
if
(
canBeInner
&&
sep
>
0
&&
sep
!=
n
ame
.
length
()
-
1
)
{
if
(
canBeInner
&&
sep
>
0
&&
sep
!=
clsN
ame
.
length
()
-
1
)
{
String
parClsName
=
pkg
+
'.'
+
n
ame
.
substring
(
0
,
sep
);
String
parClsName
=
pkg
+
'.'
+
clsN
ame
.
substring
(
0
,
sep
);
parentClass
=
fromName
(
parClsName
);
parentClass
=
fromName
(
parClsName
);
name
=
n
ame
.
substring
(
sep
+
1
);
clsName
=
clsN
ame
.
substring
(
sep
+
1
);
}
else
{
}
else
{
parentClass
=
null
;
parentClass
=
null
;
}
}
char
firstChar
=
n
ame
.
charAt
(
0
);
char
firstChar
=
clsN
ame
.
charAt
(
0
);
if
(
Character
.
isDigit
(
firstChar
))
{
if
(
Character
.
isDigit
(
firstChar
))
{
name
=
Consts
.
ANONYMOUS_CLASS_PREFIX
+
n
ame
;
clsName
=
Consts
.
ANONYMOUS_CLASS_PREFIX
+
clsN
ame
;
}
else
if
(
firstChar
==
'$'
)
{
}
else
if
(
firstChar
==
'$'
)
{
name
=
"_"
+
n
ame
;
clsName
=
"_"
+
clsN
ame
;
}
}
if
(
NameMapper
.
isReserved
(
n
ame
))
{
if
(
NameMapper
.
isReserved
(
clsN
ame
))
{
n
ame
+=
"_"
;
clsN
ame
+=
"_"
;
}
}
this
.
fullName
=
(
parentClass
!=
null
?
parentClass
.
getFullName
()
:
pkg
)
+
"."
+
n
ame
;
this
.
fullName
=
(
parentClass
!=
null
?
parentClass
.
getFullName
()
:
pkg
)
+
"."
+
clsN
ame
;
this
.
name
=
n
ame
;
this
.
name
=
clsN
ame
;
}
}
public
String
getFullPath
()
{
public
String
getFullPath
()
{
...
...
jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java
View file @
3c84975a
...
@@ -88,11 +88,9 @@ public final class MethodInfo {
...
@@ -88,11 +88,9 @@ public final class MethodInfo {
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
declClass
.
hashCode
();
int
result
=
1
;
result
=
31
*
result
+
retType
.
hashCode
();
result
=
prime
*
result
+
declClass
.
hashCode
();
result
=
31
*
result
+
shortId
.
hashCode
();
result
=
prime
*
result
+
retType
.
hashCode
();
result
=
prime
*
result
+
shortId
.
hashCode
();
return
result
;
return
result
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/ArgType.java
View file @
3c84975a
...
@@ -229,7 +229,7 @@ public abstract class ArgType {
...
@@ -229,7 +229,7 @@ public abstract class ArgType {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
arrayElement
.
toString
()
+
"[]"
;
return
arrayElement
+
"[]"
;
}
}
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/RegisterArg.java
View file @
3c84975a
...
@@ -88,7 +88,7 @@ public class RegisterArg extends InsnArg {
...
@@ -88,7 +88,7 @@ public class RegisterArg extends InsnArg {
public
boolean
isThis
()
{
public
boolean
isThis
()
{
if
(
isRegister
())
{
if
(
isRegister
())
{
String
name
=
getTypedVar
().
getName
();
String
name
=
getTypedVar
().
getName
();
if
(
name
!=
null
&&
name
.
equals
(
"this"
))
{
if
(
"this"
.
equals
(
name
))
{
return
true
;
return
true
;
}
}
// maybe it was moved from 'this' register
// maybe it was moved from 'this' register
...
@@ -120,13 +120,7 @@ public class RegisterArg extends InsnArg {
...
@@ -120,13 +120,7 @@ public class RegisterArg extends InsnArg {
return
false
;
return
false
;
}
}
RegisterArg
other
=
(
RegisterArg
)
obj
;
RegisterArg
other
=
(
RegisterArg
)
obj
;
if
(
regNum
!=
other
.
regNum
)
{
return
regNum
==
other
.
regNum
&&
typedVar
.
equals
(
other
.
typedVar
);
return
false
;
}
if
(!
typedVar
.
equals
(
other
.
typedVar
))
{
return
false
;
}
return
true
;
}
}
@Override
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/TypedVar.java
View file @
3c84975a
...
@@ -51,9 +51,9 @@ public class TypedVar {
...
@@ -51,9 +51,9 @@ public class TypedVar {
}
}
public
void
mergeName
(
TypedVar
arg
)
{
public
void
mergeName
(
TypedVar
arg
)
{
String
n
ame
=
arg
.
getName
();
String
argN
ame
=
arg
.
getName
();
if
(
n
ame
!=
null
)
{
if
(
argN
ame
!=
null
)
{
setName
(
n
ame
);
setName
(
argN
ame
);
}
else
if
(
getName
()
!=
null
)
{
}
else
if
(
getName
()
!=
null
)
{
arg
.
setName
(
getName
());
arg
.
setName
(
getName
());
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
View file @
3c84975a
...
@@ -124,7 +124,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
...
@@ -124,7 +124,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
int
offset
=
cls
.
getAnnotationsOffset
();
int
offset
=
cls
.
getAnnotationsOffset
();
if
(
offset
!=
0
)
{
if
(
offset
!=
0
)
{
try
{
try
{
new
AnnotationsParser
(
this
,
offset
);
new
AnnotationsParser
(
this
).
parse
(
offset
);
}
catch
(
DecodeException
e
)
{
}
catch
(
DecodeException
e
)
{
LOG
.
error
(
"Error parsing annotations in "
+
this
,
e
);
LOG
.
error
(
"Error parsing annotations in "
+
this
,
e
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
View file @
3c84975a
...
@@ -91,13 +91,11 @@ public class InsnNode extends LineAttrNode {
...
@@ -91,13 +91,11 @@ public class InsnNode extends LineAttrNode {
InsnArg
arg
=
arguments
.
get
(
i
);
InsnArg
arg
=
arguments
.
get
(
i
);
if
(
arg
==
from
)
{
if
(
arg
==
from
)
{
// TODO correct remove from use list
// TODO correct remove from use list
// from.getTypedVar().getUseList().remove(from);
setArg
(
i
,
to
);
setArg
(
i
,
to
);
return
true
;
return
true
;
}
else
if
(
arg
.
isInsnWrap
())
{
if
(((
InsnWrapArg
)
arg
).
getWrapInsn
().
replaceArg
(
from
,
to
))
{
return
true
;
}
}
if
(
arg
.
isInsnWrap
()
&&
((
InsnWrapArg
)
arg
).
getWrapInsn
().
replaceArg
(
from
,
to
))
{
return
true
;
}
}
}
}
return
false
;
return
false
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
View file @
3c84975a
...
@@ -47,7 +47,7 @@ public class RootNode {
...
@@ -47,7 +47,7 @@ public class RootNode {
initInnerClasses
(
classes
);
initInnerClasses
(
classes
);
}
}
private
void
initClassPath
(
List
<
ClassNode
>
classes
)
throws
IOException
,
DecodeException
{
private
static
void
initClassPath
(
List
<
ClassNode
>
classes
)
throws
IOException
,
DecodeException
{
ClspGraph
clsp
=
new
ClspGraph
();
ClspGraph
clsp
=
new
ClspGraph
();
clsp
.
load
();
clsp
.
load
();
clsp
.
addApp
(
classes
);
clsp
.
addApp
(
classes
);
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/AnnotationsParser.java
View file @
3c84975a
...
@@ -4,6 +4,7 @@ import jadx.core.dex.attributes.annotations.Annotation;
...
@@ -4,6 +4,7 @@ import jadx.core.dex.attributes.annotations.Annotation;
import
jadx.core.dex.attributes.annotations.Annotation.Visibility
;
import
jadx.core.dex.attributes.annotations.Annotation.Visibility
;
import
jadx.core.dex.attributes.annotations.AnnotationsList
;
import
jadx.core.dex.attributes.annotations.AnnotationsList
;
import
jadx.core.dex.attributes.annotations.MethodParameters
;
import
jadx.core.dex.attributes.annotations.MethodParameters
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.FieldNode
;
...
@@ -20,9 +21,14 @@ import com.android.dx.io.DexBuffer.Section;
...
@@ -20,9 +21,14 @@ import com.android.dx.io.DexBuffer.Section;
public
class
AnnotationsParser
{
public
class
AnnotationsParser
{
private
final
DexNode
dex
;
private
final
DexNode
dex
;
private
final
ClassNode
cls
;
public
AnnotationsParser
(
ClassNode
cls
,
int
offset
)
throws
DecodeException
{
public
AnnotationsParser
(
ClassNode
cls
)
{
this
.
cls
=
cls
;
this
.
dex
=
cls
.
dex
();
this
.
dex
=
cls
.
dex
();
}
public
void
parse
(
int
offset
)
throws
DecodeException
{
Section
section
=
dex
.
openSection
(
offset
);
Section
section
=
dex
.
openSection
(
offset
);
// TODO read as unsigned int
// TODO read as unsigned int
...
@@ -70,10 +76,10 @@ public class AnnotationsParser {
...
@@ -70,10 +76,10 @@ public class AnnotationsParser {
return
new
AnnotationsList
(
list
);
return
new
AnnotationsList
(
list
);
}
}
private
static
final
Annotation
.
Visibility
[]
VISIBILITIES
=
new
Annotation
.
Visibility
[]
{
private
static
final
Annotation
.
Visibility
[]
VISIBILITIES
=
{
Annotation
.
Visibility
.
BUILD
,
Visibility
.
BUILD
,
Annotation
.
Visibility
.
RUNTIME
,
Visibility
.
RUNTIME
,
Annotation
.
Visibility
.
SYSTEM
Visibility
.
SYSTEM
};
};
public
static
Annotation
readAnnotation
(
DexNode
dex
,
Section
s
,
boolean
readVisibility
)
throws
DecodeException
{
public
static
Annotation
readAnnotation
(
DexNode
dex
,
Section
s
,
boolean
readVisibility
)
throws
DecodeException
{
...
@@ -89,6 +95,11 @@ public class AnnotationsParser {
...
@@ -89,6 +95,11 @@ public class AnnotationsParser {
String
name
=
dex
.
getString
(
s
.
readUleb128
());
String
name
=
dex
.
getString
(
s
.
readUleb128
());
values
.
put
(
name
,
parser
.
parseValue
());
values
.
put
(
name
,
parser
.
parseValue
());
}
}
return
new
Annotation
(
visibility
,
dex
.
getType
(
typeIndex
),
values
);
ArgType
type
=
dex
.
getType
(
typeIndex
);
Annotation
annotation
=
new
Annotation
(
visibility
,
type
,
values
);
if
(!
type
.
isObject
())
{
throw
new
DecodeException
(
"Incorrect type for annotation: "
+
annotation
);
}
return
annotation
;
}
}
}
}
jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
View file @
3c84975a
...
@@ -25,9 +25,12 @@ public class DebugInfoParser {
...
@@ -25,9 +25,12 @@ public class DebugInfoParser {
private
static
final
int
DBG_SET_EPILOGUE_BEGIN
=
0x08
;
private
static
final
int
DBG_SET_EPILOGUE_BEGIN
=
0x08
;
private
static
final
int
DBG_SET_FILE
=
0x09
;
private
static
final
int
DBG_SET_FILE
=
0x09
;
private
static
final
int
DBG_FIRST_SPECIAL
=
0x0a
;
// the smallest special opcode
// the smallest special opcode
private
static
final
int
DBG_LINE_BASE
=
-
4
;
// the smallest line number increment
private
static
final
int
DBG_FIRST_SPECIAL
=
0x0a
;
private
static
final
int
DBG_LINE_RANGE
=
15
;
// the number of line increments represented
// the smallest line number increment
private
static
final
int
DBG_LINE_BASE
=
-
4
;
// the number of line increments represented
private
static
final
int
DBG_LINE_RANGE
=
15
;
private
final
MethodNode
mth
;
private
final
MethodNode
mth
;
private
final
Section
section
;
private
final
Section
section
;
...
@@ -42,8 +45,9 @@ public class DebugInfoParser {
...
@@ -42,8 +45,9 @@ public class DebugInfoParser {
this
.
dex
=
mth
.
dex
();
this
.
dex
=
mth
.
dex
();
this
.
section
=
dex
.
openSection
(
debugOffset
);
this
.
section
=
dex
.
openSection
(
debugOffset
);
this
.
locals
=
new
LocalVar
[
mth
.
getRegsCount
()];
int
regsCount
=
mth
.
getRegsCount
();
this
.
activeRegisters
=
new
InsnArg
[
mth
.
getRegsCount
()];
this
.
locals
=
new
LocalVar
[
regsCount
];
this
.
activeRegisters
=
new
InsnArg
[
regsCount
];
this
.
insnByOffset
=
insnByOffset
;
this
.
insnByOffset
=
insnByOffset
;
}
}
...
@@ -51,7 +55,7 @@ public class DebugInfoParser {
...
@@ -51,7 +55,7 @@ public class DebugInfoParser {
int
addr
=
0
;
int
addr
=
0
;
int
line
=
section
.
readUleb128
();
int
line
=
section
.
readUleb128
();
int
paramsCount
=
section
.
readUleb128
();
// exclude 'this'
int
paramsCount
=
section
.
readUleb128
();
List
<
RegisterArg
>
mthArgs
=
mth
.
getArguments
(
false
);
List
<
RegisterArg
>
mthArgs
=
mth
.
getArguments
(
false
);
assert
paramsCount
==
mthArgs
.
size
();
assert
paramsCount
==
mthArgs
.
size
();
...
@@ -69,7 +73,8 @@ public class DebugInfoParser {
...
@@ -69,7 +73,8 @@ public class DebugInfoParser {
activeRegisters
[
rn
]
=
arg
;
activeRegisters
[
rn
]
=
arg
;
}
}
addrChange
(-
1
,
1
,
line
);
// process '0' instruction
// process '0' instruction
addrChange
(-
1
,
1
,
line
);
int
c
=
section
.
readByte
()
&
0xFF
;
int
c
=
section
.
readByte
()
&
0xFF
;
while
(
c
!=
DBG_END_SEQUENCE
)
{
while
(
c
!=
DBG_END_SEQUENCE
)
{
...
@@ -139,7 +144,7 @@ public class DebugInfoParser {
...
@@ -139,7 +144,7 @@ public class DebugInfoParser {
if
(
c
>=
DBG_FIRST_SPECIAL
)
{
if
(
c
>=
DBG_FIRST_SPECIAL
)
{
int
adjustedOpcode
=
c
-
DBG_FIRST_SPECIAL
;
int
adjustedOpcode
=
c
-
DBG_FIRST_SPECIAL
;
line
+=
DBG_LINE_BASE
+
(
adjustedOpcode
%
DBG_LINE_RANGE
);
line
+=
DBG_LINE_BASE
+
(
adjustedOpcode
%
DBG_LINE_RANGE
);
int
addrInc
=
(
adjustedOpcode
/
DBG_LINE_RANGE
)
;
int
addrInc
=
adjustedOpcode
/
DBG_LINE_RANGE
;
addr
=
addrChange
(
addr
,
addrInc
,
line
);
addr
=
addrChange
(
addr
,
addrInc
,
line
);
}
else
{
}
else
{
throw
new
DecodeException
(
"Unknown debug insn code: "
+
c
);
throw
new
DecodeException
(
"Unknown debug insn code: "
+
c
);
...
@@ -213,10 +218,10 @@ public class DebugInfoParser {
...
@@ -213,10 +218,10 @@ public class DebugInfoParser {
}
}
private
static
void
merge
(
InsnArg
arg
,
LocalVar
var
)
{
private
static
void
merge
(
InsnArg
arg
,
LocalVar
var
)
{
if
(
arg
!=
null
&&
arg
.
isRegister
())
{
if
(
arg
!=
null
if
(
var
.
getRegNum
()
==
((
RegisterArg
)
arg
).
getRegNum
())
{
&&
arg
.
isRegister
()
&&
var
.
getRegNum
()
==
((
RegisterArg
)
arg
).
getRegNum
())
{
arg
.
mergeDebugInfo
(
var
);
arg
.
mergeDebugInfo
(
var
);
}
}
}
}
}
}
}
jadx-core/src/main/java/jadx/core/dex/regions/LoopRegion.java
View file @
3c84975a
...
@@ -15,9 +15,9 @@ public final class LoopRegion extends AbstractRegion {
...
@@ -15,9 +15,9 @@ public final class LoopRegion extends AbstractRegion {
// loop header contains one 'if' insn, equals null for infinite loop
// loop header contains one 'if' insn, equals null for infinite loop
private
IfCondition
condition
;
private
IfCondition
condition
;
private
BlockNode
conditionBlock
;
private
final
BlockNode
conditionBlock
;
// instruction which must be executed before condition in every loop
// instruction which must be executed before condition in every loop
private
BlockNode
preCondition
=
null
;
private
BlockNode
preCondition
;
private
IContainer
body
;
private
IContainer
body
;
private
final
boolean
conditionAtEnd
;
private
final
boolean
conditionAtEnd
;
...
...
jadx-core/src/main/java/jadx/core/dex/regions/TernaryRegion.java
View file @
3c84975a
...
@@ -9,7 +9,7 @@ import java.util.Collections;
...
@@ -9,7 +9,7 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.List
;
public
final
class
TernaryRegion
extends
AbstractRegion
{
public
final
class
TernaryRegion
extends
AbstractRegion
{
private
IBlock
container
;
private
final
IBlock
container
;
public
TernaryRegion
(
IRegion
parent
,
BlockNode
block
)
{
public
TernaryRegion
(
IRegion
parent
,
BlockNode
block
)
{
super
(
parent
);
super
(
parent
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
View file @
3c84975a
...
@@ -17,10 +17,12 @@ import jadx.core.dex.nodes.MethodNode;
...
@@ -17,10 +17,12 @@ import jadx.core.dex.nodes.MethodNode;
import
jadx.core.dex.trycatch.CatchAttr
;
import
jadx.core.dex.trycatch.CatchAttr
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
import
jadx.core.dex.trycatch.SplitterBlockAttr
;
import
jadx.core.dex.trycatch.SplitterBlockAttr
;
import
jadx.core.utils.BlockUtils
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.BitSet
;
import
java.util.BitSet
;
import
java.util.Collections
;
import
java.util.EnumSet
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -223,7 +225,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -223,7 +225,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
}
}
private
static
void
computeDominators
(
MethodNode
mth
)
{
private
static
void
computeDominators
(
MethodNode
mth
)
{
List
<
BlockNode
>
basicBlocks
=
mth
.
getBasicBlocks
(
);
List
<
BlockNode
>
basicBlocks
=
Collections
.
unmodifiableList
(
mth
.
getBasicBlocks
()
);
int
nBlocks
=
basicBlocks
.
size
();
int
nBlocks
=
basicBlocks
.
size
();
for
(
int
i
=
0
;
i
<
nBlocks
;
i
++)
{
for
(
int
i
=
0
;
i
<
nBlocks
;
i
++)
{
BlockNode
block
=
basicBlocks
.
get
(
i
);
BlockNode
block
=
basicBlocks
.
get
(
i
);
...
@@ -245,13 +247,15 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -245,13 +247,15 @@ public class BlockMakerVisitor extends AbstractVisitor {
continue
;
continue
;
}
}
BitSet
d
=
block
.
getDoms
();
BitSet
d
=
block
.
getDoms
();
if
(!
changed
)
{
dset
.
clear
();
dset
.
clear
();
dset
.
or
(
d
);
dset
.
or
(
d
);
}
for
(
BlockNode
pred
:
block
.
getPredecessors
())
{
for
(
BlockNode
pred
:
block
.
getPredecessors
())
{
d
.
and
(
pred
.
getDoms
());
d
.
and
(
pred
.
getDoms
());
}
}
d
.
set
(
block
.
getId
());
d
.
set
(
block
.
getId
());
if
(!
d
.
equals
(
dset
))
{
if
(!
changed
&&
!
d
.
equals
(
dset
))
{
changed
=
true
;
changed
=
true
;
}
}
}
}
...
@@ -315,15 +319,12 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -315,15 +319,12 @@ public class BlockMakerVisitor extends AbstractVisitor {
private
static
void
markReturnBlocks
(
MethodNode
mth
)
{
private
static
void
markReturnBlocks
(
MethodNode
mth
)
{
mth
.
getExitBlocks
().
clear
();
mth
.
getExitBlocks
().
clear
();
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
List
<
InsnNode
>
insns
=
block
.
getInstructions
();
if
(
BlockUtils
.
lastInsnType
(
block
,
InsnType
.
RETURN
))
{
if
(
insns
.
size
()
==
1
)
{
if
(
insns
.
get
(
0
).
getType
()
==
InsnType
.
RETURN
)
{
block
.
getAttributes
().
add
(
AttributeFlag
.
RETURN
);
block
.
getAttributes
().
add
(
AttributeFlag
.
RETURN
);
mth
.
getExitBlocks
().
add
(
block
);
mth
.
getExitBlocks
().
add
(
block
);
}
}
}
}
}
}
}
private
static
void
registerLoops
(
MethodNode
mth
)
{
private
static
void
registerLoops
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ClassModifier.java
View file @
3c84975a
...
@@ -111,12 +111,10 @@ public class ClassModifier extends AbstractVisitor {
...
@@ -111,12 +111,10 @@ public class ClassModifier extends AbstractVisitor {
AccessInfo
af
=
mth
.
getAccessFlags
();
AccessInfo
af
=
mth
.
getAccessFlags
();
// remove bridge methods
// remove bridge methods
if
(
af
.
isBridge
()
&&
af
.
isSynthetic
())
{
if
(
af
.
isBridge
()
&&
af
.
isSynthetic
()
&&
!
isMethodUniq
(
cls
,
mth
))
{
if
(!
isMethodUniq
(
cls
,
mth
))
{
// TODO add more checks before method deletion
// TODO add more checks before method deletion
it
.
remove
();
it
.
remove
();
}
}
}
// remove synthetic constructor for inner non-static classes
// remove synthetic constructor for inner non-static classes
if
(
af
.
isSynthetic
()
&&
af
.
isConstructor
()
&&
mth
.
getBasicBlocks
().
size
()
==
2
)
{
if
(
af
.
isSynthetic
()
&&
af
.
isConstructor
()
&&
mth
.
getBasicBlocks
().
size
()
==
2
)
{
...
@@ -135,11 +133,11 @@ public class ClassModifier extends AbstractVisitor {
...
@@ -135,11 +133,11 @@ public class ClassModifier extends AbstractVisitor {
private
static
boolean
isMethodUniq
(
ClassNode
cls
,
MethodNode
mth
)
{
private
static
boolean
isMethodUniq
(
ClassNode
cls
,
MethodNode
mth
)
{
MethodInfo
mi
=
mth
.
getMethodInfo
();
MethodInfo
mi
=
mth
.
getMethodInfo
();
for
(
MethodNode
otherMth
:
cls
.
getMethods
())
{
for
(
MethodNode
otherMth
:
cls
.
getMethods
())
{
if
(
otherMth
!=
mth
)
{
MethodInfo
omi
=
otherMth
.
getMethodInfo
();
MethodInfo
omi
=
otherMth
.
getMethodInfo
();
if
(
omi
.
getName
().
equals
(
mi
.
getName
())
if
(
omi
.
getName
().
equals
(
mi
.
getName
())
&&
otherMth
!=
mth
)
{
&&
omi
.
getArgumentsTypes
().
size
()
==
mi
.
getArgumentsTypes
().
size
())
{
if
(
omi
.
getArgumentsTypes
().
size
()
==
mi
.
getArgumentsTypes
().
size
())
{
// TODO: check objects types
// TODO: check to args objects types
return
false
;
return
false
;
}
}
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
View file @
3c84975a
...
@@ -231,11 +231,9 @@ public class CodeShrinker extends AbstractVisitor {
...
@@ -231,11 +231,9 @@ public class CodeShrinker extends AbstractVisitor {
List
<
RegisterArg
>
args
=
ArgsInfo
.
getArgs
(
assignInsn
);
List
<
RegisterArg
>
args
=
ArgsInfo
.
getArgs
(
assignInsn
);
boolean
startCheck
=
false
;
boolean
startCheck
=
false
;
for
(
InsnNode
insn
:
assignBlock
.
getInstructions
())
{
for
(
InsnNode
insn
:
assignBlock
.
getInstructions
())
{
if
(
startCheck
)
{
if
(
startCheck
&&
(!
insn
.
canReorder
()
||
ArgsInfo
.
usedArgAssign
(
insn
,
args
)))
{
if
(!
insn
.
canReorder
()
||
ArgsInfo
.
usedArgAssign
(
insn
,
args
))
{
return
false
;
return
false
;
}
}
}
if
(
insn
==
assignInsn
)
{
if
(
insn
==
assignInsn
)
{
startCheck
=
true
;
startCheck
=
true
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
View file @
3c84975a
...
@@ -116,11 +116,10 @@ public class ConstInlinerVisitor extends AbstractVisitor {
...
@@ -116,11 +116,10 @@ public class ConstInlinerVisitor extends AbstractVisitor {
break
;
break
;
case
IPUT:
case
IPUT:
case
SPUT:
{
case
SPUT:
IndexInsnNode
node
=
(
IndexInsnNode
)
insn
;
IndexInsnNode
node
=
(
IndexInsnNode
)
insn
;
insn
.
getArg
(
0
).
merge
(((
FieldInfo
)
node
.
getIndex
()).
getType
());
insn
.
getArg
(
0
).
merge
(((
FieldInfo
)
node
.
getIndex
()).
getType
());
break
;
break
;
}
case
IF:
{
case
IF:
{
InsnArg
arg0
=
insn
.
getArg
(
0
);
InsnArg
arg0
=
insn
.
getArg
(
0
);
...
@@ -133,7 +132,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
...
@@ -133,7 +132,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
break
;
break
;
}
}
case
CMP_G:
case
CMP_G:
case
CMP_L:
{
case
CMP_L:
InsnArg
arg0
=
insn
.
getArg
(
0
);
InsnArg
arg0
=
insn
.
getArg
(
0
);
InsnArg
arg1
=
insn
.
getArg
(
1
);
InsnArg
arg1
=
insn
.
getArg
(
1
);
if
(
arg0
==
litArg
)
{
if
(
arg0
==
litArg
)
{
...
@@ -142,7 +141,6 @@ public class ConstInlinerVisitor extends AbstractVisitor {
...
@@ -142,7 +141,6 @@ public class ConstInlinerVisitor extends AbstractVisitor {
arg1
.
merge
(
arg0
);
arg1
.
merge
(
arg0
);
}
}
break
;
break
;
}
case
RETURN:
case
RETURN:
if
(
insn
.
getArgsCount
()
!=
0
)
{
if
(
insn
.
getArgsCount
()
!=
0
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/DotGraphVisitor.java
View file @
3c84975a
...
@@ -9,7 +9,6 @@ import jadx.core.dex.nodes.IRegion;
...
@@ -9,7 +9,6 @@ import jadx.core.dex.nodes.IRegion;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
import
jadx.core.utils.BlockUtils
;
import
jadx.core.utils.InsnUtils
;
import
jadx.core.utils.InsnUtils
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.Utils
;
...
@@ -94,7 +93,7 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -94,7 +93,7 @@ public class DotGraphVisitor extends AbstractVisitor {
IRegion
r
=
(
IRegion
)
region
;
IRegion
r
=
(
IRegion
)
region
;
String
attrs
=
attributesString
(
r
);
String
attrs
=
attributesString
(
r
);
dot
.
startLine
(
"subgraph "
+
makeName
(
region
)
+
" {"
);
dot
.
startLine
(
"subgraph "
+
makeName
(
region
)
+
" {"
);
dot
.
startLine
(
"label = \""
+
r
.
toString
()
dot
.
startLine
(
"label = \""
+
r
+
(
attrs
.
length
()
==
0
?
""
:
" | "
+
attrs
)
+
(
attrs
.
length
()
==
0
?
""
:
" | "
+
attrs
)
+
"\";"
);
+
"\";"
);
dot
.
startLine
(
"node [shape=record,color=blue];"
);
dot
.
startLine
(
"node [shape=record,color=blue];"
);
...
@@ -136,12 +135,6 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -136,12 +135,6 @@ public class DotGraphVisitor extends AbstractVisitor {
for
(
BlockNode
next
:
block
.
getDominatesOn
())
{
for
(
BlockNode
next
:
block
.
getDominatesOn
())
{
conn
.
startLine
(
makeName
(
block
)
+
" -> "
+
makeName
(
next
)
+
"[style=dotted];"
);
conn
.
startLine
(
makeName
(
block
)
+
" -> "
+
makeName
(
next
)
+
"[style=dotted];"
);
}
}
// add all dominators connections
if
(
false
)
{
for
(
BlockNode
next
:
BlockUtils
.
bitsetToBlocks
(
mth
,
block
.
getDoms
()))
{
conn
.
startLine
(
makeName
(
block
)
+
" -> "
+
makeName
(
next
)
+
"[style=dotted, color=green];"
);
}
}
}
}
private
String
attributesString
(
IAttributeNode
block
)
{
private
String
attributesString
(
IAttributeNode
block
)
{
...
@@ -152,7 +145,7 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -152,7 +145,7 @@ public class DotGraphVisitor extends AbstractVisitor {
return
attrs
.
toString
();
return
attrs
.
toString
();
}
}
private
String
makeName
(
IContainer
c
)
{
private
static
String
makeName
(
IContainer
c
)
{
String
name
;
String
name
;
if
(
c
instanceof
BlockNode
)
{
if
(
c
instanceof
BlockNode
)
{
name
=
"Node_"
+
((
BlockNode
)
c
).
getId
();
name
=
"Node_"
+
((
BlockNode
)
c
).
getId
();
...
@@ -166,7 +159,7 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -166,7 +159,7 @@ public class DotGraphVisitor extends AbstractVisitor {
if
(
rawInsn
)
{
if
(
rawInsn
)
{
StringBuilder
str
=
new
StringBuilder
();
StringBuilder
str
=
new
StringBuilder
();
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
str
.
append
(
escape
(
insn
.
toString
()
+
" "
+
insn
.
getAttributes
()));
str
.
append
(
escape
(
insn
+
" "
+
insn
.
getAttributes
()));
str
.
append
(
NL
);
str
.
append
(
NL
);
}
}
return
str
.
toString
();
return
str
.
toString
();
...
@@ -181,7 +174,7 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -181,7 +174,7 @@ public class DotGraphVisitor extends AbstractVisitor {
}
}
}
}
private
String
escape
(
String
string
)
{
private
static
String
escape
(
String
string
)
{
return
string
return
string
.
replace
(
"\\"
,
""
)
// TODO replace \"
.
replace
(
"\\"
,
""
)
// TODO replace \"
.
replace
(
"/"
,
"\\/"
)
.
replace
(
"/"
,
"\\/"
)
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/MethodInline
r
Visitor.java
→
jadx-core/src/main/java/jadx/core/dex/visitors/MethodInlineVisitor.java
View file @
3c84975a
...
@@ -10,20 +10,23 @@ import jadx.core.dex.nodes.InsnNode;
...
@@ -10,20 +10,23 @@ import jadx.core.dex.nodes.InsnNode;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.exceptions.JadxException
;
public
class
MethodInlinerVisitor
extends
AbstractVisitor
{
/**
* Inline synthetic methods.
*/
public
class
MethodInlineVisitor
extends
AbstractVisitor
{
@Override
@Override
public
void
visit
(
MethodNode
mth
)
throws
JadxException
{
public
void
visit
(
MethodNode
mth
)
throws
JadxException
{
AccessInfo
accessFlags
=
mth
.
getAccessFlags
();
AccessInfo
accessFlags
=
mth
.
getAccessFlags
();
if
(
accessFlags
.
isSynthetic
()
&&
accessFlags
.
isStatic
())
{
if
(
accessFlags
.
isSynthetic
()
if
(
mth
.
getBasicBlocks
().
size
()
==
2
)
{
&&
accessFlags
.
isStatic
()
&&
mth
.
getBasicBlocks
().
size
()
==
2
)
{
BlockNode
block
=
mth
.
getBasicBlocks
().
get
(
1
);
BlockNode
block
=
mth
.
getBasicBlocks
().
get
(
1
);
if
(
block
.
getAttributes
().
contains
(
AttributeFlag
.
RETURN
))
{
if
(
block
.
getAttributes
().
contains
(
AttributeFlag
.
RETURN
))
{
inlineMth
(
mth
);
inlineMth
(
mth
);
}
}
}
}
}
}
}
private
static
void
inlineMth
(
MethodNode
mth
)
{
private
static
void
inlineMth
(
MethodNode
mth
)
{
BlockNode
firstBlock
=
mth
.
getBasicBlocks
().
get
(
0
);
BlockNode
firstBlock
=
mth
.
getBasicBlocks
().
get
(
0
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
View file @
3c84975a
...
@@ -51,7 +51,7 @@ public class ModVisitor extends AbstractVisitor {
...
@@ -51,7 +51,7 @@ public class ModVisitor extends AbstractVisitor {
}
}
}
}
private
void
replaceStep
(
MethodNode
mth
)
{
private
static
void
replaceStep
(
MethodNode
mth
)
{
ClassNode
parentClass
=
mth
.
getParentClass
();
ClassNode
parentClass
=
mth
.
getParentClass
();
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
InstructionRemover
remover
=
new
InstructionRemover
(
block
.
getInstructions
());
InstructionRemover
remover
=
new
InstructionRemover
(
block
.
getInstructions
());
...
@@ -147,7 +147,7 @@ public class ModVisitor extends AbstractVisitor {
...
@@ -147,7 +147,7 @@ public class ModVisitor extends AbstractVisitor {
/**
/**
* Remove unnecessary instructions
* Remove unnecessary instructions
*/
*/
private
void
removeStep
(
MethodNode
mth
)
{
private
static
void
removeStep
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
InstructionRemover
remover
=
new
InstructionRemover
(
block
.
getInstructions
());
InstructionRemover
remover
=
new
InstructionRemover
(
block
.
getInstructions
());
...
@@ -193,7 +193,7 @@ public class ModVisitor extends AbstractVisitor {
...
@@ -193,7 +193,7 @@ public class ModVisitor extends AbstractVisitor {
}
}
}
}
private
void
processExceptionHander
(
MethodNode
mth
,
BlockNode
block
)
{
private
static
void
processExceptionHander
(
MethodNode
mth
,
BlockNode
block
)
{
ExcHandlerAttr
handlerAttr
=
(
ExcHandlerAttr
)
block
.
getAttributes
().
get
(
AttributeType
.
EXC_HANDLER
);
ExcHandlerAttr
handlerAttr
=
(
ExcHandlerAttr
)
block
.
getAttributes
().
get
(
AttributeType
.
EXC_HANDLER
);
if
(
handlerAttr
==
null
)
{
if
(
handlerAttr
==
null
)
{
return
;
return
;
...
@@ -252,7 +252,7 @@ public class ModVisitor extends AbstractVisitor {
...
@@ -252,7 +252,7 @@ public class ModVisitor extends AbstractVisitor {
block
.
getInstructions
().
set
(
i
,
insn
);
block
.
getInstructions
().
set
(
i
,
insn
);
}
}
private
void
checkArgsNames
(
MethodNode
mth
)
{
private
static
void
checkArgsNames
(
MethodNode
mth
)
{
for
(
RegisterArg
arg
:
mth
.
getArguments
(
false
))
{
for
(
RegisterArg
arg
:
mth
.
getArguments
(
false
))
{
String
name
=
arg
.
getTypedVar
().
getName
();
String
name
=
arg
.
getTypedVar
().
getName
();
if
(
name
!=
null
&&
NameMapper
.
isReserved
(
name
))
{
if
(
name
!=
null
&&
NameMapper
.
isReserved
(
name
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/CheckRegions.java
View file @
3c84975a
package
jadx
.
core
.
dex
.
visitors
.
regions
;
package
jadx
.
core
.
dex
.
visitors
.
regions
;
import
jadx.core.Consts
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.IBlock
;
import
jadx.core.dex.nodes.IBlock
;
...
@@ -33,7 +32,6 @@ public class CheckRegions extends AbstractVisitor {
...
@@ -33,7 +32,6 @@ public class CheckRegions extends AbstractVisitor {
public
void
processBlock
(
MethodNode
mth
,
IBlock
container
)
{
public
void
processBlock
(
MethodNode
mth
,
IBlock
container
)
{
if
(
container
instanceof
BlockNode
)
{
if
(
container
instanceof
BlockNode
)
{
blocksInRegions
.
add
((
BlockNode
)
container
);
blocksInRegions
.
add
((
BlockNode
)
container
);
}
}
}
}
};
};
...
@@ -41,16 +39,11 @@ public class CheckRegions extends AbstractVisitor {
...
@@ -41,16 +39,11 @@ public class CheckRegions extends AbstractVisitor {
if
(
mth
.
getBasicBlocks
().
size
()
!=
blocksInRegions
.
size
())
{
if
(
mth
.
getBasicBlocks
().
size
()
!=
blocksInRegions
.
size
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
if
(!
blocksInRegions
.
contains
(
block
)
)
{
if
(!
blocksInRegions
.
contains
(
block
)
if
(
!
block
.
getInstructions
().
isEmpty
()
&&
!
block
.
getInstructions
().
isEmpty
()
&&
!
block
.
getAttributes
().
contains
(
AttributeFlag
.
SKIP
))
{
&&
!
block
.
getAttributes
().
contains
(
AttributeFlag
.
SKIP
))
{
mth
.
getAttributes
().
add
(
AttributeFlag
.
INCONSISTENT_CODE
);
mth
.
getAttributes
().
add
(
AttributeFlag
.
INCONSISTENT_CODE
);
if
(
Consts
.
DEBUG
)
{
LOG
.
debug
(
" Missing block: {} in {}"
,
block
,
mth
);
LOG
.
debug
(
" Missing block: {} in {}"
,
block
,
mth
);
}
else
{
break
;
}
}
}
}
}
}
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessTryCatchRegions.java
View file @
3c84975a
...
@@ -69,11 +69,11 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
...
@@ -69,11 +69,11 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
assert
bs
!=
null
;
assert
bs
!=
null
;
// intersect to get dominator of dominators
// intersect to get dominator of dominators
List
<
BlockNode
>
domBlocks
=
BlockUtils
.
bit
s
etToBlocks
(
mth
,
bs
);
List
<
BlockNode
>
domBlocks
=
BlockUtils
.
bit
S
etToBlocks
(
mth
,
bs
);
for
(
BlockNode
block
:
domBlocks
)
{
for
(
BlockNode
block
:
domBlocks
)
{
bs
.
andNot
(
block
.
getDoms
());
bs
.
andNot
(
block
.
getDoms
());
}
}
domBlocks
=
BlockUtils
.
bit
s
etToBlocks
(
mth
,
bs
);
domBlocks
=
BlockUtils
.
bit
S
etToBlocks
(
mth
,
bs
);
if
(
domBlocks
.
size
()
!=
1
)
{
if
(
domBlocks
.
size
()
!=
1
)
{
throw
new
JadxRuntimeException
(
throw
new
JadxRuntimeException
(
"Exception block dominator not found, method:"
+
mth
+
". bs: "
+
bs
);
"Exception block dominator not found, method:"
+
mth
+
". bs: "
+
bs
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
View file @
3c84975a
package
jadx
.
core
.
dex
.
visitors
.
regions
;
package
jadx
.
core
.
dex
.
visitors
.
regions
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.attributes.DeclareVariableAttr
;
import
jadx.core.dex.attributes.DeclareVariable
s
Attr
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.nodes.IBlock
;
import
jadx.core.dex.nodes.IBlock
;
import
jadx.core.dex.nodes.IContainer
;
import
jadx.core.dex.nodes.IContainer
;
...
@@ -125,7 +126,7 @@ public class ProcessVariables extends AbstractVisitor {
...
@@ -125,7 +126,7 @@ public class ProcessVariables extends AbstractVisitor {
for
(
IRegion
assignRegion
:
u
.
getAssigns
())
{
for
(
IRegion
assignRegion
:
u
.
getAssigns
())
{
if
(
u
.
getArgRegion
()
==
assignRegion
if
(
u
.
getArgRegion
()
==
assignRegion
&&
canDeclareInRegion
(
u
,
assignRegion
))
{
&&
canDeclareInRegion
(
u
,
assignRegion
))
{
u
.
getArg
().
getParentInsn
().
getAttributes
().
add
(
new
DeclareVariableAttr
()
);
u
.
getArg
().
getParentInsn
().
getAttributes
().
add
(
AttributeFlag
.
DECLARE_VAR
);
it
.
remove
();
it
.
remove
();
break
;
break
;
}
}
...
@@ -167,17 +168,16 @@ public class ProcessVariables extends AbstractVisitor {
...
@@ -167,17 +168,16 @@ public class ProcessVariables extends AbstractVisitor {
}
}
}
}
private
void
declareVar
(
IContainer
region
,
RegisterArg
arg
)
{
private
static
void
declareVar
(
IContainer
region
,
RegisterArg
arg
)
{
DeclareVariableAttr
dv
=
DeclareVariablesAttr
dv
=
(
DeclareVariablesAttr
)
region
.
getAttributes
().
get
(
AttributeType
.
DECLARE_VARIABLES
);
(
DeclareVariableAttr
)
region
.
getAttributes
().
get
(
AttributeType
.
DECLARE_VARIABLE
);
if
(
dv
==
null
)
{
if
(
dv
==
null
)
{
dv
=
new
DeclareVariable
Attr
(
new
ArrayList
<
RegisterArg
>()
);
dv
=
new
DeclareVariable
sAttr
(
);
region
.
getAttributes
().
add
(
dv
);
region
.
getAttributes
().
add
(
dv
);
}
}
dv
.
addVar
(
arg
);
dv
.
addVar
(
arg
);
}
}
private
boolean
canDeclareInRegion
(
Usage
u
,
IRegion
region
)
{
private
static
boolean
canDeclareInRegion
(
Usage
u
,
IRegion
region
)
{
for
(
IRegion
r
:
u
.
getAssigns
())
{
for
(
IRegion
r
:
u
.
getAssigns
())
{
if
(!
RegionUtils
.
isRegionContainsRegion
(
region
,
r
))
{
if
(!
RegionUtils
.
isRegionContainsRegion
(
region
,
r
))
{
return
false
;
return
false
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
3c84975a
...
@@ -350,7 +350,7 @@ public class RegionMaker {
...
@@ -350,7 +350,7 @@ public class RegionMaker {
/**
/**
* Traverse from monitor-enter thru successors and collect blocks contains monitor-exit
* Traverse from monitor-enter thru successors and collect blocks contains monitor-exit
*/
*/
private
void
traverseMonitorExits
(
InsnArg
arg
,
BlockNode
block
,
Set
<
BlockNode
>
exits
,
Set
<
BlockNode
>
visited
)
{
private
static
void
traverseMonitorExits
(
InsnArg
arg
,
BlockNode
block
,
Set
<
BlockNode
>
exits
,
Set
<
BlockNode
>
visited
)
{
visited
.
add
(
block
);
visited
.
add
(
block
);
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
if
(
insn
.
getType
()
==
InsnType
.
MONITOR_EXIT
if
(
insn
.
getType
()
==
InsnType
.
MONITOR_EXIT
...
@@ -370,7 +370,7 @@ public class RegionMaker {
...
@@ -370,7 +370,7 @@ public class RegionMaker {
/**
/**
* Traverse from monitor-enter thru successors and search for exit paths cross
* Traverse from monitor-enter thru successors and search for exit paths cross
*/
*/
private
BlockNode
traverseMonitorExitsCross
(
BlockNode
block
,
Set
<
BlockNode
>
exits
,
Set
<
BlockNode
>
visited
)
{
private
static
BlockNode
traverseMonitorExitsCross
(
BlockNode
block
,
Set
<
BlockNode
>
exits
,
Set
<
BlockNode
>
visited
)
{
visited
.
add
(
block
);
visited
.
add
(
block
);
for
(
BlockNode
node
:
block
.
getCleanSuccessors
())
{
for
(
BlockNode
node
:
block
.
getCleanSuccessors
())
{
boolean
cross
=
true
;
boolean
cross
=
true
;
...
@@ -543,7 +543,7 @@ public class RegionMaker {
...
@@ -543,7 +543,7 @@ public class RegionMaker {
return
result
;
return
result
;
}
}
private
BlockNode
getIfNode
(
BlockNode
block
)
{
private
static
BlockNode
getIfNode
(
BlockNode
block
)
{
if
(
block
!=
null
&&
!
block
.
getAttributes
().
contains
(
AttributeType
.
LOOP
))
{
if
(
block
!=
null
&&
!
block
.
getAttributes
().
contains
(
AttributeType
.
LOOP
))
{
List
<
InsnNode
>
insns
=
block
.
getInstructions
();
List
<
InsnNode
>
insns
=
block
.
getInstructions
();
if
(
insns
.
size
()
==
1
&&
insns
.
get
(
0
).
getType
()
==
InsnType
.
IF
)
{
if
(
insns
.
size
()
==
1
&&
insns
.
get
(
0
).
getType
()
==
InsnType
.
IF
)
{
...
@@ -603,7 +603,7 @@ public class RegionMaker {
...
@@ -603,7 +603,7 @@ public class RegionMaker {
Map
<
BlockNode
,
List
<
Object
>>
blocksMap
=
new
LinkedHashMap
<
BlockNode
,
List
<
Object
>>(
len
);
Map
<
BlockNode
,
List
<
Object
>>
blocksMap
=
new
LinkedHashMap
<
BlockNode
,
List
<
Object
>>(
len
);
for
(
Entry
<
Integer
,
List
<
Object
>>
entry
:
casesMap
.
entrySet
())
{
for
(
Entry
<
Integer
,
List
<
Object
>>
entry
:
casesMap
.
entrySet
())
{
BlockNode
c
=
getBlockByOffset
(
(
int
)
entry
.
getKey
(),
block
.
getSuccessors
());
BlockNode
c
=
getBlockByOffset
(
entry
.
getKey
(),
block
.
getSuccessors
());
assert
c
!=
null
;
assert
c
!=
null
;
blocksMap
.
put
(
c
,
entry
.
getValue
());
blocksMap
.
put
(
c
,
entry
.
getValue
());
}
}
...
@@ -648,7 +648,7 @@ public class RegionMaker {
...
@@ -648,7 +648,7 @@ public class RegionMaker {
if
(
out
!=
null
)
{
if
(
out
!=
null
)
{
stack
.
addExit
(
out
);
stack
.
addExit
(
out
);
}
else
{
}
else
{
for
(
BlockNode
e
:
BlockUtils
.
bit
s
etToBlocks
(
mth
,
domsOn
))
{
for
(
BlockNode
e
:
BlockUtils
.
bit
S
etToBlocks
(
mth
,
domsOn
))
{
stack
.
addExit
(
e
);
stack
.
addExit
(
e
);
}
}
}
}
...
@@ -689,7 +689,7 @@ public class RegionMaker {
...
@@ -689,7 +689,7 @@ public class RegionMaker {
handler
.
getHandlerRegion
().
getAttributes
().
add
(
excHandlerAttr
);
handler
.
getHandlerRegion
().
getAttributes
().
add
(
excHandlerAttr
);
}
}
private
boolean
isEqualReturns
(
BlockNode
b1
,
BlockNode
b2
)
{
private
static
boolean
isEqualReturns
(
BlockNode
b1
,
BlockNode
b2
)
{
if
(
b1
==
b2
)
{
if
(
b1
==
b2
)
{
return
true
;
return
true
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/TracedRegionVisitor.java
View file @
3c84975a
...
@@ -18,7 +18,7 @@ public abstract class TracedRegionVisitor implements IRegionVisitor {
...
@@ -18,7 +18,7 @@ public abstract class TracedRegionVisitor implements IRegionVisitor {
@Override
@Override
public
void
processBlock
(
MethodNode
mth
,
IBlock
container
)
{
public
void
processBlock
(
MethodNode
mth
,
IBlock
container
)
{
final
IRegion
curRegion
=
regionStack
.
peek
();
IRegion
curRegion
=
regionStack
.
peek
();
processBlockTraced
(
mth
,
container
,
curRegion
);
processBlockTraced
(
mth
,
container
,
curRegion
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeresolver/TypeResolver.java
View file @
3c84975a
...
@@ -2,6 +2,7 @@ package jadx.core.dex.visitors.typeresolver;
...
@@ -2,6 +2,7 @@ package jadx.core.dex.visitors.typeresolver;
import
jadx.core.dex.attributes.BlockRegState
;
import
jadx.core.dex.attributes.BlockRegState
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
...
@@ -34,20 +35,18 @@ public class TypeResolver extends AbstractVisitor {
...
@@ -34,20 +35,18 @@ public class TypeResolver extends AbstractVisitor {
/**
/**
* Check argument types (can be broken after merging debug info)
* Check argument types (can be broken after merging debug info)
*/
*/
private
void
prepare
(
MethodNode
mth
)
{
private
static
void
prepare
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
switch
(
insn
.
getType
())
{
if
(
insn
.
getType
()
==
InsnType
.
CHECK_CAST
)
{
case
CHECK_CAST:
ArgType
castType
=
(
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
();
ArgType
castType
=
(
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
();
insn
.
getResult
().
getTypedVar
().
forceSetType
(
castType
);
insn
.
getResult
().
getTypedVar
().
forceSetType
(
castType
);
break
;
}
}
}
}
}
}
}
}
private
void
visitBlocks
(
MethodNode
mth
)
{
private
static
void
visitBlocks
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
BlockRegState
state
=
new
BlockRegState
(
mth
);
BlockRegState
state
=
new
BlockRegState
(
mth
);
...
@@ -94,7 +93,7 @@ public class TypeResolver extends AbstractVisitor {
...
@@ -94,7 +93,7 @@ public class TypeResolver extends AbstractVisitor {
}
}
}
}
private
boolean
connectEdges
(
MethodNode
mth
,
BlockNode
from
,
BlockNode
to
,
boolean
back
)
{
private
static
boolean
connectEdges
(
MethodNode
mth
,
BlockNode
from
,
BlockNode
to
,
boolean
back
)
{
BlockRegState
end
=
from
.
getEndState
();
BlockRegState
end
=
from
.
getEndState
();
BlockRegState
start
=
to
.
getStartState
();
BlockRegState
start
=
to
.
getStartState
();
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeresolver/finish/CheckTypeVisitor.java
View file @
3c84975a
...
@@ -8,12 +8,11 @@ import jadx.core.utils.ErrorsCounter;
...
@@ -8,12 +8,11 @@ import jadx.core.utils.ErrorsCounter;
public
class
CheckTypeVisitor
{
public
class
CheckTypeVisitor
{
public
static
void
visit
(
MethodNode
mth
,
InsnNode
insn
)
{
public
static
void
visit
(
MethodNode
mth
,
InsnNode
insn
)
{
if
(
insn
.
getResult
()
!=
null
)
{
if
(
insn
.
getResult
()
!=
null
if
(
!
insn
.
getResult
().
getType
().
isTypeKnown
())
{
&&
!
insn
.
getResult
().
getType
().
isTypeKnown
())
{
error
(
"Wrong return type"
,
mth
,
insn
);
error
(
"Wrong return type"
,
mth
,
insn
);
return
;
return
;
}
}
}
for
(
InsnArg
arg
:
insn
.
getArguments
())
{
for
(
InsnArg
arg
:
insn
.
getArguments
())
{
if
(!
arg
.
getType
().
isTypeKnown
())
{
if
(!
arg
.
getType
().
isTypeKnown
())
{
...
...
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
View file @
3c84975a
...
@@ -51,6 +51,9 @@ public class BlockUtils {
...
@@ -51,6 +51,9 @@ public class BlockUtils {
}
}
public
static
boolean
isBackEdge
(
BlockNode
from
,
BlockNode
to
)
{
public
static
boolean
isBackEdge
(
BlockNode
from
,
BlockNode
to
)
{
if
(
to
==
null
)
{
return
false
;
}
if
(
from
.
getCleanSuccessors
().
contains
(
to
))
{
if
(
from
.
getCleanSuccessors
().
contains
(
to
))
{
return
false
;
// already checked
return
false
;
// already checked
}
}
...
@@ -69,16 +72,6 @@ public class BlockUtils {
...
@@ -69,16 +72,6 @@ public class BlockUtils {
}
}
}
}
public
static
BlockNode
canMergeNextBlock
(
BlockNode
block
)
{
BlockNode
next
=
getNextBlock
(
block
);
if
(
next
!=
null
)
{
if
(
next
.
getIDom
()
==
block
)
{
return
next
;
}
}
return
null
;
}
/**
/**
* Check if instruction contains in block (use == for comparison, not equals)
* Check if instruction contains in block (use == for comparison, not equals)
*/
*/
...
@@ -118,7 +111,7 @@ public class BlockUtils {
...
@@ -118,7 +111,7 @@ public class BlockUtils {
return
bs
;
return
bs
;
}
}
public
static
List
<
BlockNode
>
bit
s
etToBlocks
(
MethodNode
mth
,
BitSet
bs
)
{
public
static
List
<
BlockNode
>
bit
S
etToBlocks
(
MethodNode
mth
,
BitSet
bs
)
{
List
<
BlockNode
>
blocks
=
new
ArrayList
<
BlockNode
>(
bs
.
cardinality
());
List
<
BlockNode
>
blocks
=
new
ArrayList
<
BlockNode
>(
bs
.
cardinality
());
for
(
int
i
=
bs
.
nextSetBit
(
0
);
i
>=
0
;
i
=
bs
.
nextSetBit
(
i
+
1
))
{
for
(
int
i
=
bs
.
nextSetBit
(
0
);
i
>=
0
;
i
=
bs
.
nextSetBit
(
i
+
1
))
{
BlockNode
block
=
mth
.
getBasicBlocks
().
get
(
i
);
BlockNode
block
=
mth
.
getBasicBlocks
().
get
(
i
);
...
...
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
View file @
3c84975a
...
@@ -16,7 +16,7 @@ public class ErrorsCounter {
...
@@ -16,7 +16,7 @@ public class ErrorsCounter {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ErrorsCounter
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ErrorsCounter
.
class
);
private
static
final
Set
<
Object
>
ERROR_NODES
=
new
HashSet
<
Object
>();
private
static
final
Set
<
Object
>
ERROR_NODES
=
new
HashSet
<
Object
>();
private
static
int
errorsCount
=
0
;
private
static
int
errorsCount
;
public
static
int
getErrorCount
()
{
public
static
int
getErrorCount
()
{
return
errorsCount
;
return
errorsCount
;
...
...
jadx-core/src/main/java/jadx/core/utils/InsnUtils.java
View file @
3c84975a
...
@@ -46,7 +46,7 @@ public class InsnUtils {
...
@@ -46,7 +46,7 @@ public class InsnUtils {
if
(
index
instanceof
String
)
{
if
(
index
instanceof
String
)
{
return
"\""
+
index
+
"\""
;
return
"\""
+
index
+
"\""
;
}
else
{
}
else
{
return
" "
+
index
.
toString
()
;
return
" "
+
index
;
}
}
}
}
}
}
jadx-core/src/main/java/jadx/core/utils/RegionUtils.java
View file @
3c84975a
...
@@ -77,7 +77,6 @@ public class RegionUtils {
...
@@ -77,7 +77,6 @@ public class RegionUtils {
if
(
container
==
region
)
{
if
(
container
==
region
)
{
return
true
;
return
true
;
}
}
if
(
container
instanceof
IRegion
)
{
if
(
container
instanceof
IRegion
)
{
IRegion
r
=
(
IRegion
)
container
;
IRegion
r
=
(
IRegion
)
container
;
...
@@ -92,12 +91,11 @@ public class RegionUtils {
...
@@ -92,12 +91,11 @@ public class RegionUtils {
return
true
;
return
true
;
}
}
}
}
if
(
tb
.
getFinalBlock
()
!=
null
)
{
if
(
tb
.
getFinalBlock
()
!=
null
if
(
isRegionContainsRegion
(
tb
.
getFinalBlock
(),
region
))
{
&&
isRegionContainsRegion
(
tb
.
getFinalBlock
(),
region
))
{
return
true
;
return
true
;
}
}
}
}
}
if
(
isRegionContainsRegion
(
b
,
region
))
{
if
(
isRegionContainsRegion
(
b
,
region
))
{
return
true
;
return
true
;
}
}
...
...
jadx-core/src/test/java/jadx/api/InternalJadxTest.java
View file @
3c84975a
package
jadx
.
api
;
package
jadx
.
api
;
import
jadx.core.Jadx
;
import
jadx.core.Jadx
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.visitors.DepthTraverser
;
import
jadx.core.dex.visitors.DepthTraverser
;
...
@@ -19,6 +20,7 @@ import java.util.jar.JarEntry;
...
@@ -19,6 +20,7 @@ import java.util.jar.JarEntry;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.JarOutputStream
;
import
static
junit
.
framework
.
Assert
.
assertEquals
;
import
static
junit
.
framework
.
Assert
.
assertEquals
;
import
static
junit
.
framework
.
Assert
.
assertFalse
;
import
static
junit
.
framework
.
Assert
.
assertNotNull
;
import
static
junit
.
framework
.
Assert
.
assertNotNull
;
import
static
junit
.
framework
.
Assert
.
fail
;
import
static
junit
.
framework
.
Assert
.
fail
;
...
@@ -65,6 +67,7 @@ public abstract class InternalJadxTest {
...
@@ -65,6 +67,7 @@ public abstract class InternalJadxTest {
for
(
IDexTreeVisitor
visitor
:
passes
)
{
for
(
IDexTreeVisitor
visitor
:
passes
)
{
DepthTraverser
.
visit
(
visitor
,
cls
);
DepthTraverser
.
visit
(
visitor
,
cls
);
}
}
assertFalse
(
cls
.
getAttributes
().
contains
(
AttributeFlag
.
INCONSISTENT_CODE
));
return
cls
;
return
cls
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
fail
(
e
.
getMessage
());
fail
(
e
.
getMessage
());
...
...
jadx-core/src/test/java/jadx/tests/internal/inline/TestSyntheticInline.java
0 → 100644
View file @
3c84975a
package
jadx
.
tests
.
internal
.
inline
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestSyntheticInline
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
int
f
;
private
int
func
()
{
return
-
1
;
}
public
class
A
{
public
int
getF
()
{
return
f
;
}
public
void
setF
(
int
v
)
{
f
=
v
;
}
public
int
callFunc
()
{
return
func
();
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
not
(
containsString
(
"synthetic"
)));
assertThat
(
code
,
not
(
containsString
(
"access$"
)));
assertThat
(
code
,
not
(
containsString
(
"x0"
)));
assertThat
(
code
,
containsString
(
"return f;"
));
assertThat
(
code
,
containsString
(
"return func();"
));
assertThat
(
code
,
containsString
(
"f = v;"
));
}
}
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
View file @
3c84975a
...
@@ -45,20 +45,19 @@ public class JClass extends JNode {
...
@@ -45,20 +45,19 @@ public class JClass extends JNode {
if
(!
loaded
)
{
if
(!
loaded
)
{
cls
.
decompile
();
cls
.
decompile
();
loaded
=
true
;
loaded
=
true
;
update
Childs
();
update
();
}
}
}
}
@Override
public
synchronized
void
update
()
{
public
synchronized
void
updateChilds
()
{
removeAllChildren
();
removeAllChildren
();
if
(!
loaded
)
{
if
(!
loaded
)
{
add
(
new
TextNode
(
NLS
.
str
(
"tree.loading"
)));
add
(
new
TextNode
(
NLS
.
str
(
"tree.loading"
)));
}
else
{
}
else
{
for
(
JavaClass
javaClass
:
cls
.
getInnerClasses
())
{
for
(
JavaClass
javaClass
:
cls
.
getInnerClasses
())
{
JClass
child
=
new
JClass
(
javaClass
,
this
);
JClass
innerCls
=
new
JClass
(
javaClass
,
this
);
add
(
child
);
add
(
innerCls
);
child
.
updateChilds
();
innerCls
.
update
();
}
}
for
(
JavaField
f
:
cls
.
getFields
())
{
for
(
JavaField
f
:
cls
.
getFields
())
{
add
(
new
JField
(
f
,
this
));
add
(
new
JField
(
f
,
this
));
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JField.java
View file @
3c84975a
...
@@ -28,10 +28,6 @@ public class JField extends JNode {
...
@@ -28,10 +28,6 @@ public class JField extends JNode {
}
}
@Override
@Override
public
void
updateChilds
()
{
}
@Override
public
JClass
getJParent
()
{
public
JClass
getJParent
()
{
return
jParent
;
return
jParent
;
}
}
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
View file @
3c84975a
...
@@ -30,10 +30,6 @@ public class JMethod extends JNode {
...
@@ -30,10 +30,6 @@ public class JMethod extends JNode {
}
}
@Override
@Override
public
void
updateChilds
()
{
}
@Override
public
JClass
getJParent
()
{
public
JClass
getJParent
()
{
return
jParent
;
return
jParent
;
}
}
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JNode.java
View file @
3c84975a
...
@@ -16,7 +16,5 @@ public abstract class JNode extends DefaultMutableTreeNode {
...
@@ -16,7 +16,5 @@ public abstract class JNode extends DefaultMutableTreeNode {
public
abstract
int
getLine
();
public
abstract
int
getLine
();
public
abstract
void
updateChilds
();
public
abstract
Icon
getIcon
();
public
abstract
Icon
getIcon
();
}
}
jadx-gui/src/main/java/jadx/gui/treemodel/JPackage.java
View file @
3c84975a
...
@@ -25,7 +25,7 @@ public class JPackage extends JNode implements Comparable<JPackage> {
...
@@ -25,7 +25,7 @@ public class JPackage extends JNode implements Comparable<JPackage> {
for
(
JavaClass
javaClass
:
javaClasses
)
{
for
(
JavaClass
javaClass
:
javaClasses
)
{
classes
.
add
(
new
JClass
(
javaClass
));
classes
.
add
(
new
JClass
(
javaClass
));
}
}
update
Childs
();
update
();
}
}
public
JPackage
(
String
name
)
{
public
JPackage
(
String
name
)
{
...
@@ -33,15 +33,14 @@ public class JPackage extends JNode implements Comparable<JPackage> {
...
@@ -33,15 +33,14 @@ public class JPackage extends JNode implements Comparable<JPackage> {
this
.
classes
=
new
ArrayList
<
JClass
>(
1
);
this
.
classes
=
new
ArrayList
<
JClass
>(
1
);
}
}
@Override
public
void
update
()
{
public
void
updateChilds
()
{
removeAllChildren
();
removeAllChildren
();
for
(
JPackage
pkg
:
innerPackages
)
{
for
(
JPackage
pkg
:
innerPackages
)
{
pkg
.
update
Childs
();
pkg
.
update
();
add
(
pkg
);
add
(
pkg
);
}
}
for
(
JClass
cls
:
classes
)
{
for
(
JClass
cls
:
classes
)
{
cls
.
update
Childs
();
cls
.
update
();
add
(
cls
);
add
(
cls
);
}
}
}
}
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java
View file @
3c84975a
...
@@ -27,11 +27,10 @@ public class JRoot extends JNode {
...
@@ -27,11 +27,10 @@ public class JRoot extends JNode {
public
JRoot
(
JadxWrapper
wrapper
)
{
public
JRoot
(
JadxWrapper
wrapper
)
{
this
.
wrapper
=
wrapper
;
this
.
wrapper
=
wrapper
;
update
Childs
();
update
();
}
}
@Override
public
void
update
()
{
public
void
updateChilds
()
{
removeAllChildren
();
removeAllChildren
();
if
(
flatPackages
)
{
if
(
flatPackages
)
{
for
(
JavaPackage
pkg
:
wrapper
.
getPackages
())
{
for
(
JavaPackage
pkg
:
wrapper
.
getPackages
())
{
...
@@ -41,7 +40,7 @@ public class JRoot extends JNode {
...
@@ -41,7 +40,7 @@ public class JRoot extends JNode {
// build packages hierarchy
// build packages hierarchy
List
<
JPackage
>
rootPkgs
=
getHierarchyPackages
(
wrapper
.
getPackages
());
List
<
JPackage
>
rootPkgs
=
getHierarchyPackages
(
wrapper
.
getPackages
());
for
(
JPackage
jPackage
:
rootPkgs
)
{
for
(
JPackage
jPackage
:
rootPkgs
)
{
jPackage
.
update
Childs
();
jPackage
.
update
();
add
(
jPackage
);
add
(
jPackage
);
}
}
}
}
...
@@ -88,7 +87,7 @@ public class JRoot extends JNode {
...
@@ -88,7 +87,7 @@ public class JRoot extends JNode {
}
}
// use identity set for collect inner packages
// use identity set for collect inner packages
Set
<
JPackage
>
innerPackages
=
Collections
.
newSetFromMap
(
new
IdentityHashMap
<
JPackage
,
Boolean
>());
Set
<
JPackage
>
innerPackages
=
Collections
.
newSetFromMap
(
new
IdentityHashMap
<
JPackage
,
Boolean
>());
for
(
JPackage
pkg
:
pkgMap
.
values
())
{
for
(
JPackage
pkg
:
pkgMap
.
values
())
{
innerPackages
.
addAll
(
pkg
.
getInnerPackages
());
innerPackages
.
addAll
(
pkg
.
getInnerPackages
());
}
}
...
@@ -131,7 +130,7 @@ public class JRoot extends JNode {
...
@@ -131,7 +130,7 @@ public class JRoot extends JNode {
public
void
setFlatPackages
(
boolean
flatPackages
)
{
public
void
setFlatPackages
(
boolean
flatPackages
)
{
if
(
this
.
flatPackages
!=
flatPackages
)
{
if
(
this
.
flatPackages
!=
flatPackages
)
{
this
.
flatPackages
=
flatPackages
;
this
.
flatPackages
=
flatPackages
;
update
Childs
();
update
();
}
}
}
}
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/TextNode.java
View file @
3c84975a
...
@@ -20,10 +20,6 @@ public class TextNode extends JNode {
...
@@ -20,10 +20,6 @@ public class TextNode extends JNode {
}
}
@Override
@Override
public
void
updateChilds
()
{
}
@Override
public
Icon
getIcon
()
{
public
Icon
getIcon
()
{
return
null
;
return
null
;
}
}
...
...
jadx-gui/src/main/java/jadx/gui/utils/Utils.java
View file @
3c84975a
...
@@ -67,10 +67,18 @@ public class Utils {
...
@@ -67,10 +67,18 @@ public class Utils {
icon
=
def
;
icon
=
def
;
}
}
OverlayIcon
overIcon
=
new
OverlayIcon
(
icon
);
OverlayIcon
overIcon
=
new
OverlayIcon
(
icon
);
if
(
af
.
isFinal
())
overIcon
.
add
(
ICON_FINAL
);
if
(
af
.
isFinal
())
{
if
(
af
.
isStatic
())
overIcon
.
add
(
ICON_STATIC
);
overIcon
.
add
(
ICON_FINAL
);
if
(
af
.
isAbstract
())
overIcon
.
add
(
ICON_ABSTRACT
);
}
if
(
af
.
isNative
())
overIcon
.
add
(
ICON_NATIVE
);
if
(
af
.
isStatic
())
{
overIcon
.
add
(
ICON_STATIC
);
}
if
(
af
.
isAbstract
())
{
overIcon
.
add
(
ICON_ABSTRACT
);
}
if
(
af
.
isNative
())
{
overIcon
.
add
(
ICON_NATIVE
);
}
return
overIcon
;
return
overIcon
;
}
}
}
}
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