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
85a18e6d
Commit
85a18e6d
authored
May 02, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: don't insert break in method exit blocks (fix #60)
parent
5d86bf97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
3 deletions
+57
-3
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+6
-3
TestBreakInLoop2.java
...t/java/jadx/tests/integration/loops/TestBreakInLoop2.java
+51
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
85a18e6d
...
...
@@ -353,9 +353,12 @@ public class RegionMaker {
return
false
;
}
List
<
BlockNode
>
simplePath
=
BlockUtils
.
buildSimplePath
(
exit
);
if
(!
simplePath
.
isEmpty
()
&&
simplePath
.
get
(
simplePath
.
size
()
-
1
).
contains
(
AFlag
.
RETURN
))
{
return
false
;
if
(!
simplePath
.
isEmpty
())
{
BlockNode
lastBlock
=
simplePath
.
get
(
simplePath
.
size
()
-
1
);
if
(
lastBlock
.
contains
(
AFlag
.
RETURN
)
||
lastBlock
.
getSuccessors
().
isEmpty
())
{
return
false
;
}
}
// check if there no outer switch (TODO: very expensive check)
Set
<
BlockNode
>
paths
=
BlockUtils
.
getAllPathsBlocks
(
mth
.
getEnterBlock
(),
exit
);
...
...
jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop2.java
0 → 100644
View file @
85a18e6d
package
jadx
.
tests
.
integration
.
loops
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
java.util.List
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestBreakInLoop2
extends
IntegrationTest
{
public
static
class
TestCls
{
public
void
test
(
List
<
Integer
>
data
)
throws
Exception
{
for
(;
;
)
{
try
{
funcB
(
data
);
break
;
}
catch
(
Exception
ex
)
{
if
(
funcC
())
{
throw
ex
;
}
data
.
clear
();
}
Thread
.
sleep
(
100
);
}
}
private
boolean
funcB
(
List
<
Integer
>
data
)
{
return
false
;
}
private
boolean
funcC
()
{
return
true
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"while (true) {"
));
assertThat
(
code
,
containsOne
(
"break;"
));
assertThat
(
code
,
containsOne
(
"throw ex;"
));
assertThat
(
code
,
containsOne
(
"data.clear();"
));
assertThat
(
code
,
containsOne
(
"Thread.sleep(100);"
));
}
}
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