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
d10efec1
Commit
d10efec1
authored
Feb 13, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix type for one time used args
parent
3f08c99f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
5 deletions
+39
-5
InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+1
-1
ConstInlinerVisitor.java
...main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
+9
-4
TestWrongCode.java
...core/src/test/java/jadx/tests/internal/TestWrongCode.java
+29
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
View file @
d10efec1
...
...
@@ -473,7 +473,7 @@ public class InsnDecoder {
case
Opcodes
.
ARRAY_LENGTH
:
{
InsnNode
node
=
new
InsnNode
(
InsnType
.
ARRAY_LENGTH
,
1
);
node
.
setResult
(
InsnArg
.
reg
(
insn
,
0
,
ArgType
.
INT
));
node
.
addArg
(
InsnArg
.
reg
(
insn
,
1
,
ArgType
.
unknown
(
PrimitiveType
.
ARRAY
)));
node
.
addArg
(
InsnArg
.
reg
(
insn
,
1
,
ArgType
.
array
(
ArgType
.
UNKNOWN
)));
return
node
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
View file @
d10efec1
...
...
@@ -54,7 +54,6 @@ public class ConstInlinerVisitor extends AbstractVisitor {
private
static
boolean
replaceConst
(
MethodNode
mth
,
BlockNode
block
,
InsnNode
insn
,
long
literal
)
{
List
<
InsnArg
>
use
=
insn
.
getResult
().
getTypedVar
().
getUseList
();
int
replace
=
0
;
for
(
InsnArg
arg
:
use
)
{
InsnNode
useInsn
=
arg
.
getParentInsn
();
...
...
@@ -64,9 +63,15 @@ public class ConstInlinerVisitor extends AbstractVisitor {
BlockNode
useBlock
=
BlockUtils
.
getBlockByInsn
(
mth
,
useInsn
);
if
(
useBlock
==
block
||
useBlock
.
isDominator
(
block
))
{
if
(
arg
!=
insn
.
getResult
()
&&
!
registerReassignOnPath
(
block
,
useBlock
,
insn
))
{
// in most cases type not equal arg.getType()
// just set unknown type and run type fixer
LiteralArg
litArg
=
InsnArg
.
lit
(
literal
,
ArgType
.
UNKNOWN
);
LiteralArg
litArg
;
if
(
use
.
size
()
==
2
)
{
// arg used only in one place
litArg
=
InsnArg
.
lit
(
literal
,
arg
.
getType
());
}
else
{
// in most cases type not equal arg.getType()
// just set unknown type and run type fixer
litArg
=
InsnArg
.
lit
(
literal
,
ArgType
.
UNKNOWN
);
}
if
(
useInsn
.
replaceArg
(
arg
,
litArg
))
{
fixTypes
(
mth
,
useInsn
,
litArg
);
replace
++;
...
...
jadx-core/src/test/java/jadx/tests/internal/TestWrongCode.java
0 → 100644
View file @
d10efec1
package
jadx
.
tests
.
internal
;
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
TestWrongCode
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
int
f
()
{
int
[]
a
=
null
;
return
a
.
length
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
not
(
containsString
(
"return false.length;"
)));
assertThat
(
code
,
containsString
(
"return null.length;"
));
}
}
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