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
5c48a457
Commit
5c48a457
authored
Oct 18, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code style issues
parent
b5f439e1
Hide whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
262 additions
and
168 deletions
+262
-168
AnnotationGen.java
jadx-core/src/main/java/jadx/core/codegen/AnnotationGen.java
+2
-2
ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+9
-7
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+9
-9
MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+4
-7
TypeGen.java
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
+3
-0
AnnotationsList.java
...jadx/core/dex/attributes/annotations/AnnotationsList.java
+4
-0
InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+0
-2
LiteralArg.java
...main/java/jadx/core/dex/instructions/args/LiteralArg.java
+2
-2
SSAVar.java
...src/main/java/jadx/core/dex/instructions/args/SSAVar.java
+6
-14
MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+9
-18
DebugInfoParser.java
...main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
+1
-1
LocalVar.java
...re/src/main/java/jadx/core/dex/nodes/parser/LocalVar.java
+5
-7
IfInfo.java
...rc/main/java/jadx/core/dex/regions/conditions/IfInfo.java
+1
-1
LoopRegion.java
...src/main/java/jadx/core/dex/regions/loops/LoopRegion.java
+0
-1
ClassModifier.java
...e/src/main/java/jadx/core/dex/visitors/ClassModifier.java
+2
-2
CodeShrinker.java
...re/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
+7
-6
ConstInlinerVisitor.java
...main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
+1
-1
EnumVisitor.java
...ore/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
+0
-5
ModVisitor.java
...core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
+2
-3
ReSugarCode.java
...ore/src/main/java/jadx/core/dex/visitors/ReSugarCode.java
+1
-1
IfRegionVisitor.java
.../java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
+1
-1
ProcessVariables.java
...java/jadx/core/dex/visitors/regions/ProcessVariables.java
+1
-1
RegionMakerVisitor.java
...va/jadx/core/dex/visitors/regions/RegionMakerVisitor.java
+1
-1
ReturnVisitor.java
...in/java/jadx/core/dex/visitors/regions/ReturnVisitor.java
+1
-1
TernaryMod.java
.../main/java/jadx/core/dex/visitors/regions/TernaryMod.java
+1
-1
PostTypeInference.java
...dx/core/dex/visitors/typeinference/PostTypeInference.java
+4
-10
SelectTypeVisitor.java
...dx/core/dex/visitors/typeinference/SelectTypeVisitor.java
+3
-0
TypeInference.java
...a/jadx/core/dex/visitors/typeinference/TypeInference.java
+1
-6
ErrorsCounter.java
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
+1
-0
RegionUtils.java
jadx-core/src/main/java/jadx/core/utils/RegionUtils.java
+2
-2
TestAPI.groovy
jadx-core/src/test/groovy/jadx/tests/TestAPI.groovy
+1
-0
TestEnums3.java
...rc/test/java/jadx/tests/integration/enums/TestEnums3.java
+49
-0
TestRFieldAccess.java
...t/java/jadx/tests/integration/inner/TestRFieldAccess.java
+31
-0
TestOverloadedMethodInvoke.java
.../tests/integration/invoke/TestOverloadedMethodInvoke.java
+14
-12
TestSuperInvoke.java
...t/java/jadx/tests/integration/invoke/TestSuperInvoke.java
+43
-0
TestConstructor.java
...-core/src/test/java/jadx/tests/smali/TestConstructor.java
+1
-1
JadxUpdate.java
jadx-gui/src/main/java/jadx/gui/update/JadxUpdate.java
+10
-5
VersionComparator.java
...-gui/src/main/java/jadx/gui/update/VersionComparator.java
+3
-0
JadxPreferences.java
jadx-gui/src/main/java/jadx/gui/utils/JadxPreferences.java
+14
-33
Link.java
jadx-gui/src/main/java/jadx/gui/utils/Link.java
+11
-4
JRootTest.java
jadx-gui/src/test/java/jadx/gui/treemodel/JRootTest.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/codegen/AnnotationGen.java
View file @
5c48a457
...
...
@@ -43,7 +43,7 @@ public class AnnotationGen {
public
void
addForParameter
(
CodeWriter
code
,
MethodParameters
paramsAnnotations
,
int
n
)
{
AnnotationsList
aList
=
paramsAnnotations
.
getParamList
().
get
(
n
);
if
(
aList
==
null
||
aList
.
size
()
==
0
)
{
if
(
aList
==
null
||
aList
.
isEmpty
()
)
{
return
;
}
for
(
Annotation
a
:
aList
.
getAll
())
{
...
...
@@ -54,7 +54,7 @@ public class AnnotationGen {
private
void
add
(
IAttributeNode
node
,
CodeWriter
code
)
{
AnnotationsList
aList
=
node
.
get
(
AType
.
ANNOTATION_LIST
);
if
(
aList
==
null
||
aList
.
size
()
==
0
)
{
if
(
aList
==
null
||
aList
.
isEmpty
()
)
{
return
;
}
for
(
Annotation
a
:
aList
.
getAll
())
{
...
...
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
View file @
5c48a457
...
...
@@ -148,7 +148,7 @@ public class ClassGen {
clsCode
.
add
(
' '
);
}
if
(
cls
.
getInterfaces
().
size
()
>
0
&&
!
af
.
isAnnotation
())
{
if
(
!
cls
.
getInterfaces
().
isEmpty
()
&&
!
af
.
isAnnotation
())
{
if
(
cls
.
getAccessFlags
().
isInterface
())
{
clsCode
.
add
(
"extends "
);
}
else
{
...
...
@@ -347,7 +347,7 @@ public class ClassGen {
for
(
Iterator
<
EnumField
>
it
=
enumFields
.
getFields
().
iterator
();
it
.
hasNext
();
)
{
EnumField
f
=
it
.
next
();
code
.
startLine
(
f
.
getName
());
if
(
f
.
getArgs
().
size
()
!=
0
)
{
if
(
!
f
.
getArgs
().
isEmpty
()
)
{
code
.
add
(
'('
);
for
(
Iterator
<
InsnArg
>
aIt
=
f
.
getArgs
().
iterator
();
aIt
.
hasNext
();
)
{
InsnArg
arg
=
aIt
.
next
();
...
...
@@ -403,8 +403,8 @@ public class ClassGen {
code
.
attachAnnotation
(
classNode
);
}
String
baseClass
=
useClassInternal
(
cls
.
getClassInfo
(),
classInfo
);
ArgType
[]
generics
=
classInfo
.
getType
().
getGenericTypes
();
code
.
add
(
baseClass
);
ArgType
[]
generics
=
classInfo
.
getType
().
getGenericTypes
();
if
(
generics
!=
null
)
{
code
.
add
(
'<'
);
int
len
=
generics
.
length
;
...
...
@@ -451,7 +451,7 @@ public class ClassGen {
if
(
classNode
!=
null
&&
!
classNode
.
getAccessFlags
().
isPublic
())
{
return
shortName
;
}
if
(
searchCollision
(
cls
.
dex
(),
useCls
,
shortName
))
{
if
(
searchCollision
(
cls
.
dex
(),
useCls
,
classInfo
))
{
return
fullName
;
}
if
(
classInfo
.
getPackage
().
equals
(
useCls
.
getPackage
()))
{
...
...
@@ -497,22 +497,24 @@ public class ClassGen {
return
false
;
}
private
static
boolean
searchCollision
(
DexNode
dex
,
ClassInfo
useCls
,
String
shortName
)
{
private
static
boolean
searchCollision
(
DexNode
dex
,
ClassInfo
useCls
,
ClassInfo
searchCls
)
{
if
(
useCls
==
null
)
{
return
false
;
}
String
shortName
=
searchCls
.
getShortName
();
if
(
useCls
.
getShortName
().
equals
(
shortName
))
{
return
true
;
}
ClassNode
classNode
=
dex
.
resolveClass
(
useCls
);
if
(
classNode
!=
null
)
{
for
(
ClassNode
inner
:
classNode
.
getInnerClasses
())
{
if
(
inner
.
getShortName
().
equals
(
shortName
))
{
if
(
inner
.
getShortName
().
equals
(
shortName
)
&&
!
inner
.
getClassInfo
().
equals
(
searchCls
))
{
return
true
;
}
}
}
return
searchCollision
(
dex
,
useCls
.
getParentClass
(),
s
hortName
);
return
searchCollision
(
dex
,
useCls
.
getParentClass
(),
s
earchCls
);
}
private
void
insertSourceFileInfo
(
CodeWriter
code
,
AttrNode
node
)
{
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
5c48a457
...
...
@@ -47,6 +47,7 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -132,14 +133,13 @@ public class InsnGen {
private
void
instanceField
(
CodeWriter
code
,
FieldInfo
field
,
InsnArg
arg
)
throws
CodegenException
{
ClassNode
pCls
=
mth
.
getParentClass
();
FieldNode
fieldNode
=
pCls
.
searchField
(
field
);
while
((
fieldNode
==
null
)
&&
(
pCls
.
getParentClass
()
!=
pCls
)
&&
(
pCls
.
getParentClass
()
!=
null
))
{
while
(
fieldNode
==
null
&&
pCls
.
getParentClass
()
!=
pCls
&&
pCls
.
getParentClass
()
!=
null
)
{
pCls
=
pCls
.
getParentClass
();
fieldNode
=
pCls
.
searchField
(
field
);
}
if
(
fieldNode
!=
null
)
{
if
(
fieldNode
!=
null
)
{
FieldReplaceAttr
replace
=
fieldNode
.
get
(
AType
.
FIELD_REPLACE
);
if
(
replace
!=
null
)
{
FieldInfo
info
=
replace
.
getFieldInfo
();
...
...
@@ -201,7 +201,7 @@ public class InsnGen {
if
(
insn
.
getType
()
==
InsnType
.
NOP
)
{
return
false
;
}
Enum
Set
<
Flags
>
state
=
EnumSet
.
noneOf
(
Flags
.
class
);
Set
<
Flags
>
state
=
EnumSet
.
noneOf
(
Flags
.
class
);
if
(
flag
==
Flags
.
BODY_ONLY
||
flag
==
Flags
.
BODY_ONLY_NOWRAP
)
{
state
.
add
(
flag
);
makeInsnBody
(
code
,
insn
,
state
);
...
...
@@ -224,7 +224,7 @@ public class InsnGen {
return
true
;
}
private
void
makeInsnBody
(
CodeWriter
code
,
InsnNode
insn
,
Enum
Set
<
Flags
>
state
)
throws
CodegenException
{
private
void
makeInsnBody
(
CodeWriter
code
,
InsnNode
insn
,
Set
<
Flags
>
state
)
throws
CodegenException
{
switch
(
insn
.
getType
())
{
case
CONST_STR:
String
str
=
((
ConstStringNode
)
insn
).
getString
();
...
...
@@ -748,7 +748,7 @@ public class InsnGen {
return
true
;
}
private
void
makeTernary
(
TernaryInsn
insn
,
CodeWriter
code
,
Enum
Set
<
Flags
>
state
)
throws
CodegenException
{
private
void
makeTernary
(
TernaryInsn
insn
,
CodeWriter
code
,
Set
<
Flags
>
state
)
throws
CodegenException
{
boolean
wrap
=
state
.
contains
(
Flags
.
BODY_ONLY
);
if
(
wrap
)
{
code
.
add
(
'('
);
...
...
@@ -770,7 +770,7 @@ public class InsnGen {
}
}
private
void
makeArith
(
ArithNode
insn
,
CodeWriter
code
,
Enum
Set
<
Flags
>
state
)
throws
CodegenException
{
private
void
makeArith
(
ArithNode
insn
,
CodeWriter
code
,
Set
<
Flags
>
state
)
throws
CodegenException
{
if
(
insn
.
contains
(
AFlag
.
ARITH_ONEARG
))
{
makeArithOneArg
(
insn
,
code
);
return
;
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
View file @
5c48a457
...
...
@@ -206,13 +206,10 @@ public class MethodGen {
if
(
insn
==
null
)
{
continue
;
}
if
(
addLabels
)
{
if
(
insn
.
contains
(
AType
.
JUMP
)
||
insn
.
contains
(
AType
.
EXC_HANDLER
))
{
code
.
decIndent
();
code
.
startLine
(
getLabelName
(
insn
.
getOffset
())
+
":"
);
code
.
incIndent
();
}
if
(
addLabels
&&
(
insn
.
contains
(
AType
.
JUMP
)
||
insn
.
contains
(
AType
.
EXC_HANDLER
)))
{
code
.
decIndent
();
code
.
startLine
(
getLabelName
(
insn
.
getOffset
())
+
":"
);
code
.
incIndent
();
}
try
{
if
(
insnGen
.
makeInsn
(
insn
,
code
))
{
...
...
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
View file @
5c48a457
...
...
@@ -8,6 +8,9 @@ import jadx.core.utils.exceptions.JadxRuntimeException;
public
class
TypeGen
{
private
TypeGen
()
{
}
public
static
String
signature
(
ArgType
type
)
{
PrimitiveType
stype
=
type
.
getPrimitiveType
();
if
(
stype
==
PrimitiveType
.
OBJECT
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/annotations/AnnotationsList.java
View file @
5c48a457
...
...
@@ -32,6 +32,10 @@ public class AnnotationsList implements IAttribute {
return
map
.
size
();
}
public
boolean
isEmpty
()
{
return
map
.
isEmpty
();
}
@Override
public
AType
<
AnnotationsList
>
getType
()
{
return
AType
.
ANNOTATION_LIST
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
View file @
5c48a457
...
...
@@ -12,8 +12,6 @@ import jadx.core.dex.nodes.InsnNode;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.utils.exceptions.DecodeException
;
import
java.io.EOFException
;
import
com.android.dex.Code
;
import
com.android.dx.io.OpcodeInfo
;
import
com.android.dx.io.Opcodes
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java
View file @
5c48a457
...
...
@@ -38,11 +38,11 @@ public final class LiteralArg extends InsnArg {
public
boolean
isInteger
()
{
PrimitiveType
type
=
this
.
type
.
getPrimitiveType
();
return
(
type
==
PrimitiveType
.
INT
return
type
==
PrimitiveType
.
INT
||
type
==
PrimitiveType
.
BYTE
||
type
==
PrimitiveType
.
CHAR
||
type
==
PrimitiveType
.
SHORT
||
type
==
PrimitiveType
.
LONG
)
;
||
type
==
PrimitiveType
.
LONG
;
}
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/SSAVar.java
View file @
5c48a457
...
...
@@ -29,7 +29,6 @@ public class SSAVar {
if
(
assign
!=
null
)
{
assign
.
setSVar
(
this
);
}
startUseAddr
=
-
1
;
endUseAddr
=
-
1
;
}
...
...
@@ -52,30 +51,23 @@ public class SSAVar {
int
start
=
Integer
.
MAX_VALUE
;
int
end
=
Integer
.
MIN_VALUE
;
if
(
assign
!=
null
)
{
if
(
assign
.
getParentInsn
()
!=
null
)
{
int
insnAddr
=
assign
.
getParentInsn
().
getOffset
();
if
(
insnAddr
>=
0
)
{
start
=
Math
.
min
(
insnAddr
,
start
);
end
=
Math
.
max
(
insnAddr
,
end
);
}
if
(
assign
!=
null
&&
assign
.
getParentInsn
()
!=
null
)
{
int
insnAddr
=
assign
.
getParentInsn
().
getOffset
();
if
(
insnAddr
>=
0
)
{
start
=
Math
.
min
(
insnAddr
,
start
);
end
=
Math
.
max
(
insnAddr
,
end
);
}
}
for
(
RegisterArg
arg
:
useList
)
{
if
(
arg
.
getParentInsn
()
!=
null
)
{
int
insnAddr
=
arg
.
getParentInsn
().
getOffset
();
if
(
insnAddr
>=
0
)
{
start
=
Math
.
min
(
insnAddr
,
start
);
end
=
Math
.
max
(
insnAddr
,
end
);
}
}
}
if
((
start
!=
Integer
.
MAX_VALUE
)
&&
(
end
!=
Integer
.
MIN_VALUE
))
{
if
(
start
!=
Integer
.
MAX_VALUE
&&
end
!=
Integer
.
MIN_VALUE
)
{
startUseAddr
=
start
;
endUseAddr
=
end
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
View file @
5c48a457
...
...
@@ -204,9 +204,8 @@ public class MethodNode extends LineAttrNode implements ILoadable {
list
.
add
(
thisArg
);
list
.
addAll
(
argsList
);
return
list
;
}
else
{
return
argsList
;
}
return
argsList
;
}
public
RegisterArg
removeFirstArgument
()
{
...
...
@@ -277,7 +276,6 @@ public class MethodNode extends LineAttrNode implements ILoadable {
for
(
TryCatchBlock
ct
:
catches
)
{
for
(
ExceptionHandler
eh
:
ct
.
getHandlers
())
{
int
addr
=
eh
.
getHandleOffset
();
// assert addrs.add(addr) : "Instruction already contains EXC_HANDLER attribute";
ExcHandlerAttr
ehAttr
=
new
ExcHandlerAttr
(
ct
,
eh
);
insnByOffset
[
addr
].
addAttr
(
ehAttr
);
}
...
...
@@ -313,18 +311,17 @@ public class MethodNode extends LineAttrNode implements ILoadable {
continue
;
}
switch
(
insn
.
getType
())
{
case
SWITCH:
{
case
SWITCH:
SwitchNode
sw
=
(
SwitchNode
)
insn
;
for
(
int
target
:
sw
.
getTargets
())
{
addJump
(
insnByOffset
,
offset
,
target
);
}
// default case
int
next
=
InsnDecoder
.
getNextInsnOffset
(
insnByOffset
,
offset
);
if
(
next
!=
-
1
)
{
addJump
(
insnByOffset
,
offset
,
next
);
int
next
InsnOffset
=
InsnDecoder
.
getNextInsnOffset
(
insnByOffset
,
offset
);
if
(
next
InsnOffset
!=
-
1
)
{
addJump
(
insnByOffset
,
offset
,
next
InsnOffset
);
}
break
;
}
case
IF:
int
next
=
InsnDecoder
.
getNextInsnOffset
(
insnByOffset
,
offset
);
...
...
@@ -499,25 +496,19 @@ public class MethodNode extends LineAttrNode implements ILoadable {
public
boolean
isDefaultConstructor
()
{
boolean
result
=
false
;
if
(
accFlags
.
isConstructor
()
&&
mthInfo
.
isConstructor
())
{
int
defaultArgCount
=
0
;
/** workaround for non-static inner class constructor, that has
* synthetic argument */
/** workaround for non-static inner class constructor, that has synthetic argument */
if
(
parentClass
.
getClassInfo
().
isInner
()
&&
!
parentClass
.
getAccessFlags
().
isStatic
())
{
ClassNode
outerCls
=
parentClass
.
getParentClass
();
if
((
argsList
!=
null
)
&&
(
argsList
.
size
()
>=
1
))
{
if
(
argsList
.
get
(
0
).
getType
().
equals
(
outerCls
.
getClassInfo
().
getType
()))
{
defaultArgCount
=
1
;
}
if
(
argsList
!=
null
&&
!
argsList
.
isEmpty
()
&&
argsList
.
get
(
0
).
getType
().
equals
(
outerCls
.
getClassInfo
().
getType
()))
{
defaultArgCount
=
1
;
}
}
result
=
(
argsList
==
null
)
||
(
argsList
.
size
()
==
defaultArgCount
);
}
return
result
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
View file @
5c48a457
...
...
@@ -162,7 +162,7 @@ public class DebugInfoParser {
for
(
LocalVar
var
:
locals
)
{
if
(
var
!=
null
&&
!
var
.
isEnd
())
{
var
.
end
(
mth
.
getCodeSize
()
-
1
,
line
);
var
.
end
(
mth
.
getCodeSize
()
-
1
,
line
);
setVar
(
var
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/LocalVar.java
View file @
5c48a457
...
...
@@ -21,9 +21,9 @@ final class LocalVar {
public
LocalVar
(
DexNode
dex
,
int
rn
,
int
nameId
,
int
typeId
,
int
signId
)
{
this
.
regNum
=
rn
;
String
name
=
(
nameId
==
DexNode
.
NO_INDEX
?
null
:
dex
.
getString
(
nameId
)
);
ArgType
type
=
(
typeId
==
DexNode
.
NO_INDEX
?
null
:
dex
.
getType
(
typeId
)
);
String
sign
=
(
signId
==
DexNode
.
NO_INDEX
?
null
:
dex
.
getString
(
signId
)
);
String
name
=
nameId
==
DexNode
.
NO_INDEX
?
null
:
dex
.
getString
(
nameId
);
ArgType
type
=
typeId
==
DexNode
.
NO_INDEX
?
null
:
dex
.
getType
(
typeId
);
String
sign
=
signId
==
DexNode
.
NO_INDEX
?
null
:
dex
.
getString
(
signId
);
init
(
name
,
type
,
sign
);
}
...
...
@@ -56,10 +56,8 @@ final class LocalVar {
LOG
.
warn
(
"Generic type in debug info not equals: {} != {}"
,
type
,
gType
);
}
apply
=
true
;
}
else
if
(
el
.
isGenericType
())
{
apply
=
true
;
}
else
{
apply
=
false
;
apply
=
el
.
isGenericType
()
;
}
return
apply
;
}
...
...
@@ -71,6 +69,7 @@ final class LocalVar {
/**
* Sets end address of local variable
*
* @param addr address
* @param line source line
* @return <b>true</b> if local variable was active, else <b>false</b>
...
...
@@ -81,7 +80,6 @@ final class LocalVar {
this
.
endAddr
=
addr
;
return
true
;
}
return
false
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfInfo.java
View file @
5c48a457
...
...
@@ -28,7 +28,7 @@ public final class IfInfo {
}
private
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
,
Set
<
BlockNode
>
mergedBlocks
,
Set
<
BlockNode
>
skipBlocks
)
{
Set
<
BlockNode
>
mergedBlocks
,
Set
<
BlockNode
>
skipBlocks
)
{
this
.
condition
=
condition
;
this
.
thenBlock
=
thenBlock
;
this
.
elseBlock
=
elseBlock
;
...
...
jadx-core/src/main/java/jadx/core/dex/regions/loops/LoopRegion.java
View file @
5c48a457
...
...
@@ -126,7 +126,6 @@ public final class LoopRegion extends AbstractRegion {
}
}
public
LoopType
getType
()
{
return
type
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ClassModifier.java
View file @
5c48a457
...
...
@@ -125,7 +125,7 @@ public class ClassModifier extends AbstractVisitor {
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
).
size
()
>=
1
)
{
if
(
constr
.
isThis
()
&&
!
mth
.
getArguments
(
false
).
isEmpty
()
)
{
mth
.
removeFirstArgument
();
mth
.
add
(
AFlag
.
DONT_GENERATE
);
}
...
...
@@ -167,7 +167,7 @@ public class ClassModifier extends AbstractVisitor {
private
static
boolean
allBlocksEmpty
(
List
<
BlockNode
>
blocks
)
{
for
(
BlockNode
block
:
blocks
)
{
if
(
block
.
getInstructions
().
size
()
!=
0
)
{
if
(
!
block
.
getInstructions
().
isEmpty
()
)
{
return
false
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
View file @
5c48a457
...
...
@@ -55,7 +55,7 @@ public class CodeShrinker extends AbstractVisitor {
}
public
static
List
<
RegisterArg
>
getArgs
(
InsnNode
insn
)
{
Li
nkedLi
st
<
RegisterArg
>
args
=
new
LinkedList
<
RegisterArg
>();
List
<
RegisterArg
>
args
=
new
LinkedList
<
RegisterArg
>();
addArgs
(
insn
,
args
);
return
args
;
}
...
...
@@ -105,9 +105,9 @@ public class CodeShrinker extends AbstractVisitor {
if
(
start
>
to
)
{
throw
new
JadxRuntimeException
(
"Invalid inline insn positions: "
+
start
+
" - "
+
to
);
}
BitSet
args
=
new
BitSet
();
BitSet
movedSet
=
new
BitSet
();
for
(
RegisterArg
arg
:
movedArgs
)
{
args
.
set
(
arg
.
getRegNum
());
movedSet
.
set
(
arg
.
getRegNum
());
}
for
(
int
i
=
start
;
i
<
to
;
i
++)
{
ArgsInfo
argsInfo
=
argsList
.
get
(
i
);
...
...
@@ -115,7 +115,7 @@ public class CodeShrinker extends AbstractVisitor {
continue
;
}
InsnNode
curInsn
=
argsInfo
.
insn
;
if
(!
curInsn
.
canReorder
()
||
usedArgAssign
(
curInsn
,
args
))
{
if
(!
curInsn
.
canReorder
()
||
usedArgAssign
(
curInsn
,
movedSet
))
{
return
false
;
}
}
...
...
@@ -187,7 +187,8 @@ public class CodeShrinker extends AbstractVisitor {
List
<
WrapInfo
>
wrapList
=
new
ArrayList
<
WrapInfo
>();
for
(
ArgsInfo
argsInfo
:
argsList
)
{
List
<
RegisterArg
>
args
=
argsInfo
.
getArgs
();
for
(
ListIterator
<
RegisterArg
>
it
=
args
.
listIterator
(
args
.
size
());
it
.
hasPrevious
();
)
{
ListIterator
<
RegisterArg
>
it
=
args
.
listIterator
(
args
.
size
());
while
(
it
.
hasPrevious
())
{
RegisterArg
arg
=
it
.
previous
();
// if (arg.getName() != null) {
// continue;
...
...
@@ -293,7 +294,7 @@ public class CodeShrinker extends AbstractVisitor {
}
}
// remove method args
if
(
list
.
size
()
!=
0
&&
args
.
size
()
!=
0
)
{
if
(
!
list
.
isEmpty
()
&&
!
args
.
isEmpty
()
)
{
list
.
removeAll
(
args
);
}
i
++;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
View file @
5c48a457
...
...
@@ -150,7 +150,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
InvokeNode
inv
=
(
InvokeNode
)
insn
;
List
<
ArgType
>
types
=
inv
.
getCallMth
().
getArgumentsTypes
();
int
count
=
insn
.
getArgsCount
();
int
k
=
(
types
.
size
()
==
count
?
0
:
-
1
)
;
int
k
=
types
.
size
()
==
count
?
0
:
-
1
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
InsnArg
arg
=
insn
.
getArg
(
i
);
if
(!
arg
.
getType
().
isTypeKnown
())
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
View file @
5c48a457
...
...
@@ -114,21 +114,17 @@ public class EnumVisitor extends AbstractVisitor {
for
(
InsnNode
insn
:
insns
)
{
if
(
insn
.
getType
()
==
InsnType
.
CONSTRUCTOR
)
{
ConstructorInsn
co
=
(
ConstructorInsn
)
insn
;
if
(
insn
.
getArgsCount
()
<
2
)
{
continue
;
}
ClassInfo
clsInfo
=
co
.
getClassType
();
ClassNode
constrCls
=
cls
.
dex
().
resolveClass
(
clsInfo
);
if
(
constrCls
==
null
)
{
continue
;
}
if
(!
clsInfo
.
equals
(
cls
.
getClassInfo
())
&&
!
constrCls
.
getAccessFlags
().
isEnum
())
{
continue
;
}
RegisterArg
nameArg
=
(
RegisterArg
)
insn
.
getArg
(
0
);
// InsnArg pos = insn.getArg(1);
// TODO add check: pos == j
...
...
@@ -136,7 +132,6 @@ public class EnumVisitor extends AbstractVisitor {
if
(
name
==
null
)
{
throw
new
JadxException
(
"Unknown enum field name: "
+
cls
);
}
EnumField
field
=
new
EnumField
(
name
,
insn
.
getArgsCount
()
-
2
);
attr
.
getFields
().
add
(
field
);
for
(
int
i
=
2
;
i
<
insn
.
getArgsCount
();
i
++)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
View file @
5c48a457
...
...
@@ -244,7 +244,7 @@ public class ModVisitor extends AbstractVisitor {
InstructionRemover
.
remove
(
mth
,
excBlock
,
size
-
1
);
// move not removed instructions to 'finally' block
if
(
insns
.
size
()
!=
0
)
{
if
(
!
insns
.
isEmpty
()
)
{
// TODO: support instructions from several blocks
// tryBlock.setFinalBlockFromInsns(mth, insns);
// TODO: because of incomplete realization don't extract final block,
...
...
@@ -255,14 +255,13 @@ public class ModVisitor extends AbstractVisitor {
}
List
<
InsnNode
>
blockInsns
=
block
.
getInstructions
();
if
(
blockInsns
.
size
()
>
0
)
{
if
(
!
blockInsns
.
isEmpty
()
)
{
InsnNode
insn
=
blockInsns
.
get
(
0
);
if
(
insn
.
getType
()
==
InsnType
.
MOVE_EXCEPTION
&&
insn
.
getResult
().
getSVar
().
getUseCount
()
==
0
)
{
InstructionRemover
.
remove
(
mth
,
block
,
0
);
}
}
int
totalSize
=
0
;
for
(
BlockNode
excBlock
:
excHandler
.
getBlocks
())
{
totalSize
+=
excBlock
.
getInstructions
().
size
();
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ReSugarCode.java
View file @
5c48a457
...
...
@@ -218,7 +218,7 @@ public class ReSugarCode extends AbstractVisitor {
if
(!(
index
instanceof
FieldInfo
))
{
return
null
;
}
FieldNode
enumMapField
=
mth
.
dex
().
resolveField
((
(
FieldInfo
)
index
)
);
FieldNode
enumMapField
=
mth
.
dex
().
resolveField
((
FieldInfo
)
index
);
if
(
enumMapField
==
null
||
!
enumMapField
.
getAccessFlags
().
isSynthetic
())
{
return
null
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
View file @
5c48a457
...
...
@@ -6,10 +6,10 @@ import jadx.core.dex.nodes.IBlock;
import
jadx.core.dex.nodes.IContainer
;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.regions.conditions.IfCondition
;
import
jadx.core.dex.regions.conditions.IfCondition.Mode
;
import
jadx.core.dex.regions.conditions.IfRegion
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.RegionUtils
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
View file @
5c48a457
...
...
@@ -12,8 +12,8 @@ import jadx.core.dex.nodes.IContainer;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.conditions.IfRegion
;
import
jadx.core.dex.regions.SwitchRegion
;
import
jadx.core.dex.regions.conditions.IfRegion
;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.RegionUtils
;
import
jadx.core.utils.exceptions.JadxException
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMakerVisitor.java
View file @
5c48a457
...
...
@@ -4,9 +4,9 @@ import jadx.core.dex.nodes.IContainer;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.loops.LoopRegion
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.regions.SynchronizedRegion
;
import
jadx.core.dex.regions.loops.LoopRegion
;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.InstructionRemover
;
import
jadx.core.utils.exceptions.JadxException
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ReturnVisitor.java
View file @
5c48a457
...
...
@@ -8,9 +8,9 @@ import jadx.core.dex.nodes.IContainer;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.SwitchRegion
;
import
jadx.core.dex.regions.conditions.IfRegion
;
import
jadx.core.dex.regions.loops.LoopRegion
;
import
jadx.core.dex.regions.SwitchRegion
;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/TernaryMod.java
View file @
5c48a457
...
...
@@ -12,8 +12,8 @@ import jadx.core.dex.nodes.BlockNode;
import
jadx.core.dex.nodes.IContainer
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.conditions.IfRegion
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.regions.conditions.IfRegion
;
import
jadx.core.dex.visitors.CodeShrinker
;
import
jadx.core.utils.InsnList
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/PostTypeInference.java
View file @
5c48a457
...
...
@@ -16,6 +16,9 @@ import java.util.List;
public
class
PostTypeInference
{
private
PostTypeInference
()
{
}
public
static
boolean
process
(
MethodNode
mth
,
InsnNode
insn
)
{
switch
(
insn
.
getType
())
{
case
CONST:
...
...
@@ -25,7 +28,7 @@ public class PostTypeInference {
long
lit
=
litArg
.
getLiteral
();
if
(
lit
!=
0
)
{
// incorrect literal value for object
ArgType
type
=
(
lit
==
1
?
ArgType
.
BOOLEAN
:
ArgType
.
INT
)
;
ArgType
type
=
lit
==
1
?
ArgType
.
BOOLEAN
:
ArgType
.
INT
;
// can't merge with object -> force it
litArg
.
setType
(
type
);
res
.
getSVar
().
setType
(
type
);
...
...
@@ -115,15 +118,6 @@ public class PostTypeInference {
break
;
}
return
false
;
}
static
void
setType
(
InsnArg
arg
,
ArgType
type
)
{
if
(
arg
.
isRegister
())
{
((
RegisterArg
)
arg
).
getSVar
().
setType
(
type
);
}
else
{
arg
.
setType
(
type
);
}
}
private
static
boolean
fixArrayTypes
(
InsnArg
array
,
InsnArg
elem
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/SelectTypeVisitor.java
View file @
5c48a457
...
...
@@ -6,6 +6,9 @@ import jadx.core.dex.nodes.InsnNode;
public
class
SelectTypeVisitor
{
private
SelectTypeVisitor
()
{
}
public
static
void
visit
(
InsnNode
insn
)
{
InsnArg
res
=
insn
.
getResult
();
if
(
res
!=
null
&&
!
res
.
getType
().
isTypeKnown
())
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInference.java
View file @
5c48a457
...
...
@@ -47,12 +47,7 @@ public class TypeInference extends AbstractVisitor {
if
(
assign
!=
null
&&
(
useList
.
isEmpty
()
||
var
.
isTypeImmutable
()))
{
return
assign
.
getType
();
}
ArgType
type
;
if
(
assign
!=
null
)
{
type
=
assign
.
getType
();
}
else
{
type
=
ArgType
.
UNKNOWN
;
}
ArgType
type
=
assign
!=
null
?
assign
.
getType
()
:
ArgType
.
UNKNOWN
;
for
(
RegisterArg
arg
:
useList
)
{
ArgType
useType
=
arg
.
getType
();
ArgType
newType
=
ArgType
.
merge
(
type
,
useType
);
...
...
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
View file @
5c48a457
...
...
@@ -66,6 +66,7 @@ public class ErrorsCounter {
mth
.
dex
().
root
().
getErrorsCounter
().
addError
(
mth
,
msg
,
e
);
return
msg
;
}
public
static
String
methodError
(
MethodNode
mth
,
String
errorMsg
)
{
return
methodError
(
mth
,
errorMsg
,
null
);
}
...
...
jadx-core/src/main/java/jadx/core/utils/RegionUtils.java
View file @
5c48a457
...
...
@@ -27,7 +27,7 @@ public class RegionUtils {
public
static
boolean
hasExitEdge
(
IContainer
container
)
{
if
(
container
instanceof
BlockNode
)
{
BlockNode
block
=
(
BlockNode
)
container
;
return
block
.
getSuccessors
().
size
()
!=
0
return
!
block
.
getSuccessors
().
isEmpty
()
&&
!
block
.
contains
(
AFlag
.
RETURN
);
}
else
if
(
container
instanceof
IRegion
)
{
IRegion
region
=
(
IRegion
)
container
;
...
...
@@ -109,7 +109,7 @@ public class RegionUtils {
public
static
boolean
notEmpty
(
IContainer
container
)
{
if
(
container
instanceof
BlockNode
)
{
return
((
BlockNode
)
container
).
getInstructions
().
size
()
!=
0
;
return
!((
BlockNode
)
container
).
getInstructions
().
isEmpty
()
;
}
else
if
(
container
instanceof
IRegion
)
{
IRegion
region
=
(
IRegion
)
container
;
for
(
IContainer
block
:
region
.
getSubBlocks
())
{
...
...
jadx-core/src/test/groovy/jadx/tests/TestAPI.groovy
View file @
5c48a457
package
jadx.tests
import
jadx.api.IJadxArgs
import
jadx.api.JadxDecompiler
import
jadx.core.utils.exceptions.JadxException
...
...
jadx-core/src/test/java/jadx/tests/integration/enums/TestEnums3.java
0 → 100644
View file @
5c48a457
package
jadx
.
tests
.
integration
.
enums
;
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
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestEnums3
extends
IntegrationTest
{
public
static
class
TestCls
{
private
static
int
three
=
3
;
public
enum
Numbers
{
ONE
(
1
),
TWO
(
2
),
THREE
(
three
),
FOUR
(
three
+
1
);
private
final
int
num
;
private
Numbers
(
int
n
)
{
this
.
num
=
n
;
}
public
int
getNum
()
{
return
num
;
}
}
public
void
check
()
{
assertTrue
(
Numbers
.
ONE
.
getNum
()
==
1
);
assertTrue
(
Numbers
.
THREE
.
getNum
()
==
3
);
assertTrue
(
Numbers
.
FOUR
.
getNum
()
==
4
);
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"ONE(1)"
));
// assertThat(code, containsOne("THREE(three)"));
// assertThat(code, containsOne("assertTrue(Numbers.ONE.getNum() == 1);"));
assertThat
(
code
,
containsOne
(
"private Numbers(int n) {"
));
}
}
jadx-core/src/test/java/jadx/tests/integration/inner/TestRFieldAccess.java
0 → 100644
View file @
5c48a457
package
jadx
.
tests
.
integration
.
inner
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
countString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestRFieldAccess
extends
IntegrationTest
{
public
static
class
R
{
public
static
final
class
id
{
public
static
final
int
Button01
=
2131230730
;
}
}
public
static
class
TestR
{
public
int
test
()
{
return
R
.
id
.
Button01
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestRFieldAccess
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
countString
(
2
,
"return R.id.Button01;"
));
}
}
jadx-core/src/test/java/jadx/tests/integration/invoke/TestOverloadedMethodInvoke.java
View file @
5c48a457
...
...
@@ -16,30 +16,32 @@ public class TestOverloadedMethodInvoke extends IntegrationTest {
public
static
class
TestCls
{
int
c
;
public
void
method
(
Throwable
th
)
{
public
void
method
(
Throwable
th
,
int
a
)
{
c
++;
if
(
th
!=
null
)
{
c
+=
100
;
}
c
+=
a
;
}
public
void
method
(
Exception
e
)
{
public
void
method
(
Exception
e
,
int
a
)
{
c
+=
1000
;
if
(
e
!=
null
)
{
c
+=
10000
;
}
c
+=
a
;
}
public
void
test
(
Throwable
th
,
Exception
e
)
{
method
(
e
);
method
(
th
);
method
((
Throwable
)
e
);
method
((
Exception
)
th
);
method
(
e
,
10
);
method
(
th
,
100
);
method
((
Throwable
)
e
,
1000
);
method
((
Exception
)
th
,
10000
);
}
public
void
check
()
{
test
(
null
,
new
Exception
());
assertEquals
(
1210
2
,
c
);
assertEquals
(
2321
2
,
c
);
}
}
...
...
@@ -48,11 +50,11 @@ public class TestOverloadedMethodInvoke extends IntegrationTest {
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
contains
String
(
"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
,
contains
One
(
"public void test(Throwable th, Exception e) {"
));
assertThat
(
code
,
containsOne
(
"method(e
, 10
);"
));
assertThat
(
code
,
containsOne
(
"method(th
, 100
);"
));
assertThat
(
code
,
containsOne
(
"method((Throwable) e
, 1000
);"
));
assertThat
(
code
,
containsOne
(
"method((Exception) th
, 10000
);"
));
assertThat
(
code
,
not
(
containsString
(
"(Exception) e"
)));
}
}
jadx-core/src/test/java/jadx/tests/integration/invoke/TestSuperInvoke.java
0 → 100644
View file @
5c48a457
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
.
countString
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestSuperInvoke
extends
IntegrationTest
{
public
class
A
{
public
int
a
()
{
return
1
;
}
}
public
class
B
extends
A
{
@Override
public
int
a
()
{
return
super
.
a
()
+
2
;
}
public
int
test
()
{
return
a
();
}
}
public
void
check
()
{
assertEquals
(
3
,
new
B
().
test
());
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestSuperInvoke
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
countString
(
2
,
"return super.a() + 2;"
));
}
}
jadx-core/src/test/java/jadx/tests/smali/TestConstructor.java
View file @
5c48a457
package
jadx
.
tests
.
smali
;
import
jadx.tests.api.SmaliTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.SmaliTest
;
import
org.junit.Test
;
...
...
jadx-gui/src/main/java/jadx/gui/update/JadxUpdate.java
View file @
5c48a457
...
...
@@ -3,6 +3,7 @@ package jadx.gui.update;
import
jadx.api.JadxDecompiler
;
import
jadx.gui.update.data.Release
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.lang.reflect.Type
;
...
...
@@ -29,7 +30,8 @@ public class JadxUpdate {
private
static
final
Gson
GSON
=
new
Gson
();
private
static
final
Type
RELEASES_LIST_TYPE
=
new
TypeToken
<
List
<
Release
>>()
{}.
getType
();
private
static
final
Type
RELEASES_LIST_TYPE
=
new
TypeToken
<
List
<
Release
>>()
{
}.
getType
();
private
static
final
Comparator
<
Release
>
RELEASE_COMPARATOR
=
new
Comparator
<
Release
>()
{
@Override
...
...
@@ -38,12 +40,15 @@ public class JadxUpdate {
}
};
public
static
interface
IUpdateCallback
{
public
interface
IUpdateCallback
{
void
onUpdate
(
Release
r
);
}
private
JadxUpdate
()
{
}
public
static
void
check
(
final
IUpdateCallback
callback
)
{
Runnable
run
=
new
Runnable
()
{
Runnable
run
=
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
...
...
@@ -62,7 +67,7 @@ public class JadxUpdate {
thread
.
start
();
}
private
static
Release
checkForNewRelease
()
throws
Exception
{
private
static
Release
checkForNewRelease
()
throws
IO
Exception
{
String
version
=
JadxDecompiler
.
getVersion
();
if
(
version
.
contains
(
"dev"
))
{
LOG
.
debug
(
"Ignore check for update: development version"
);
...
...
@@ -92,7 +97,7 @@ public class JadxUpdate {
return
latest
;
}
private
static
<
T
>
T
get
(
String
url
,
Type
type
)
throws
Exception
{
private
static
<
T
>
T
get
(
String
url
,
Type
type
)
throws
IO
Exception
{
URL
obj
=
new
URL
(
url
);
HttpURLConnection
con
=
(
HttpURLConnection
)
obj
.
openConnection
();
con
.
setRequestMethod
(
"GET"
);
...
...
jadx-gui/src/main/java/jadx/gui/update/VersionComparator.java
View file @
5c48a457
...
...
@@ -2,6 +2,9 @@ package jadx.gui.update;
public
class
VersionComparator
{
private
VersionComparator
()
{
}
public
static
int
checkAndCompare
(
String
str1
,
String
str2
)
{
try
{
return
compare
(
clean
(
str1
),
clean
(
str2
));
...
...
jadx-gui/src/main/java/jadx/gui/utils/JadxPreferences.java
View file @
5c48a457
...
...
@@ -4,98 +4,79 @@ import java.util.prefs.Preferences;
public
class
JadxPreferences
{
private
static
final
String
KEY_LAST_OPEN_FILE_PATH
=
"lastOpenFilePath"
;
private
static
final
String
KEY_LAST_SAVE_FILE_PATH
=
"lastSaveFilePath"
;
private
static
final
String
KEY_FLATTEN_PACKAGE
=
"flattenPackage"
;
private
static
Preferences
prefs
=
null
;
public
static
String
getLastOpenFilePath
()
{
String
result
=
""
;
try
{
result
=
getPreferences
().
get
(
KEY_LAST_OPEN_FILE_PATH
,
""
);
if
(
result
.
isEmpty
())
{
if
(
result
.
isEmpty
())
{
result
=
System
.
getProperty
(
"user.home"
);
}
}
catch
(
Exception
anyEx
)
{
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
return
result
;
}
public
static
void
putLastOpenFilePath
(
String
path
)
{
try
{
Preferences
prefs
=
getPreferences
();
prefs
.
put
(
KEY_LAST_OPEN_FILE_PATH
,
path
);
prefs
.
sync
();
}
catch
(
Exception
anyEx
)
{
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
}
public
static
String
getLastSaveFilePath
()
{
String
result
=
""
;
try
{
result
=
getPreferences
().
get
(
KEY_LAST_SAVE_FILE_PATH
,
""
);
if
(
result
.
isEmpty
())
{
if
(
result
.
isEmpty
())
{
result
=
getLastOpenFilePath
();
}
}
catch
(
Exception
anyEx
)
{
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
return
result
;
}
public
static
void
putLastSaveFilePath
(
String
path
)
{
try
{
Preferences
prefs
=
getPreferences
();
prefs
.
put
(
KEY_LAST_SAVE_FILE_PATH
,
path
);
prefs
.
sync
();
}
catch
(
Exception
anyEx
)
{
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
}
public
static
boolean
getFlattenPackage
()
{
boolean
result
=
false
;
try
{
Preferences
prefs
=
getPreferences
();
result
=
prefs
.
getBoolean
(
KEY_FLATTEN_PACKAGE
,
false
);
}
catch
(
Exception
anyEx
)
{
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
return
result
;
}
public
static
void
putFlattenPackage
(
boolean
value
)
{
try
{
Preferences
prefs
=
getPreferences
();
prefs
.
putBoolean
(
KEY_FLATTEN_PACKAGE
,
value
);
prefs
.
sync
();
}
catch
(
Exception
anyEx
)
{
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
}
private
static
final
String
KEY_LAST_OPEN_FILE_PATH
=
"lastOpenFilePath"
;
private
static
final
String
KEY_LAST_SAVE_FILE_PATH
=
"lastSaveFilePath"
;
private
static
final
String
KEY_FLATTEN_PACKAGE
=
"flattenPackage"
;
private
static
Preferences
prefs
=
null
;
private
static
Preferences
getPreferences
()
{
if
(
prefs
==
null
)
{
prefs
=
Preferences
.
userRoot
();
...
...
jadx-gui/src/main/java/jadx/gui/utils/Link.java
View file @
5c48a457
...
...
@@ -12,9 +12,14 @@ import java.io.IOException;
import
java.net.URISyntaxException
;
import
java.util.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
static
java
.
awt
.
Desktop
.
Action
;
public
class
Link
extends
JLabel
implements
MouseListener
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JLabel
.
class
);
private
String
url
;
public
Link
(
String
text
,
String
url
)
{
...
...
@@ -42,10 +47,12 @@ public class Link extends JLabel implements MouseListener {
@Override
public
void
mousePressed
(
MouseEvent
arg0
)
{
// ignore
}
@Override
public
void
mouseReleased
(
MouseEvent
arg0
)
{
// ignore
}
private
void
browse
()
{
...
...
@@ -56,9 +63,9 @@ public class Link extends JLabel implements MouseListener {
desktop
.
browse
(
new
java
.
net
.
URI
(
url
));
return
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
);
LOG
.
debug
(
"Open url error"
,
e
);
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
(
);
LOG
.
debug
(
"Open url error"
,
e
);
}
}
}
...
...
@@ -78,13 +85,13 @@ public class Link extends JLabel implements MouseListener {
return
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
debug
(
"Open url error"
,
e
);
}
showUrlDialog
();
}
private
void
showUrlDialog
()
{
JTextArea
urlArea
=
new
JTextArea
(
"Can't open browser. Please browse to:\n"
+
url
);
JTextArea
urlArea
=
new
JTextArea
(
"Can't open browser. Please browse to:\n"
+
url
);
JOptionPane
.
showMessageDialog
(
null
,
urlArea
);
}
}
jadx-gui/src/test/java/jadx/gui/treemodel/JRootTest.java
View file @
5c48a457
package
jadx
.
gui
.
treemodel
;
import
jadx.api.JadxDecompiler
;
import
jadx.api.Factory
;
import
jadx.api.IJadxArgs
;
import
jadx.api.JadxDecompiler
;
import
jadx.api.JavaClass
;
import
jadx.api.JavaPackage
;
import
jadx.core.dex.nodes.ClassNode
;
...
...
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