Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76393173
jadx
提交
45021389
J
jadx
项目概览
2301_76393173
/
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,发现更多精彩内容 >>
未验证
提交
45021389
编写于
1月 24, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: correct method arg name if unused
上级
f674a29a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
10 deletion
+65
-10
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+3
-2
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+0
-3
jadx-core/src/main/java/jadx/core/dex/visitors/InitCodeVariables.java
...c/main/java/jadx/core/dex/visitors/InitCodeVariables.java
+10
-5
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariablesDeclAnnotation.java
...ts/integration/variables/TestVariablesDeclAnnotation.java
+52
-0
未找到文件。
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
浏览文件 @
45021389
...
...
@@ -238,10 +238,11 @@ public class MethodGen {
classGen
.
useType
(
code
,
argType
);
}
code
.
add
(
' '
);
if
(
code
.
isMetadataSupported
()
&&
ssaVar
!=
null
)
{
String
varName
=
nameGen
.
assignArg
(
var
);
if
(
code
.
isMetadataSupported
()
&&
ssaVar
!=
null
/* for fallback mode */
)
{
code
.
attachDefinition
(
VarDeclareRef
.
get
(
mth
,
var
));
}
code
.
add
(
nameGen
.
assignArg
(
var
)
);
code
.
add
(
varName
);
i
++;
if
(
it
.
hasNext
())
{
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
浏览文件 @
45021389
...
...
@@ -99,9 +99,6 @@ public class MethodNode extends NotificationAttrNode implements IMethodDetails,
@Override
public
void
unload
()
{
loaded
=
false
;
if
(
noCode
)
{
return
;
}
// don't unload retType, argTypes, typeParameters
thisArg
=
null
;
argsList
=
null
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/InitCodeVariables.java
浏览文件 @
45021389
...
...
@@ -26,9 +26,6 @@ public class InitCodeVariables extends AbstractVisitor {
@Override
public
void
visit
(
MethodNode
mth
)
throws
JadxException
{
if
(
mth
.
isNoCode
())
{
return
;
}
initCodeVars
(
mth
);
}
...
...
@@ -42,16 +39,24 @@ public class InitCodeVariables extends AbstractVisitor {
private
static
void
initCodeVars
(
MethodNode
mth
)
{
RegisterArg
thisArg
=
mth
.
getThisArg
();
if
(
thisArg
!=
null
)
{
initCodeVar
(
thisArg
.
getSVar
()
);
initCodeVar
(
mth
,
thisArg
);
}
for
(
RegisterArg
mthArg
:
mth
.
getArgRegs
())
{
initCodeVar
(
mth
Arg
.
getSVar
()
);
initCodeVar
(
mth
,
mthArg
);
}
for
(
SSAVar
ssaVar
:
mth
.
getSVars
())
{
initCodeVar
(
ssaVar
);
}
}
public
static
void
initCodeVar
(
MethodNode
mth
,
RegisterArg
regArg
)
{
SSAVar
ssaVar
=
regArg
.
getSVar
();
if
(
ssaVar
==
null
)
{
ssaVar
=
mth
.
makeNewSVar
(
regArg
);
}
initCodeVar
(
ssaVar
);
}
public
static
void
initCodeVar
(
SSAVar
ssaVar
)
{
if
(
ssaVar
.
isCodeVarSet
())
{
return
;
...
...
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariablesDeclAnnotation.java
0 → 100644
浏览文件 @
45021389
package
jadx.tests.integration.variables
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.junit.jupiter.api.Test
;
import
jadx.api.data.annotations.VarDeclareRef
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
public
class
TestVariablesDeclAnnotation
extends
IntegrationTest
{
public
abstract
static
class
TestCls
{
public
int
test
(
String
str
,
int
i
)
{
return
i
;
}
public
abstract
int
test2
(
String
str
);
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
assertThat
(
cls
).
code
()
.
containsOne
(
"public int test(String str, int i) {"
)
.
containsOne
(
"public abstract int test2(String str);"
);
checkArgNamesInMethod
(
cls
,
"test"
,
"[str, i]"
);
checkArgNamesInMethod
(
cls
,
"test2"
,
"[str]"
);
}
private
static
void
checkArgNamesInMethod
(
ClassNode
cls
,
String
mthName
,
String
expectedVars
)
{
MethodNode
testMth
=
cls
.
searchMethodByShortName
(
mthName
);
assertThat
(
testMth
).
isNotNull
();
int
mthLine
=
testMth
.
getDecompiledLine
();
List
<
String
>
argNames
=
cls
.
getCode
().
getAnnotations
().
entrySet
().
stream
()
.
filter
(
e
->
e
.
getKey
().
getLine
()
==
mthLine
&&
e
.
getValue
()
instanceof
VarDeclareRef
)
.
sorted
(
Comparator
.
comparingInt
(
e
->
e
.
getKey
().
getPos
()))
.
map
(
e
->
((
VarDeclareRef
)
e
.
getValue
()).
getName
())
.
collect
(
Collectors
.
toList
());
assertThat
(
argNames
).
doesNotContainNull
();
assertThat
(
argNames
.
toString
()).
isEqualTo
(
expectedVars
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录