Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
58998089
Commit
58998089
authored
Aug 07, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: redone 'if' structure checking
parent
f0a73b32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
18 deletions
+65
-18
IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+8
-18
TestIfInTry.java
...src/test/java/jadx/tests/internal/others/TestIfInTry.java
+57
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
View file @
58998089
...
...
@@ -50,26 +50,16 @@ public class IfMakerHelper {
boolean
badThen
=
!
allPathsFromIf
(
thenBlock
,
info
);
boolean
badElse
=
!
allPathsFromIf
(
elseBlock
,
info
);
if
(
badThen
&&
badElse
)
{
LOG
.
debug
(
"Stop processing blocks after 'if': {}, method: {}"
,
info
,
mth
);
return
null
;
}
if
(
badThen
||
badElse
)
{
if
(
badElse
&&
isPathExists
(
thenBlock
,
elseBlock
))
{
info
=
new
IfInfo
(
info
.
getCondition
(),
thenBlock
,
null
);
info
.
setOutBlock
(
elseBlock
);
}
else
if
(
badThen
&&
isPathExists
(
elseBlock
,
thenBlock
))
{
info
=
IfInfo
.
invert
(
info
);
info
=
new
IfInfo
(
info
.
getCondition
(),
info
.
getThenBlock
(),
null
);
info
.
setOutBlock
(
thenBlock
);
}
else
if
(
badElse
)
{
info
=
new
IfInfo
(
info
.
getCondition
(),
thenBlock
,
null
);
info
.
setOutBlock
(
null
);
LOG
.
debug
(
"Stop processing blocks after bad 'else' in 'if': {}, method: {}"
,
info
,
mth
);
}
else
{
info
=
IfInfo
.
invert
(
info
);
info
=
new
IfInfo
(
info
.
getCondition
(),
info
.
getThenBlock
(),
null
);
info
.
setOutBlock
(
null
);
LOG
.
debug
(
"Stop processing blocks after bad 'then' in 'if': {}, method: {}"
,
info
,
mth
);
}
if
(
badElse
)
{
info
=
new
IfInfo
(
info
.
getCondition
(),
thenBlock
,
null
);
info
.
setOutBlock
(
elseBlock
);
}
else
if
(
badThen
)
{
info
=
IfInfo
.
invert
(
info
);
info
=
new
IfInfo
(
info
.
getCondition
(),
elseBlock
,
null
);
info
.
setOutBlock
(
thenBlock
);
}
else
{
List
<
BlockNode
>
thenSC
=
thenBlock
.
getCleanSuccessors
();
List
<
BlockNode
>
elseSC
=
elseBlock
.
getCleanSuccessors
();
...
...
jadx-core/src/test/java/jadx/tests/internal/others/TestIfInTry.java
0 → 100644
View file @
58998089
package
jadx
.
tests
.
internal
.
others
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
java.io.File
;
import
java.io.IOException
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
countString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestIfInTry
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
File
dir
;
public
int
test
()
{
try
{
int
a
=
f
();
if
(
a
!=
0
)
{
return
a
;
}
}
catch
(
Exception
e
)
{
// skip
}
try
{
f
();
return
1
;
}
catch
(
IOException
e
)
{
return
-
1
;
}
}
private
int
f
()
throws
IOException
{
return
0
;
}
}
@Test
public
void
test
()
{
setOutputCFG
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"if (a != 0) {"
));
assertThat
(
code
,
containsOne
(
"} catch (Exception e) {"
));
assertThat
(
code
,
countString
(
2
,
"try {"
));
assertThat
(
code
,
countString
(
3
,
"f()"
));
assertThat
(
code
,
containsOne
(
"return 1;"
));
assertThat
(
code
,
containsOne
(
"} catch (IOException e"
));
assertThat
(
code
,
containsOne
(
"return -1;"
));
}
}
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