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
9645f33c
Commit
9645f33c
authored
Apr 24, 2019
by
Ahmed Ashour
Committed by
skylot
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: bitwise or/and with non-boolean (#628) (PR #629)
parent
336d6ce1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
9 deletions
+47
-9
IfCondition.java
...in/java/jadx/core/dex/regions/conditions/IfCondition.java
+12
-9
TestConditions17.java
...a/jadx/tests/integration/conditions/TestConditions17.java
+35
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfCondition.java
View file @
9645f33c
...
...
@@ -12,6 +12,7 @@ import jadx.core.dex.instructions.ArithNode;
import
jadx.core.dex.instructions.ArithOp
;
import
jadx.core.dex.instructions.IfNode
;
import
jadx.core.dex.instructions.IfOp
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
import
jadx.core.dex.instructions.args.LiteralArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
...
...
@@ -221,21 +222,23 @@ public final class IfCondition {
break
;
case
ARITH:
ArithOp
arithOp
=
((
ArithNode
)
wrapInsn
).
getOp
();
if
(
arithOp
==
ArithOp
.
OR
||
arithOp
==
ArithOp
.
AND
)
{
IfOp
ifOp
=
c
.
getInsn
().
getOp
();
boolean
isTrue
=
ifOp
==
IfOp
.
NE
&&
lit
==
0
if
(
c
.
getB
().
getType
()
==
ArgType
.
BOOLEAN
)
{
ArithOp
arithOp
=
((
ArithNode
)
wrapInsn
).
getOp
();
if
(
arithOp
==
ArithOp
.
OR
||
arithOp
==
ArithOp
.
AND
)
{
IfOp
ifOp
=
c
.
getInsn
().
getOp
();
boolean
isTrue
=
ifOp
==
IfOp
.
NE
&&
lit
==
0
||
ifOp
==
IfOp
.
EQ
&&
lit
==
1
;
IfOp
op
=
isTrue
?
IfOp
.
NE
:
IfOp
.
EQ
;
Mode
mode
=
isTrue
&&
arithOp
==
ArithOp
.
OR
||
IfOp
op
=
isTrue
?
IfOp
.
NE
:
IfOp
.
EQ
;
Mode
mode
=
isTrue
&&
arithOp
==
ArithOp
.
OR
||
!
isTrue
&&
arithOp
==
ArithOp
.
AND
?
Mode
.
OR
:
Mode
.
AND
;
IfNode
if1
=
new
IfNode
(
op
,
-
1
,
wrapInsn
.
getArg
(
0
),
LiteralArg
.
FALSE
);
IfNode
if2
=
new
IfNode
(
op
,
-
1
,
wrapInsn
.
getArg
(
1
),
LiteralArg
.
FALSE
);
return
new
IfCondition
(
mode
,
IfNode
if1
=
new
IfNode
(
op
,
-
1
,
wrapInsn
.
getArg
(
0
),
LiteralArg
.
FALSE
);
IfNode
if2
=
new
IfNode
(
op
,
-
1
,
wrapInsn
.
getArg
(
1
),
LiteralArg
.
FALSE
);
return
new
IfCondition
(
mode
,
Arrays
.
asList
(
new
IfCondition
(
new
Compare
(
if1
)),
new
IfCondition
(
new
Compare
(
if2
))));
}
}
break
;
...
...
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions17.java
0 → 100644
View file @
9645f33c
package
jadx
.
tests
.
integration
.
conditions
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
public
class
TestConditions17
extends
IntegrationTest
{
public
static
class
TestCls
{
public
static
final
int
SOMETHING
=
2
;
public
static
void
test
(
int
a
)
{
if
((
a
&
SOMETHING
)
!=
0
)
{
print
(
1
);
}
print
(
2
);
}
public
static
void
print
(
Object
o
)
{
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
" & "
));
}
}
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