Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
ccb8ed13
J
jadx
项目概览
qq_39073359
/
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,发现更多精彩内容 >>
提交
ccb8ed13
编写于
7月 29, 2019
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add assign for inlined getter methods
上级
8d68d409
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
93 addition
and
0 deletion
+93
-0
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+21
-0
jadx-core/src/test/java/jadx/tests/integration/inline/TestGetterInlineNegative.java
...dx/tests/integration/inline/TestGetterInlineNegative.java
+43
-0
jadx-core/src/test/smali/inline/TestGetterInlineNegative.smali
...core/src/test/smali/inline/TestGetterInlineNegative.smali
+29
-0
未找到文件。
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
ccb8ed13
...
...
@@ -40,6 +40,7 @@ import jadx.core.dex.instructions.args.InsnArg;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
import
jadx.core.dex.instructions.args.LiteralArg
;
import
jadx.core.dex.instructions.args.Named
;
import
jadx.core.dex.instructions.args.NamedArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.SSAVar
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
...
...
@@ -874,6 +875,13 @@ public class InsnGen {
if
(
Consts
.
DEBUG
)
{
code
.
add
(
"/* inline method: "
).
add
(
callMthNode
.
toString
()).
add
(
"*/"
).
startLine
();
}
if
(
forceAssign
(
inl
,
insn
,
callMthNode
))
{
ArgType
varType
=
callMthNode
.
getReturnType
();
useType
(
code
,
varType
);
code
.
add
(
' '
);
code
.
add
(
mgen
.
getNameGen
().
assignNamedArg
(
new
NamedArg
(
"unused"
,
varType
)));
code
.
add
(
" = "
);
}
if
(
callMthNode
.
getMethodInfo
().
getArgumentsTypes
().
isEmpty
())
{
makeInsn
(
inl
,
code
,
Flags
.
BODY_ONLY
);
}
else
{
...
...
@@ -907,6 +915,19 @@ public class InsnGen {
return
true
;
}
private
boolean
forceAssign
(
InsnNode
inlineInsn
,
InvokeNode
parentInsn
,
MethodNode
callMthNode
)
{
if
(
parentInsn
.
getResult
()
!=
null
)
{
return
false
;
}
if
(
parentInsn
.
contains
(
AFlag
.
WRAPPED
))
{
return
false
;
}
if
(
callMthNode
.
getReturnType
().
equals
(
ArgType
.
VOID
))
{
return
false
;
}
return
true
;
}
private
void
makeTernary
(
TernaryInsn
insn
,
CodeWriter
code
,
Set
<
Flags
>
state
)
throws
CodegenException
{
boolean
wrap
=
state
.
contains
(
Flags
.
BODY_ONLY
);
if
(
wrap
)
{
...
...
jadx-core/src/test/java/jadx/tests/integration/inline/TestGetterInlineNegative.java
0 → 100644
浏览文件 @
ccb8ed13
package
jadx.tests.integration.inline
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.SmaliTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
public
class
TestGetterInlineNegative
extends
SmaliTest
{
// @formatter:off
/*
public class TestGetterInlineNegative {
public static final String field = "some string";
public static synthetic String getter() {
return field;
}
public void test() {
getter(); // inline will produce 'field;' and fail to compile with 'not a statement' error
}
public String test2() {
return getter();
}
}
*/
// @formatter:on
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNodeFromSmali
();
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
not
(
containsString
(
indent
()
+
"field;"
)));
assertThat
(
code
,
containsOne
(
"return field;"
));
}
}
jadx-core/src/test/smali/inline/TestGetterInlineNegative.smali
0 → 100644
浏览文件 @
ccb8ed13
.class public Linline/TestGetterInlineNegative;
.super Ljava/lang/Object;
.field public static final field:Ljava/lang/String; = "some string"
.method public static synthetic getter()Ljava/lang/String;
.locals 1
sget-object v0, Linline/TestGetterInlineNegative;->field:Ljava/lang/String;
return-object v0
.end method
.method public test()V
.locals 1
invoke-static {}, Linline/TestGetterInlineNegative;->getter()Ljava/lang/String;
return-void
.end method
.method public test2()Ljava/lang/String;
.locals 2
invoke-static {}, Linline/TestGetterInlineNegative;->getter()Ljava/lang/String;
move-result-object v1
return-object v1
.end method
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录