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
6a1717a6
Commit
6a1717a6
authored
Dec 15, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: use original call class for invoke inherited methods (#413)
parent
ee6508e9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
8 deletions
+54
-8
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+13
-7
DependencyCollector.java
...main/java/jadx/core/dex/visitors/DependencyCollector.java
+4
-0
CodegenUtils.java
jadx-core/src/main/java/jadx/core/utils/CodegenUtils.java
+1
-1
TestInheritedStaticInvoke.java
...x/tests/integration/invoke/TestInheritedStaticInvoke.java
+36
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
6a1717a6
...
@@ -602,11 +602,8 @@ public class InsnGen {
...
@@ -602,11 +602,8 @@ public class InsnGen {
// inline method
// inline method
MethodNode
callMthNode
=
mth
.
root
().
deepResolveMethod
(
callMth
);
MethodNode
callMthNode
=
mth
.
root
().
deepResolveMethod
(
callMth
);
if
(
callMthNode
!=
null
)
{
if
(
callMthNode
!=
null
&&
inlineMethod
(
callMthNode
,
insn
,
code
))
{
if
(
inlineMethod
(
callMthNode
,
insn
,
code
))
{
return
;
return
;
}
callMth
=
callMthNode
.
getMethodInfo
();
}
}
int
k
=
0
;
int
k
=
0
;
...
@@ -640,8 +637,10 @@ public class InsnGen {
...
@@ -640,8 +637,10 @@ public class InsnGen {
}
}
if
(
callMthNode
!=
null
)
{
if
(
callMthNode
!=
null
)
{
code
.
attachAnnotation
(
callMthNode
);
code
.
attachAnnotation
(
callMthNode
);
code
.
add
(
callMthNode
.
getAlias
());
}
else
{
code
.
add
(
callMth
.
getAlias
());
}
}
code
.
add
(
callMth
.
getAlias
());
generateMethodArguments
(
code
,
insn
,
k
,
callMthNode
);
generateMethodArguments
(
code
,
insn
,
k
,
callMthNode
);
}
}
...
@@ -694,7 +693,14 @@ public class InsnGen {
...
@@ -694,7 +693,14 @@ public class InsnGen {
* Add additional cast for overloaded method argument.
* Add additional cast for overloaded method argument.
*/
*/
private
boolean
processOverloadedArg
(
CodeWriter
code
,
MethodNode
callMth
,
InsnArg
arg
,
int
origPos
)
{
private
boolean
processOverloadedArg
(
CodeWriter
code
,
MethodNode
callMth
,
InsnArg
arg
,
int
origPos
)
{
ArgType
origType
=
callMth
.
getArguments
(
false
).
get
(
origPos
).
getInitType
();
ArgType
origType
;
List
<
RegisterArg
>
arguments
=
callMth
.
getArguments
(
false
);
if
(
arguments
.
isEmpty
())
{
mth
.
addComment
(
"JADX WARN: used method not loaded: "
+
callMth
+
", types can be incorrect"
);
origType
=
callMth
.
getMethodInfo
().
getArgumentsTypes
().
get
(
origPos
);
}
else
{
origType
=
arguments
.
get
(
origPos
).
getInitType
();
}
if
(!
arg
.
getType
().
equals
(
origType
))
{
if
(!
arg
.
getType
().
equals
(
origType
))
{
code
.
add
(
'('
);
code
.
add
(
'('
);
useType
(
code
,
origType
);
useType
(
code
,
origType
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/DependencyCollector.java
View file @
6a1717a6
...
@@ -11,6 +11,7 @@ import jadx.core.dex.instructions.args.ArgType;
...
@@ -11,6 +11,7 @@ import jadx.core.dex.instructions.args.ArgType;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.DexNode
;
...
@@ -90,6 +91,9 @@ public class DependencyCollector extends AbstractVisitor {
...
@@ -90,6 +91,9 @@ public class DependencyCollector extends AbstractVisitor {
}
else
if
(
insn
instanceof
InvokeNode
)
{
}
else
if
(
insn
instanceof
InvokeNode
)
{
ClassInfo
declClass
=
((
InvokeNode
)
insn
).
getCallMth
().
getDeclClass
();
ClassInfo
declClass
=
((
InvokeNode
)
insn
).
getCallMth
().
getDeclClass
();
addDep
(
dex
,
depList
,
declClass
);
addDep
(
dex
,
depList
,
declClass
);
}
else
if
(
insn
instanceof
ConstructorInsn
)
{
ClassInfo
declClass
=
((
ConstructorInsn
)
insn
).
getCallMth
().
getDeclClass
();
addDep
(
dex
,
depList
,
declClass
);
}
}
}
}
...
...
jadx-core/src/main/java/jadx/core/utils/CodegenUtils.java
View file @
6a1717a6
...
@@ -8,7 +8,7 @@ public class CodegenUtils {
...
@@ -8,7 +8,7 @@ public class CodegenUtils {
public
static
void
addComments
(
CodeWriter
code
,
AttrNode
node
)
{
public
static
void
addComments
(
CodeWriter
code
,
AttrNode
node
)
{
for
(
String
comment
:
node
.
getAll
(
AType
.
COMMENTS
))
{
for
(
String
comment
:
node
.
getAll
(
AType
.
COMMENTS
))
{
code
.
startLine
(
"/* "
).
add
(
comment
).
add
(
" */"
);
code
.
startLine
(
"/* "
).
add
MultiLine
(
comment
).
add
(
" */"
);
}
}
}
}
}
}
jadx-core/src/test/java/jadx/tests/integration/invoke/TestInheritedStaticInvoke.java
0 → 100644
View file @
6a1717a6
package
jadx
.
tests
.
integration
.
invoke
;
import
org.junit.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestInheritedStaticInvoke
extends
IntegrationTest
{
public
static
class
TestCls
{
public
static
class
A
{
public
static
int
a
()
{
return
1
;
}
}
public
static
class
B
extends
A
{
}
public
int
test
()
{
return
B
.
a
();
// not A.a()
}
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"return B.a();"
));
}
}
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