Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ql04210214
jadx
提交
7576f9cd
J
jadx
项目概览
ql04210214
/
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
7576f9cd
编写于
1月 11, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: wrap negative literals before cast (#1327)
上级
46b5725d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
2 deletion
+60
-2
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+10
-1
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+11
-1
jadx-core/src/test/java/jadx/tests/integration/invoke/TestOverloadedInvoke.java
...a/jadx/tests/integration/invoke/TestOverloadedInvoke.java
+39
-0
未找到文件。
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
7576f9cd
...
...
@@ -112,7 +112,7 @@ public class InsnGen {
}
code
.
add
(
mgen
.
getNameGen
().
useArg
(
reg
));
}
else
if
(
arg
.
isLiteral
())
{
code
.
add
(
lit
((
LiteralArg
)
arg
)
);
addLiteralArg
(
code
,
(
LiteralArg
)
arg
,
flags
);
}
else
if
(
arg
.
isInsnWrap
())
{
addWrappedArg
(
code
,
(
InsnWrapArg
)
arg
,
flags
);
}
else
if
(
arg
.
isNamed
())
{
...
...
@@ -122,6 +122,15 @@ public class InsnGen {
}
}
private
void
addLiteralArg
(
ICodeWriter
code
,
LiteralArg
litArg
,
Set
<
Flags
>
flags
)
{
String
literalStr
=
lit
(
litArg
);
if
(!
flags
.
contains
(
Flags
.
BODY_ONLY_NOWRAP
)
&&
literalStr
.
startsWith
(
"-"
))
{
code
.
add
(
'('
).
add
(
literalStr
).
add
(
')'
);
}
else
{
code
.
add
(
literalStr
);
}
}
private
void
addWrappedArg
(
ICodeWriter
code
,
InsnWrapArg
arg
,
Set
<
Flags
>
flags
)
throws
CodegenException
{
InsnNode
wrapInsn
=
arg
.
getWrapInsn
();
if
(
wrapInsn
.
contains
(
AFlag
.
FORCE_ASSIGN_INLINE
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
浏览文件 @
7576f9cd
...
...
@@ -508,7 +508,17 @@ public class InsnDecoder {
private
InsnNode
makeNewArray
(
InsnData
insn
)
{
ArgType
indexType
=
ArgType
.
parse
(
insn
.
getIndexAsType
());
int
dim
=
(
int
)
insn
.
getLiteral
();
ArgType
arrType
=
dim
==
0
?
indexType
:
ArgType
.
array
(
indexType
,
dim
);
ArgType
arrType
;
if
(
dim
==
0
)
{
arrType
=
indexType
;
}
else
{
if
(
indexType
.
isArray
())
{
// java bytecode can pass array as a base type
arrType
=
indexType
;
}
else
{
arrType
=
ArgType
.
array
(
indexType
,
dim
);
}
}
int
regsCount
=
insn
.
getRegsCount
();
NewArrayNode
newArr
=
new
NewArrayNode
(
arrType
,
regsCount
-
1
);
newArr
.
setResult
(
InsnArg
.
reg
(
insn
,
0
,
arrType
));
...
...
jadx-core/src/test/java/jadx/tests/integration/invoke/TestOverloadedInvoke.java
0 → 100644
浏览文件 @
7576f9cd
package
jadx.tests.integration.invoke
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.extensions.profiles.TestProfile
;
import
jadx.tests.api.extensions.profiles.TestWithProfiles
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
public
class
TestOverloadedInvoke
extends
IntegrationTest
{
public
static
class
TestCls
{
public
static
final
int
N
=
10
;
public
void
test
()
{
int
[][][]
arr
=
new
int
[
N
][
N
][
N
];
use
(
arr
,
-
1
);
use
(
arr
[
0
],
-
2
);
}
public
void
use
(
Object
[][]
arr
,
Object
obj
)
{
}
public
void
use
(
int
[][]
arr
,
int
i
)
{
}
}
@TestWithProfiles
({
TestProfile
.
DX_J8
,
TestProfile
.
D8_J11
,
TestProfile
.
JAVA8
})
public
void
test
()
{
noDebugInfo
();
assertThat
(
getClassNode
(
TestCls
.
class
))
.
code
()
.
containsOne
(
"use(iArr[0], -2);"
)
.
containsOne
(
"use((Object[][]) iArr, (Object) (-1));"
);
// TODO: don't add unnecessary casts
// .containsOne("use(iArr, -1);");
// TODO: replace call `Array.newInstance` with new array creation: `new int[N][N][N]`
// .containsOne("new int[10][10][10];");
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录