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
d5740c1b
Commit
d5740c1b
authored
Apr 07, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix 'finally' extract in 'if'
parent
3357979c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
4 deletions
+77
-4
BlockFinallyExtract.java
...dx/core/dex/visitors/blocksmaker/BlockFinallyExtract.java
+6
-4
TestTryCatchFinally5.java
...jadx/tests/integration/trycatch/TestTryCatchFinally5.java
+71
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockFinallyExtract.java
View file @
d5740c1b
...
...
@@ -34,6 +34,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
static
jadx
.
core
.
dex
.
visitors
.
blocksmaker
.
BlockSplitter
.
connect
;
import
static
jadx
.
core
.
dex
.
visitors
.
blocksmaker
.
BlockSplitter
.
insertBlockBetween
;
import
static
jadx
.
core
.
dex
.
visitors
.
blocksmaker
.
BlockSplitter
.
removeConnection
;
public
class
BlockFinallyExtract
extends
AbstractVisitor
{
...
...
@@ -511,10 +512,11 @@ public class BlockFinallyExtract extends AbstractVisitor {
// redirect input edges
for
(
BlockNode
pred
:
new
ArrayList
<
BlockNode
>(
remBlock
.
getPredecessors
()))
{
removeConnection
(
pred
,
remBlock
);
connect
(
pred
,
startBlock
);
addIgnoredEdge
(
pred
,
startBlock
);
connect
(
pred
,
rOut
);
BlockNode
middle
=
insertBlockBetween
(
mth
,
pred
,
remBlock
);
removeConnection
(
middle
,
remBlock
);
connect
(
middle
,
startBlock
);
addIgnoredEdge
(
middle
,
startBlock
);
connect
(
middle
,
rOut
);
}
// mark blocks for remove
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally5.java
0 → 100644
View file @
d5740c1b
package
jadx
.
tests
.
integration
.
trycatch
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestTryCatchFinally5
extends
IntegrationTest
{
public
static
class
TestCls
{
private
<
E
>
List
<
E
>
test
(
A
a
,
B
<
E
>
b
)
{
C
c
=
p
(
a
);
if
(
c
==
null
)
{
return
null
;
}
D
d
=
b
.
f
(
c
);
try
{
if
(!
d
.
first
())
{
return
null
;
}
List
<
E
>
list
=
new
ArrayList
<
E
>();
do
{
list
.
add
(
b
.
load
(
d
));
}
while
(
d
.
toNext
());
return
list
;
}
finally
{
d
.
close
();
}
}
private
C
p
(
A
a
)
{
return
(
C
)
a
;
}
private
interface
A
{
}
private
interface
B
<
T
>
{
D
f
(
C
c
);
T
load
(
D
d
);
}
private
interface
C
{
}
private
interface
D
{
boolean
first
();
boolean
toNext
();
void
close
();
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"} finally {"
));
// TODO: remove duplicates on multiple paths
// assertThat(code, containsOne("d.close();"));
}
}
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