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
4ace552a
Commit
4ace552a
authored
Feb 22, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix duplicate cast
parent
b61daaed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
20 deletions
+15
-20
TypeResolver.java
...ava/jadx/core/dex/visitors/typeresolver/TypeResolver.java
+0
-19
PostTypeResolver.java
...re/dex/visitors/typeresolver/finish/PostTypeResolver.java
+8
-0
TestDuplicateCast.java
.../src/test/java/jadx/tests/internal/TestDuplicateCast.java
+7
-1
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/typeresolver/TypeResolver.java
View file @
4ace552a
package
jadx
.
core
.
dex
.
visitors
.
typeresolver
;
import
jadx.core.dex.attributes.BlockRegState
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.nodes.BlockNode
;
...
...
@@ -20,8 +17,6 @@ public class TypeResolver extends AbstractVisitor {
if
(
mth
.
isNoCode
())
{
return
;
}
prepare
(
mth
);
visitBlocks
(
mth
);
visitEdges
(
mth
);
...
...
@@ -32,20 +27,6 @@ public class TypeResolver extends AbstractVisitor {
}
}
/**
* Check argument types (can be broken after merging debug info)
*/
private
static
void
prepare
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
if
(
insn
.
getType
()
==
InsnType
.
CHECK_CAST
)
{
ArgType
castType
=
(
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
();
insn
.
getResult
().
getTypedVar
().
forceSetType
(
castType
);
}
}
}
}
private
static
void
visitBlocks
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
BlockRegState
state
=
new
BlockRegState
(
mth
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeresolver/finish/PostTypeResolver.java
View file @
4ace552a
package
jadx
.
core
.
dex
.
visitors
.
typeresolver
.
finish
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InvokeNode
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
...
...
@@ -85,6 +86,13 @@ public class PostTypeResolver {
return
change
;
}
case
CHECK_CAST:
{
ArgType
castType
=
(
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
();
// workaround for compiler bug (see TestDuplicateCast)
insn
.
getResult
().
getTypedVar
().
forceSetType
(
castType
);
return
true
;
}
default
:
break
;
}
...
...
jadx-core/src/test/java/jadx/tests/internal/TestDuplicateCast.java
View file @
4ace552a
...
...
@@ -9,12 +9,18 @@ import jadx.core.dex.nodes.MethodNode;
import
java.util.List
;
import
org.junit.Test
;
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
;
/**
* Test duplicate 'check-cast' instruction produced because of bug in javac:
* http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6246854
*/
public
class
TestDuplicateCast
extends
InternalJadxTest
{
public
static
class
TestCls
{
...
...
@@ -23,7 +29,7 @@ public class TestDuplicateCast extends InternalJadxTest {
}
}
//
@Test
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
MethodNode
mth
=
getMethod
(
cls
,
"method"
);
...
...
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