Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
极致猎手
jadx
提交
932966b6
J
jadx
项目概览
极致猎手
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
932966b6
编写于
5月 02, 2015
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: skip synthetic arguments in anonymous class constructor
上级
85a18e6d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
3 deletion
+99
-3
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+15
-0
jadx-core/src/main/java/jadx/core/dex/visitors/ClassModifier.java
...e/src/main/java/jadx/core/dex/visitors/ClassModifier.java
+15
-3
jadx-core/src/test/java/jadx/tests/integration/invoke/TestInvoke1.java
.../test/java/jadx/tests/integration/invoke/TestInvoke1.java
+69
-0
未找到文件。
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
932966b6
...
...
@@ -647,6 +647,10 @@ public class InsnGen {
if
(
arg
.
contains
(
AFlag
.
SKIP_ARG
))
{
continue
;
}
RegisterArg
callArg
=
getCallMthArg
(
callMth
,
i
-
startArgNum
);
if
(
callArg
!=
null
&&
callArg
.
contains
(
AFlag
.
SKIP_ARG
))
{
continue
;
}
if
(
i
!=
k
)
{
code
.
add
(
", "
);
}
...
...
@@ -660,6 +664,17 @@ public class InsnGen {
code
.
add
(
')'
);
}
private
static
RegisterArg
getCallMthArg
(
@Nullable
MethodNode
callMth
,
int
num
)
{
if
(
callMth
==
null
)
{
return
null
;
}
List
<
RegisterArg
>
args
=
callMth
.
getArguments
(
false
);
if
(
args
!=
null
&&
num
<
args
.
size
())
{
return
args
.
get
(
num
);
}
return
null
;
}
/**
* Add additional cast for overloaded method argument.
*/
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ClassModifier.java
浏览文件 @
932966b6
...
...
@@ -11,6 +11,7 @@ import jadx.core.dex.instructions.IndexInsnNode;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.SSAVar
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.ClassNode
;
...
...
@@ -135,13 +136,24 @@ public class ClassModifier extends AbstractVisitor {
mth
.
add
(
AFlag
.
DONT_GENERATE
);
continue
;
}
// remove synthetic constructor for inner
non-static
classes
// remove synthetic constructor for inner classes
if
(
af
.
isSynthetic
()
&&
af
.
isConstructor
()
&&
mth
.
getBasicBlocks
().
size
()
==
2
)
{
List
<
InsnNode
>
insns
=
mth
.
getBasicBlocks
().
get
(
0
).
getInstructions
();
if
(
insns
.
size
()
==
1
&&
insns
.
get
(
0
).
getType
()
==
InsnType
.
CONSTRUCTOR
)
{
ConstructorInsn
constr
=
(
ConstructorInsn
)
insns
.
get
(
0
);
if
(
constr
.
isThis
()
&&
!
mth
.
getArguments
(
false
).
isEmpty
())
{
mth
.
removeFirstArgument
();
List
<
RegisterArg
>
args
=
mth
.
getArguments
(
false
);
if
(
constr
.
isThis
()
&&
!
args
.
isEmpty
())
{
// remove first arg for non-static class (references to outer class)
if
(
args
.
get
(
0
).
getType
().
equals
(
cls
.
getParentClass
().
getClassInfo
().
getType
()))
{
args
.
get
(
0
).
add
(
AFlag
.
SKIP_ARG
);
}
// remove unused args
for
(
RegisterArg
arg
:
args
)
{
SSAVar
sVar
=
arg
.
getSVar
();
if
(
sVar
!=
null
&&
sVar
.
getUseCount
()
==
0
)
{
arg
.
add
(
AFlag
.
SKIP_ARG
);
}
}
mth
.
add
(
AFlag
.
DONT_GENERATE
);
}
}
...
...
jadx-core/src/test/java/jadx/tests/integration/invoke/TestInvoke1.java
0 → 100644
浏览文件 @
932966b6
package
jadx.tests.integration.invoke
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
java.io.IOException
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestInvoke1
extends
IntegrationTest
{
public
static
class
TestCls
{
private
A
is
;
private
C
test
(
int
start
)
throws
IOException
{
int
id
=
is
.
readInt32
();
String
name
=
is
.
readString16Fixed
(
128
);
long
typeStringsOffset
=
start
+
is
.
readInt32
();
long
keyStringsOffset
=
start
+
is
.
readInt32
();
String
[]
types
=
null
;
if
(
typeStringsOffset
!=
0
)
{
types
=
strs
();
}
String
[]
keys
=
null
;
if
(
keyStringsOffset
!=
0
)
{
keys
=
strs
();
}
C
pkg
=
new
C
(
id
,
name
,
types
,
keys
);
if
(
id
==
0x7F
)
{
is
.
readInt32
();
}
return
pkg
;
}
private
String
[]
strs
()
{
return
new
String
[
0
];
}
private
static
final
class
C
{
public
C
(
int
id
,
String
name
,
String
[]
types
,
String
[]
keys
)
{
}
}
private
final
class
A
{
public
int
readInt32
()
{
return
0
;
}
public
String
readString16Fixed
(
int
i
)
{
return
null
;
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"C pkg = new C(id, name, types, keys);"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录