Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
dabaeed8
Commit
dabaeed8
authored
Dec 28, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add return type to method short id
parent
4923b36e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
28 deletions
+51
-28
Consts.java
jadx-core/src/main/java/jadx/core/Consts.java
+2
-0
MethodInfo.java
jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java
+12
-10
MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+3
-3
EnumVisitor.java
...ore/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
+33
-14
SimplifyVisitor.java
...src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/Consts.java
View file @
dabaeed8
...
...
@@ -21,4 +21,6 @@ public class Consts {
public
static
final
String
DEFAULT_PACKAGE_NAME
=
"defpackage"
;
public
static
final
String
ANONYMOUS_CLASS_PREFIX
=
"AnonymousClass_"
;
public
static
final
String
MTH_TOSTRING_SIGNATURE
=
"toString()Ljava/lang/String;"
;
}
jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java
View file @
dabaeed8
...
...
@@ -31,14 +31,16 @@ public final class MethodInfo {
retType
=
dex
.
getType
(
proto
.
getReturnTypeIndex
());
args
=
dex
.
readParamList
(
proto
.
getParametersOffset
());
StringBuilder
strArg
=
new
StringBuilder
();
strArg
.
append
(
'('
);
for
(
ArgType
arg
:
args
)
strArg
.
append
(
TypeGen
.
signature
(
arg
));
strArg
.
append
(
')'
);
// strArg.append(TypeGen.signature(retType));
shortId
=
name
+
strArg
;
StringBuilder
signature
=
new
StringBuilder
();
signature
.
append
(
name
);
signature
.
append
(
'('
);
for
(
ArgType
arg
:
args
)
{
signature
.
append
(
TypeGen
.
signature
(
arg
));
}
signature
.
append
(
')'
);
signature
.
append
(
TypeGen
.
signature
(
retType
));
shortId
=
signature
.
toString
();
}
public
String
getName
()
{
...
...
@@ -108,8 +110,8 @@ public final class MethodInfo {
@Override
public
String
toString
()
{
return
retType
+
" "
+
declClass
.
getFullName
()
+
"."
+
name
+
"("
+
Utils
.
listToString
(
args
)
+
")
"
;
return
declClass
.
getFullName
()
+
"."
+
name
+
"("
+
Utils
.
listToString
(
args
)
+
")
:"
+
retType
;
}
}
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
View file @
dabaeed8
...
...
@@ -516,8 +516,8 @@ public class MethodNode extends LineAttrNode implements ILoadable {
@Override
public
String
toString
()
{
return
retType
+
"
"
+
parentClass
.
getFullName
()
+
"."
+
mthInfo
.
getName
()
+
"("
+
Utils
.
listToString
(
mthInfo
.
getArgumentsTypes
())
+
")"
;
return
parentClass
.
getFullName
()
+
"."
+
mthInfo
.
getName
()
+
"
("
+
Utils
.
listToString
(
mthInfo
.
getArgumentsTypes
())
+
"):"
+
retType
;
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
View file @
dabaeed8
package
jadx
.
core
.
dex
.
visitors
;
import
jadx.core.codegen.TypeGen
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.EnumClassAttr
;
import
jadx.core.dex.attributes.EnumClassAttr.EnumField
;
...
...
@@ -8,6 +9,7 @@ import jadx.core.dex.info.FieldInfo;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
...
...
@@ -30,8 +32,9 @@ public class EnumVisitor extends AbstractVisitor {
@Override
public
boolean
visit
(
ClassNode
cls
)
throws
JadxException
{
if
(!
cls
.
isEnum
())
if
(!
cls
.
isEnum
())
{
return
true
;
}
// collect enum fields, remove synthetic
List
<
FieldNode
>
enumFields
=
new
ArrayList
<
FieldNode
>();
...
...
@@ -47,19 +50,29 @@ public class EnumVisitor extends AbstractVisitor {
MethodNode
staticMethod
=
null
;
ArgType
clsType
=
cls
.
getClassInfo
().
getType
();
String
enumConstructor
=
"<init>(Ljava/lang/String;I)V"
;
String
valuesOfMethod
=
"valueOf(Ljava/lang/String;)"
+
TypeGen
.
signature
(
clsType
);
String
valuesMethod
=
"values()"
+
TypeGen
.
signature
(
ArgType
.
array
(
clsType
));
// remove synthetic methods
for
(
Iterator
<
MethodNode
>
it
=
cls
.
getMethods
().
iterator
();
it
.
hasNext
();
)
{
MethodNode
mth
=
it
.
next
();
MethodInfo
mi
=
mth
.
getMethodInfo
();
if
(
mi
.
isClassInit
())
{
staticMethod
=
mth
;
}
else
if
(
mi
.
isConstructor
()
&&
!
mth
.
getAccessFlags
().
isSynthetic
())
{
if
(
mi
.
getShortId
().
equals
(
"<init>(Ljava/lang/String;I)"
))
}
else
{
String
shortId
=
mi
.
getShortId
();
boolean
isSynthetic
=
mth
.
getAccessFlags
().
isSynthetic
();
if
(
mi
.
isConstructor
()
&&
!
isSynthetic
)
{
if
(
shortId
.
equals
(
enumConstructor
))
{
it
.
remove
();
}
}
else
if
(
isSynthetic
||
shortId
.
equals
(
valuesMethod
)
||
shortId
.
equals
(
valuesOfMethod
))
{
it
.
remove
();
}
else
if
(
mth
.
getAccessFlags
().
isSynthetic
()
||
mi
.
getShortId
().
equals
(
"values()"
)
||
mi
.
getShortId
().
equals
(
"valueOf(Ljava/lang/String;)"
))
{
it
.
remove
();
}
}
}
...
...
@@ -89,10 +102,11 @@ public class EnumVisitor extends AbstractVisitor {
IndexInsnNode
fp
=
(
IndexInsnNode
)
insn
;
FieldInfo
f
=
(
FieldInfo
)
fp
.
getIndex
();
if
(
f
.
getName
().
equals
(
"$VALUES"
))
{
if
(
i
==
size
-
1
)
if
(
i
==
size
-
1
)
{
cls
.
getMethods
().
remove
(
staticMethod
);
else
}
else
{
list
.
subList
(
0
,
i
+
1
).
clear
();
}
break
;
}
}
...
...
@@ -102,16 +116,19 @@ public class EnumVisitor extends AbstractVisitor {
if
(
insn
.
getType
()
==
InsnType
.
CONSTRUCTOR
)
{
ConstructorInsn
co
=
(
ConstructorInsn
)
insn
;
if
(
insn
.
getArgsCount
()
<
2
)
if
(
insn
.
getArgsCount
()
<
2
)
{
continue
;
}
ClassInfo
clsInfo
=
co
.
getClassType
();
ClassNode
constrCls
=
cls
.
dex
().
resolveClass
(
clsInfo
);
if
(
constrCls
==
null
)
if
(
constrCls
==
null
)
{
continue
;
}
if
(!
clsInfo
.
equals
(
cls
.
getClassInfo
())
&&
!
constrCls
.
getAccessFlags
().
isEnum
())
if
(!
clsInfo
.
equals
(
cls
.
getClassInfo
())
&&
!
constrCls
.
getAccessFlags
().
isEnum
())
{
continue
;
}
RegisterArg
nameArg
=
(
RegisterArg
)
insn
.
getArg
(
0
);
// InsnArg pos = insn.getArg(1);
...
...
@@ -130,8 +147,9 @@ public class EnumVisitor extends AbstractVisitor {
constrArg
=
iArg
;
}
else
{
constrArg
=
CodeShrinker
.
inlineArgument
(
staticMethod
,
(
RegisterArg
)
iArg
);
if
(
constrArg
==
null
)
if
(
constrArg
==
null
)
{
throw
new
JadxException
(
"Can't inline constructor arg in enum: "
+
cls
);
}
}
field
.
getArgs
().
add
(
constrArg
);
}
...
...
@@ -143,8 +161,9 @@ public class EnumVisitor extends AbstractVisitor {
// remove constructor, because it is anonymous class
for
(
Iterator
<?>
mit
=
innerCls
.
getMethods
().
iterator
();
mit
.
hasNext
();
)
{
MethodNode
innerMth
=
(
MethodNode
)
mit
.
next
();
if
(
innerMth
.
getAccessFlags
().
isConstructor
())
if
(
innerMth
.
getAccessFlags
().
isConstructor
())
{
mit
.
remove
();
}
}
field
.
setCls
(
innerCls
);
innerCls
.
getAttributes
().
add
(
AttributeFlag
.
DONT_GENERATE
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java
View file @
dabaeed8
...
...
@@ -109,7 +109,7 @@ public class SimplifyVisitor extends AbstractVisitor {
case
INVOKE:
MethodInfo
callMth
=
((
InvokeNode
)
insn
).
getCallMth
();
if
(
callMth
.
getDeclClass
().
getFullName
().
equals
(
Consts
.
CLASS_STRING_BUILDER
)
&&
callMth
.
getShortId
().
equals
(
"toString()"
)
&&
callMth
.
getShortId
().
equals
(
Consts
.
MTH_TOSTRING_SIGNATURE
)
&&
insn
.
getArg
(
0
).
isInsnWrap
())
{
try
{
List
<
InsnNode
>
chain
=
flattenInsnChain
(
insn
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment