Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ql04210214
jadx
提交
68ccf57b
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,发现更多精彩内容 >>
提交
68ccf57b
编写于
10月 18, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix type detection for method arguments
上级
84970759
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
128 addition
and
22 deletion
+128
-22
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+1
-1
jadx-core/src/main/java/jadx/core/dex/instructions/args/MthParameterArg.java
...java/jadx/core/dex/instructions/args/MthParameterArg.java
+1
-0
jadx-core/src/main/java/jadx/core/dex/instructions/args/RegisterArg.java
...ain/java/jadx/core/dex/instructions/args/RegisterArg.java
+1
-0
jadx-core/src/main/java/jadx/core/dex/instructions/args/SSAVar.java
...src/main/java/jadx/core/dex/instructions/args/SSAVar.java
+26
-14
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/PostTypeInference.java
...dx/core/dex/visitors/typeinference/PostTypeInference.java
+6
-5
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInference.java
...a/jadx/core/dex/visitors/typeinference/TypeInference.java
+1
-2
jadx-core/src/test/java/jadx/tests/integration/invoke/TestOverloadedMethodInvoke.java
.../tests/integration/invoke/TestOverloadedMethodInvoke.java
+58
-0
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver2.java
.../java/jadx/tests/integration/types/TestTypeResolver2.java
+34
-0
未找到文件。
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
68ccf57b
...
...
@@ -680,7 +680,7 @@ public class InsnGen {
if
(!
arg
.
getType
().
equals
(
origType
))
{
code
.
add
(
'('
);
useType
(
code
,
origType
);
code
.
add
(
')'
);
code
.
add
(
") "
);
addArg
(
code
,
arg
,
true
);
}
else
{
addArg
(
code
,
arg
,
false
);
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/MthParameterArg.java
浏览文件 @
68ccf57b
...
...
@@ -39,6 +39,7 @@ public class MthParameterArg extends RegisterArg {
if
(
isThis
)
{
sVar
.
setName
(
"this"
);
}
sVar
.
setTypeImmutable
(
type
);
super
.
setSVar
(
sVar
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/RegisterArg.java
浏览文件 @
68ccf57b
...
...
@@ -80,6 +80,7 @@ public class RegisterArg extends InsnArg implements Named {
setName
(
name
);
}
@Deprecated
public
void
forceType
(
ArgType
type
)
{
this
.
type
=
type
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/SSAVar.java
浏览文件 @
68ccf57b
...
...
@@ -19,6 +19,7 @@ public class SSAVar {
private
PhiInsn
usedInPhi
;
private
ArgType
type
;
private
boolean
typeImmutable
;
public
SSAVar
(
int
regNum
,
int
v
,
RegisterArg
assign
)
{
this
.
regNum
=
regNum
;
...
...
@@ -33,10 +34,6 @@ public class SSAVar {
endUseAddr
=
-
1
;
}
public
int
getRegNum
()
{
return
regNum
;
}
public
int
getStartAddr
()
{
if
(
startUseAddr
==
-
1
)
{
calcUsageAddrRange
();
...
...
@@ -48,7 +45,6 @@ public class SSAVar {
if
(
endUseAddr
==
-
1
)
{
calcUsageAddrRange
();
}
return
endUseAddr
;
}
...
...
@@ -85,6 +81,10 @@ public class SSAVar {
}
}
public
int
getRegNum
()
{
return
regNum
;
}
public
int
getVersion
()
{
return
version
;
}
...
...
@@ -141,20 +141,32 @@ public class SSAVar {
return
useList
.
size
()
+
usedInPhi
.
getResult
().
getSVar
().
getUseCount
();
}
public
ArgType
getType
()
{
return
type
;
}
public
void
setType
(
ArgType
type
)
{
this
.
type
=
type
;
ArgType
acceptedType
;
if
(
typeImmutable
)
{
// don't change type, just update types in useList
acceptedType
=
this
.
type
;
}
else
{
acceptedType
=
type
;
this
.
type
=
acceptedType
;
}
if
(
assign
!=
null
)
{
assign
.
type
=
t
ype
;
assign
.
type
=
acceptedT
ype
;
}
for
(
int
i
=
0
,
useListSize
=
useList
.
size
();
i
<
useListSize
;
i
++)
{
useList
.
get
(
i
).
type
=
t
ype
;
useList
.
get
(
i
).
type
=
acceptedT
ype
;
}
}
public
void
setTypeImmutable
(
ArgType
type
)
{
setType
(
type
);
this
.
typeImmutable
=
true
;
}
public
boolean
isTypeImmutable
()
{
return
typeImmutable
;
}
public
void
setName
(
String
name
)
{
if
(
name
!=
null
)
{
if
(
varName
==
null
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/PostTypeInference.java
浏览文件 @
68ccf57b
...
...
@@ -85,20 +85,21 @@ public class PostTypeInference {
case
CHECK_CAST:
{
ArgType
castType
=
(
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
();
SSAVar
sVar
=
insn
.
getResult
().
getSVar
();
RegisterArg
result
=
insn
.
getResult
();
// don't override generic types of same base class
boolean
skip
=
castType
.
isObject
()
&&
castType
.
getObject
().
equals
(
sVar
.
getType
().
getObject
());
boolean
skip
=
castType
.
isObject
()
&&
castType
.
getObject
().
equals
(
result
.
getType
().
getObject
());
if
(!
skip
)
{
// workaround for compiler bug (see TestDuplicateCast)
sVar
.
setType
(
castType
);
result
.
getSVar
()
.
setType
(
castType
);
}
return
true
;
}
case
PHI:
{
PhiInsn
phi
=
(
PhiInsn
)
insn
;
SSAVar
resultSVar
=
phi
.
getResult
().
getSVar
();
if
(
resultSVar
!=
null
&&
!
resultSVar
.
getType
().
isTypeKnown
())
{
RegisterArg
result
=
phi
.
getResult
();
SSAVar
resultSVar
=
result
.
getSVar
();
if
(
resultSVar
!=
null
&&
!
result
.
getType
().
isTypeKnown
())
{
for
(
InsnArg
arg
:
phi
.
getArguments
())
{
ArgType
argType
=
arg
.
getType
();
if
(
argType
.
isTypeKnown
())
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInference.java
浏览文件 @
68ccf57b
...
...
@@ -44,8 +44,7 @@ public class TypeInference extends AbstractVisitor {
private
static
ArgType
processType
(
SSAVar
var
)
{
RegisterArg
assign
=
var
.
getAssign
();
List
<
RegisterArg
>
useList
=
var
.
getUseList
();
if
(
assign
!=
null
&&
(
useList
.
isEmpty
()
||
assign
.
isTypeImmutable
()))
{
if
(
assign
!=
null
&&
(
useList
.
isEmpty
()
||
var
.
isTypeImmutable
()))
{
return
assign
.
getType
();
}
ArgType
type
;
...
...
jadx-core/src/test/java/jadx/tests/integration/invoke/TestOverloadedMethodInvoke.java
0 → 100644
浏览文件 @
68ccf57b
package
jadx.tests.integration.invoke
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestOverloadedMethodInvoke
extends
IntegrationTest
{
public
static
class
TestCls
{
int
c
;
public
void
method
(
Throwable
th
)
{
c
++;
if
(
th
!=
null
)
{
c
+=
100
;
}
}
public
void
method
(
Exception
e
)
{
c
+=
1000
;
if
(
e
!=
null
)
{
c
+=
10000
;
}
}
public
void
test
(
Throwable
th
,
Exception
e
)
{
method
(
e
);
method
(
th
);
method
((
Throwable
)
e
);
method
((
Exception
)
th
);
}
public
void
check
()
{
test
(
null
,
new
Exception
());
assertEquals
(
12102
,
c
);
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"public void test(Throwable th, Exception e) {"
));
assertThat
(
code
,
containsOne
(
"method(e);"
));
assertThat
(
code
,
containsOne
(
"method(th);"
));
assertThat
(
code
,
containsOne
(
"method((Throwable) e);"
));
assertThat
(
code
,
containsOne
(
"method((Exception) th);"
));
assertThat
(
code
,
not
(
containsString
(
"(Exception) e"
)));
}
}
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver2.java
0 → 100644
浏览文件 @
68ccf57b
package
jadx.tests.integration.types
;
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
TestTypeResolver2
extends
IntegrationTest
{
public
static
class
TestCls
{
private
static
boolean
test
(
Object
obj
)
throws
IOException
{
if
(
obj
!=
null
)
{
return
true
;
}
throw
new
IOException
();
}
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"if (obj != null) {"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录