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
41cc83db
Commit
41cc83db
authored
Jul 07, 2014
by
fruiter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix nested try-catch blocks processing
parent
ce7101be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
+52
-5
ProcessTryCatchRegions.java
...adx/core/dex/visitors/regions/ProcessTryCatchRegions.java
+11
-5
TestNestedTryCatch.java
...java/jadx/tests/internal/trycatch/TestNestedTryCatch.java
+41
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessTryCatchRegions.java
View file @
41cc83db
...
...
@@ -101,10 +101,14 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
// search dominator blocks in this region (don't need to go deeper)
for
(
BlockNode
dominator
:
tryBlocksMap
.
keySet
())
{
if
(
region
.
getSubBlocks
().
contains
(
dominator
))
{
wrapBlocks
(
region
,
dominator
);
Region
newRegion
=
wrapBlocks
(
region
,
dominator
);
tryBlocksMap
.
remove
(
dominator
);
// if region is modified rerun this method
leaveRegion
(
mth
,
region
);
if
(
newRegion
!=
null
)
{
// dominator may be moved into new region
leaveRegion
(
mth
,
newRegion
);
// if region is modified rerun this method
leaveRegion
(
mth
,
region
);
}
return
;
}
}
...
...
@@ -113,7 +117,7 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
/**
* Extract all block dominated by 'dominator' to separate region and mark as try/catch block
*/
private
void
wrapBlocks
(
IRegion
region
,
BlockNode
dominator
)
{
private
Region
wrapBlocks
(
IRegion
region
,
BlockNode
dominator
)
{
Region
newRegion
=
new
Region
(
region
);
TryCatchBlock
tb
=
tryBlocksMap
.
get
(
dominator
);
assert
tb
!=
null
;
...
...
@@ -127,7 +131,7 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
}
}
if
(
newRegion
.
getSubBlocks
().
isEmpty
())
{
return
;
return
null
;
}
if
(
DEBUG
)
{
LOG
.
debug
(
"ProcessTryCatchRegions mark: {}"
,
newRegion
);
...
...
@@ -147,6 +151,8 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
aReg
.
setParent
(
newRegion
);
}
}
return
newRegion
;
}
private
boolean
isHandlerPath
(
TryCatchBlock
tb
,
IContainer
cont
)
{
...
...
jadx-core/src/test/java/jadx/tests/internal/trycatch/TestNestedTryCatch.java
0 → 100644
View file @
41cc83db
package
jadx
.
tests
.
internal
.
trycatch
;
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
TestNestedTryCatch
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
void
f
()
{
try
{
Thread
.
sleep
(
1
);
try
{
Thread
.
sleep
(
2
);
}
catch
(
InterruptedException
e
)
{
}
}
catch
(
Exception
e
)
{
}
return
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"try {"
));
assertThat
(
code
,
containsString
(
"Thread.sleep(1);"
));
assertThat
(
code
,
containsString
(
"Thread.sleep(2);"
));
assertThat
(
code
,
containsString
(
"} catch (InterruptedException e) {"
));
assertThat
(
code
,
containsString
(
"} catch (Exception e2) {"
));
assertThat
(
code
,
not
(
containsString
(
"return"
)));
}
}
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