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
a959af08
Commit
a959af08
authored
Jul 19, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix replace target in if instruction (#317)
parent
c5994f95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
IfNode.java
...core/src/main/java/jadx/core/dex/instructions/IfNode.java
+4
-3
TestSwitchReturnFromCase2.java
...tests/integration/switches/TestSwitchReturnFromCase2.java
+44
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/instructions/IfNode.java
View file @
a959af08
...
@@ -68,15 +68,16 @@ public class IfNode extends GotoNode {
...
@@ -68,15 +68,16 @@ public class IfNode extends GotoNode {
@Override
@Override
public
boolean
replaceTargetBlock
(
BlockNode
origin
,
BlockNode
replace
)
{
public
boolean
replaceTargetBlock
(
BlockNode
origin
,
BlockNode
replace
)
{
boolean
replaced
=
false
;
if
(
thenBlock
==
origin
)
{
if
(
thenBlock
==
origin
)
{
thenBlock
=
replace
;
thenBlock
=
replace
;
re
turn
true
;
re
placed
=
true
;
}
}
if
(
elseBlock
==
origin
)
{
if
(
elseBlock
==
origin
)
{
elseBlock
=
replace
;
elseBlock
=
replace
;
re
turn
true
;
re
placed
=
true
;
}
}
return
false
;
return
replaced
;
}
}
public
BlockNode
getThenBlock
()
{
public
BlockNode
getThenBlock
()
{
...
...
jadx-core/src/test/java/jadx/tests/integration/switches/TestSwitchReturnFromCase2.java
0 → 100644
View file @
a959af08
package
jadx
.
tests
.
integration
.
switches
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestSwitchReturnFromCase2
extends
IntegrationTest
{
public
static
class
TestCls
{
public
boolean
test
(
int
a
)
{
switch
(
a
%
4
)
{
case
2
:
case
3
:
if
(
a
==
2
)
{
return
true
;
}
return
true
;
}
return
false
;
}
public
void
check
()
{
assertTrue
(
test
(
2
));
assertTrue
(
test
(
3
));
assertTrue
(
test
(
15
));
assertFalse
(
test
(
1
));
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"switch (a % 4) {"
));
}
}
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