Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
be9dae57
J
jadx
项目概览
Quincy379
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be9dae57
编写于
7月 30, 2019
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add explicit cast for byte literal in method invoke (#719)
上级
46290437
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
6 deletion
+42
-6
jadx-core/src/main/java/jadx/core/dex/instructions/CallMthInterface.java
...ain/java/jadx/core/dex/instructions/CallMthInterface.java
+5
-0
jadx-core/src/main/java/jadx/core/dex/instructions/InvokeNode.java
.../src/main/java/jadx/core/dex/instructions/InvokeNode.java
+6
-1
jadx-core/src/main/java/jadx/core/dex/instructions/mods/ConstructorInsn.java
...java/jadx/core/dex/instructions/mods/ConstructorInsn.java
+5
-0
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
+1
-1
jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlineVisitor.java
.../main/java/jadx/core/dex/visitors/ConstInlineVisitor.java
+21
-0
jadx-core/src/test/java/jadx/tests/integration/enums/TestInnerEnums.java
...est/java/jadx/tests/integration/enums/TestInnerEnums.java
+4
-4
未找到文件。
jadx-core/src/main/java/jadx/core/dex/instructions/CallMthInterface.java
浏览文件 @
be9dae57
...
...
@@ -8,4 +8,9 @@ public interface CallMthInterface {
MethodInfo
getCallMth
();
RegisterArg
getInstanceArg
();
/**
* Return offset to match method args from {@link #getCallMth()}
*/
int
getFirstArgOffset
();
}
jadx-core/src/main/java/jadx/core/dex/instructions/InvokeNode.java
浏览文件 @
be9dae57
...
...
@@ -18,7 +18,7 @@ public class InvokeNode extends InsnNode implements CallMthInterface {
private
final
MethodInfo
mth
;
public
InvokeNode
(
MethodInfo
mth
,
DecodedInstruction
insn
,
InvokeType
type
,
boolean
isRange
,
int
resReg
)
{
super
(
InsnType
.
INVOKE
,
mth
.
getArgsCount
()
+
(
type
!=
InvokeType
.
STATIC
?
1
:
0
));
super
(
InsnType
.
INVOKE
,
mth
.
getArgsCount
()
+
(
type
==
InvokeType
.
STATIC
?
0
:
1
));
this
.
mth
=
mth
;
this
.
type
=
type
;
...
...
@@ -66,6 +66,11 @@ public class InvokeNode extends InsnNode implements CallMthInterface {
return
null
;
}
@Override
public
int
getFirstArgOffset
()
{
return
type
==
InvokeType
.
STATIC
?
0
:
1
;
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
InvokeNode
(
mth
,
type
,
getArgsCount
()));
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/mods/ConstructorInsn.java
浏览文件 @
be9dae57
...
...
@@ -92,6 +92,11 @@ public class ConstructorInsn extends InsnNode implements CallMthInterface {
return
callType
==
CallType
.
SELF
;
}
@Override
public
int
getFirstArgOffset
()
{
return
0
;
}
@Override
public
boolean
isSame
(
InsnNode
obj
)
{
if
(
this
==
obj
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
浏览文件 @
be9dae57
...
...
@@ -143,7 +143,7 @@ public class InsnNode extends LineAttrNode {
return
arg
;
}
p
rotected
int
getArgIndex
(
InsnArg
arg
)
{
p
ublic
int
getArgIndex
(
InsnArg
arg
)
{
int
count
=
getArgsCount
();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
arg
==
arguments
.
get
(
i
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlineVisitor.java
浏览文件 @
be9dae57
...
...
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.CallMthInterface
;
import
jadx.core.dex.instructions.ConstStringNode
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InsnType
;
...
...
@@ -203,6 +205,10 @@ public class ConstInlineVisitor extends AbstractVisitor {
}
if
(
fieldNode
!=
null
)
{
litArg
.
wrapInstruction
(
mth
,
new
IndexInsnNode
(
InsnType
.
SGET
,
fieldNode
.
getFieldInfo
(),
0
));
}
else
{
if
(
needExplicitCast
(
useInsn
,
litArg
))
{
litArg
.
add
(
AFlag
.
EXPLICIT_PRIMITIVE_TYPE
);
}
}
}
else
{
if
(!
useInsn
.
replaceArg
(
arg
,
constArg
.
duplicate
()))
{
...
...
@@ -214,4 +220,19 @@ public class ConstInlineVisitor extends AbstractVisitor {
}
return
true
;
}
private
static
boolean
needExplicitCast
(
InsnNode
insn
,
LiteralArg
arg
)
{
if
(
insn
instanceof
CallMthInterface
)
{
CallMthInterface
callInsn
=
(
CallMthInterface
)
insn
;
MethodInfo
callMth
=
callInsn
.
getCallMth
();
int
offset
=
callInsn
.
getFirstArgOffset
();
int
argIndex
=
insn
.
getArgIndex
(
arg
);
ArgType
argType
=
callMth
.
getArgumentsTypes
().
get
(
argIndex
-
offset
);
if
(
argType
.
isPrimitive
())
{
arg
.
setType
(
argType
);
return
argType
.
equals
(
ArgType
.
BYTE
);
}
}
return
false
;
}
}
jadx-core/src/test/java/jadx/tests/integration/enums/TestInnerEnums.java
浏览文件 @
be9dae57
...
...
@@ -14,9 +14,9 @@ public class TestInnerEnums extends IntegrationTest {
public
static
class
TestCls
{
public
enum
Numbers
{
ONE
(
1
,
NumString
.
ONE
),
TWO
(
2
,
NumString
.
TWO
);
ONE
(
(
byte
)
1
,
NumString
.
ONE
),
TWO
((
byte
)
2
,
NumString
.
TWO
);
private
final
int
num
;
private
final
byte
num
;
private
final
NumString
str
;
public
enum
NumString
{
...
...
@@ -33,7 +33,7 @@ public class TestInnerEnums extends IntegrationTest {
}
}
Numbers
(
int
n
,
NumString
str
)
{
Numbers
(
byte
n
,
NumString
str
)
{
this
.
num
=
n
;
this
.
str
=
str
;
}
...
...
@@ -63,7 +63,7 @@ public class TestInnerEnums extends IntegrationTest {
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"ONE(1, NumString.ONE)"
));
assertThat
(
code
,
containsOne
(
"ONE(
(byte)
1, NumString.ONE)"
));
assertThat
(
code
,
containsOne
(
"ONE(\"one\")"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录