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
50d31444
Commit
50d31444
authored
Jul 17, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix code style
parent
f8d57d92
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
80 additions
and
64 deletions
+80
-64
ClspGraph.java
jadx-core/src/main/java/jadx/core/clsp/ClspGraph.java
+22
-23
ConditionGen.java
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
+3
-2
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+1
-1
MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+1
-1
TypeGen.java
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
+1
-1
Annotation.java
...java/jadx/core/dex/attributes/annotations/Annotation.java
+1
-1
EnumClassAttr.java
...in/java/jadx/core/dex/attributes/nodes/EnumClassAttr.java
+1
-1
AccessInfo.java
jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java
+1
-1
ArithOp.java
...ore/src/main/java/jadx/core/dex/instructions/ArithOp.java
+1
-1
IfOp.java
jadx-core/src/main/java/jadx/core/dex/instructions/IfOp.java
+7
-7
ArgType.java
...rc/main/java/jadx/core/dex/instructions/args/ArgType.java
+8
-4
MthParameterArg.java
...java/jadx/core/dex/instructions/args/MthParameterArg.java
+1
-1
PrimitiveType.java
...n/java/jadx/core/dex/instructions/args/PrimitiveType.java
+1
-1
ConstructorInsn.java
...java/jadx/core/dex/instructions/mods/ConstructorInsn.java
+1
-1
RootNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
+6
-4
AnnotationsParser.java
...in/java/jadx/core/dex/nodes/parser/AnnotationsParser.java
+1
-1
LocalVar.java
...re/src/main/java/jadx/core/dex/nodes/parser/LocalVar.java
+1
-1
IfCondition.java
...core/src/main/java/jadx/core/dex/regions/IfCondition.java
+1
-1
IfRegionVisitor.java
.../java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
+2
-1
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+3
-3
InternalJadxTest.java
jadx-core/src/test/java/jadx/api/InternalJadxTest.java
+5
-1
TestUtils.java
jadx-core/src/test/java/jadx/api/TestUtils.java
+3
-0
TestAnnotations.java
...java/jadx/tests/internal/annotations/TestAnnotations.java
+8
-6
No files found.
jadx-core/src/main/java/jadx/core/clsp/ClspGraph.java
View file @
50d31444
...
...
@@ -77,15 +77,15 @@ public class ClspGraph {
return
clsName
;
}
NClass
cls
=
nameMap
.
get
(
implClsName
);
if
(
cls
!=
null
)
{
if
(
isImplements
(
clsName
,
implClsName
))
{
return
implClsName
;
}
Set
<
String
>
anc
=
getAncestors
(
clsName
);
return
searchCommonParent
(
anc
,
cls
);
if
(
cls
==
null
)
{
LOG
.
debug
(
"Missing class: {}"
,
implClsName
);
return
null
;
}
LOG
.
debug
(
"Missing class: {}"
,
implClsName
);
return
null
;
if
(
isImplements
(
clsName
,
implClsName
))
{
return
implClsName
;
}
Set
<
String
>
anc
=
getAncestors
(
clsName
);
return
searchCommonParent
(
anc
,
cls
);
}
private
String
searchCommonParent
(
Set
<
String
>
anc
,
NClass
cls
)
{
...
...
@@ -93,11 +93,10 @@ public class ClspGraph {
String
name
=
p
.
getName
();
if
(
anc
.
contains
(
name
))
{
return
name
;
}
else
{
String
r
=
searchCommonParent
(
anc
,
p
);
if
(
r
!=
null
)
{
return
r
;
}
}
String
r
=
searchCommonParent
(
anc
,
p
);
if
(
r
!=
null
)
{
return
r
;
}
}
return
null
;
...
...
@@ -109,17 +108,17 @@ public class ClspGraph {
return
result
;
}
NClass
cls
=
nameMap
.
get
(
clsName
);
if
(
cls
!
=
null
)
{
result
=
new
HashSet
<
String
>(
);
addAncestorsNames
(
cls
,
result
);
if
(
result
.
isEmpty
())
{
result
=
Collections
.
emptySet
();
}
ancestorCache
.
put
(
clsName
,
result
);
re
turn
result
;
if
(
cls
=
=
null
)
{
LOG
.
debug
(
"Missing class: {}"
,
clsName
);
return
Collections
.
emptySet
(
);
}
result
=
new
HashSet
<
String
>
();
addAncestorsNames
(
cls
,
result
);
if
(
result
.
isEmpty
())
{
re
sult
=
Collections
.
emptySet
()
;
}
LOG
.
debug
(
"Missing class: {}"
,
clsName
);
return
Collections
.
emptySet
()
;
ancestorCache
.
put
(
clsName
,
result
);
return
result
;
}
private
void
addAncestorsNames
(
NClass
cls
,
Set
<
String
>
result
)
{
...
...
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
View file @
50d31444
...
...
@@ -10,6 +10,7 @@ import jadx.core.dex.instructions.args.LiteralArg;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.regions.Compare
;
import
jadx.core.dex.regions.IfCondition
;
import
jadx.core.dex.regions.IfCondition.Mode
;
import
jadx.core.utils.ErrorsCounter
;
import
jadx.core.utils.exceptions.CodegenException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
...
...
@@ -99,7 +100,7 @@ public class ConditionGen extends InsnGen {
}
private
void
addAndOr
(
CodeWriter
code
,
IfCondition
condition
)
throws
CodegenException
{
String
mode
=
condition
.
getMode
()
==
IfCondition
.
Mode
.
AND
?
" && "
:
" || "
;
String
mode
=
condition
.
getMode
()
==
Mode
.
AND
?
" && "
:
" || "
;
Iterator
<
IfCondition
>
it
=
condition
.
getArgs
().
iterator
();
while
(
it
.
hasNext
())
{
wrap
(
code
,
it
.
next
());
...
...
@@ -110,7 +111,7 @@ public class ConditionGen extends InsnGen {
}
private
boolean
isWrapNeeded
(
IfCondition
condition
)
{
return
!
condition
.
isCompare
()
&&
condition
.
getMode
()
!=
IfCondition
.
Mode
.
NOT
;
return
!
condition
.
isCompare
()
&&
condition
.
getMode
()
!=
Mode
.
NOT
;
}
private
static
boolean
isArgWrapNeeded
(
InsnArg
arg
)
{
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
50d31444
...
...
@@ -58,7 +58,7 @@ public class InsnGen {
protected
final
RootNode
root
;
protected
final
boolean
fallback
;
private
static
enum
Flags
{
private
enum
Flags
{
BODY_ONLY
,
BODY_ONLY_NOWRAP
,
}
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
View file @
50d31444
...
...
@@ -132,7 +132,7 @@ public class MethodGen {
if
(
type
.
isArray
())
{
ArgType
elType
=
type
.
getArrayElement
();
classGen
.
useType
(
argsCode
,
elType
);
argsCode
.
add
(
"
..."
);
argsCode
.
add
(
"..."
);
}
else
{
LOG
.
warn
(
ErrorsCounter
.
formatErrorMsg
(
mth
,
"Last argument in varargs method not array"
));
classGen
.
useType
(
argsCode
,
arg
.
getType
());
...
...
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
View file @
50d31444
...
...
@@ -9,7 +9,7 @@ import jadx.core.utils.exceptions.JadxRuntimeException;
public
class
TypeGen
{
public
static
String
signature
(
ArgType
type
)
{
final
PrimitiveType
stype
=
type
.
getPrimitiveType
();
PrimitiveType
stype
=
type
.
getPrimitiveType
();
if
(
stype
==
PrimitiveType
.
OBJECT
)
{
return
Utils
.
makeQualifiedObjectName
(
type
.
getObject
());
}
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/annotations/Annotation.java
View file @
50d31444
...
...
@@ -6,7 +6,7 @@ import java.util.Map;
public
class
Annotation
{
public
static
enum
Visibility
{
public
enum
Visibility
{
BUILD
,
RUNTIME
,
SYSTEM
}
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EnumClassAttr.java
View file @
50d31444
...
...
@@ -53,7 +53,7 @@ public class EnumClassAttr implements IAttribute {
private
MethodNode
staticMethod
;
public
EnumClassAttr
(
int
fieldsCount
)
{
this
.
fields
=
new
ArrayList
<
Enum
ClassAttr
.
Enum
Field
>(
fieldsCount
);
this
.
fields
=
new
ArrayList
<
EnumField
>(
fieldsCount
);
}
public
List
<
EnumField
>
getFields
()
{
...
...
jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java
View file @
50d31444
...
...
@@ -8,7 +8,7 @@ public class AccessInfo {
private
final
int
accFlags
;
public
static
enum
AFType
{
public
enum
AFType
{
CLASS
,
FIELD
,
METHOD
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/ArithOp.java
View file @
50d31444
...
...
@@ -17,7 +17,7 @@ public enum ArithOp {
private
final
String
symbol
;
private
ArithOp
(
String
symbol
)
{
ArithOp
(
String
symbol
)
{
this
.
symbol
=
symbol
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/IfOp.java
View file @
50d31444
...
...
@@ -12,7 +12,7 @@ public enum IfOp {
private
final
String
symbol
;
private
IfOp
(
String
symbol
)
{
IfOp
(
String
symbol
)
{
this
.
symbol
=
symbol
;
}
...
...
@@ -23,19 +23,19 @@ public enum IfOp {
public
IfOp
invert
()
{
switch
(
this
)
{
case
EQ:
return
IfOp
.
NE
;
return
NE
;
case
NE:
return
IfOp
.
EQ
;
return
EQ
;
case
LT:
return
IfOp
.
GE
;
return
GE
;
case
LE:
return
IfOp
.
GT
;
return
GT
;
case
GT:
return
IfOp
.
LE
;
return
LE
;
case
GE:
return
IfOp
.
LT
;
return
LT
;
default
:
throw
new
JadxRuntimeException
(
"Unknown if operations type: "
+
this
);
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/ArgType.java
View file @
50d31444
...
...
@@ -48,6 +48,10 @@ public abstract class ArgType {
ArgType
.
clsp
=
clsp
;
}
public
static
boolean
isClspSet
()
{
return
ArgType
.
clsp
!=
null
;
}
private
static
ArgType
primitive
(
PrimitiveType
stype
)
{
return
new
PrimitiveArg
(
stype
);
}
...
...
@@ -174,7 +178,7 @@ public abstract class ArgType {
private
final
int
bounds
;
public
WildcardType
(
ArgType
obj
,
int
bound
)
{
super
(
ArgType
.
OBJECT
.
getObject
());
super
(
OBJECT
.
getObject
());
this
.
type
=
obj
;
this
.
bounds
=
bound
;
}
...
...
@@ -214,7 +218,7 @@ public abstract class ArgType {
if
(
bounds
==
0
)
{
return
"?"
;
}
return
"? "
+
(
bounds
==
-
1
?
"super"
:
"extends"
)
+
" "
+
type
.
toString
()
;
return
"? "
+
(
bounds
==
-
1
?
"super"
:
"extends"
)
+
" "
+
type
;
}
}
...
...
@@ -398,7 +402,7 @@ public abstract class ArgType {
}
/**
* @see
jadx.core.dex.instructions.args.ArgType.
WildcardType#getWildcardBounds()
* @see WildcardType#getWildcardBounds()
*/
public
int
getWildcardBounds
()
{
return
0
;
...
...
@@ -513,7 +517,7 @@ public abstract class ArgType {
return
OBJECT
;
}
else
{
ArgType
res
=
merge
(
ea
,
eb
);
return
res
==
null
?
null
:
ArgType
.
array
(
res
);
return
res
==
null
?
null
:
array
(
res
);
}
}
else
if
(
b
.
equals
(
OBJECT
))
{
return
OBJECT
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/MthParameterArg.java
View file @
50d31444
...
...
@@ -2,7 +2,7 @@ package jadx.core.dex.instructions.args;
public
class
MthParameterArg
extends
RegisterArg
{
private
boolean
isThis
=
false
;
private
boolean
isThis
;
public
MthParameterArg
(
int
rn
,
ArgType
type
)
{
super
(
rn
,
type
);
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/PrimitiveType.java
View file @
50d31444
...
...
@@ -16,7 +16,7 @@ public enum PrimitiveType {
private
final
String
shortName
;
private
final
String
longName
;
private
PrimitiveType
(
String
shortName
,
String
longName
)
{
PrimitiveType
(
String
shortName
,
String
longName
)
{
this
.
shortName
=
shortName
;
this
.
longName
=
longName
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/mods/ConstructorInsn.java
View file @
50d31444
...
...
@@ -14,7 +14,7 @@ public class ConstructorInsn extends InsnNode {
private
final
CallType
callType
;
private
final
RegisterArg
instanceArg
;
private
static
enum
CallType
{
private
enum
CallType
{
CONSTRUCTOR
,
// just new instance
SUPER
,
// super call
THIS
,
// call constructor from other constructor
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
View file @
50d31444
...
...
@@ -48,11 +48,13 @@ public class RootNode {
}
private
static
void
initClassPath
(
List
<
ClassNode
>
classes
)
throws
IOException
,
DecodeException
{
ClspGraph
clsp
=
new
ClspGraph
();
clsp
.
load
();
clsp
.
addApp
(
classes
);
if
(!
ArgType
.
isClspSet
())
{
ClspGraph
clsp
=
new
ClspGraph
();
clsp
.
load
();
clsp
.
addApp
(
classes
);
ArgType
.
setClsp
(
clsp
);
ArgType
.
setClsp
(
clsp
);
}
}
private
void
initInnerClasses
(
List
<
ClassNode
>
classes
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/AnnotationsParser.java
View file @
50d31444
...
...
@@ -20,7 +20,7 @@ import com.android.dex.Dex.Section;
public
class
AnnotationsParser
{
private
static
final
Annotation
.
Visibility
[]
VISIBILITIES
=
{
private
static
final
Visibility
[]
VISIBILITIES
=
{
Visibility
.
BUILD
,
Visibility
.
RUNTIME
,
Visibility
.
SYSTEM
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/LocalVar.java
View file @
50d31444
...
...
@@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory;
final
class
LocalVar
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
LocalVar
.
class
);
private
int
regNum
;
private
final
int
regNum
;
private
String
name
;
private
ArgType
type
;
...
...
jadx-core/src/main/java/jadx/core/dex/regions/IfCondition.java
View file @
50d31444
...
...
@@ -20,7 +20,7 @@ import java.util.List;
public
final
class
IfCondition
{
public
static
enum
Mode
{
public
enum
Mode
{
COMPARE
,
NOT
,
AND
,
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
View file @
50d31444
...
...
@@ -7,6 +7,7 @@ import jadx.core.dex.nodes.IContainer;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.IfCondition
;
import
jadx.core.dex.regions.IfCondition.Mode
;
import
jadx.core.dex.regions.IfRegion
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.visitors.AbstractVisitor
;
...
...
@@ -58,7 +59,7 @@ public class IfRegionVisitor extends AbstractVisitor implements IRegionVisitor,
private
static
void
simplifyIfCondition
(
IfRegion
ifRegion
)
{
if
(
ifRegion
.
simplifyCondition
())
{
IfCondition
condition
=
ifRegion
.
getCondition
();
if
(
condition
.
getMode
()
==
IfCondition
.
Mode
.
NOT
)
{
if
(
condition
.
getMode
()
==
Mode
.
NOT
)
{
invertIfRegion
(
ifRegion
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
50d31444
...
...
@@ -403,12 +403,12 @@ public class RegionMaker {
// select 'then', 'else' and 'exit' blocks
if
(
bElse
.
getPredecessors
().
size
()
!=
1
&&
BlockUtils
.
isPathExists
(
bThen
,
bElse
))
{
&&
isPathExists
(
bThen
,
bElse
))
{
thenBlock
=
bThen
;
elseBlock
=
null
;
out
=
bElse
;
}
else
if
(
bThen
.
getPredecessors
().
size
()
!=
1
&&
BlockUtils
.
isPathExists
(
bElse
,
bThen
))
{
&&
isPathExists
(
bElse
,
bThen
))
{
ifnode
.
invertCondition
();
thenBlock
=
ifnode
.
getThenBlock
();
elseBlock
=
null
;
...
...
@@ -511,7 +511,7 @@ public class RegionMaker {
for
(
BlockNode
maybeOut
:
block
.
getSuccessors
())
{
boolean
allReached
=
true
;
for
(
BlockNode
s
:
block
.
getSuccessors
())
{
if
(!
BlockUtils
.
isPathExists
(
s
,
maybeOut
))
{
if
(!
isPathExists
(
s
,
maybeOut
))
{
allReached
=
false
;
break
;
}
...
...
jadx-core/src/test/java/jadx/api/InternalJadxTest.java
View file @
50d31444
...
...
@@ -51,6 +51,11 @@ public abstract class InternalJadxTest extends TestUtils {
}
// don't unload class
checkCode
(
cls
);
return
cls
;
}
private
static
void
checkCode
(
ClassNode
cls
)
{
assertTrue
(
"Inconsistent cls: "
+
cls
,
!
cls
.
contains
(
AFlag
.
INCONSISTENT_CODE
)
&&
!
cls
.
contains
(
AType
.
JADX_ERROR
));
for
(
MethodNode
mthNode
:
cls
.
getMethods
())
{
...
...
@@ -58,7 +63,6 @@ public abstract class InternalJadxTest extends TestUtils {
!
mthNode
.
contains
(
AFlag
.
INCONSISTENT_CODE
)
&&
!
mthNode
.
contains
(
AType
.
JADX_ERROR
));
}
assertThat
(
cls
.
getCode
().
toString
(),
not
(
containsString
(
"inconsistent"
)));
return
cls
;
}
protected
List
<
IDexTreeVisitor
>
getPasses
()
{
...
...
jadx-core/src/test/java/jadx/api/TestUtils.java
View file @
50d31444
...
...
@@ -5,6 +5,9 @@ import jadx.core.codegen.CodeWriter;
public
class
TestUtils
{
public
static
String
indent
(
int
indent
)
{
if
(
indent
==
1
)
{
return
CodeWriter
.
INDENT
;
}
StringBuilder
sb
=
new
StringBuilder
(
indent
*
CodeWriter
.
INDENT
.
length
());
for
(
int
i
=
0
;
i
<
indent
;
i
++)
{
sb
.
append
(
CodeWriter
.
INDENT
);
...
...
jadx-core/src/test/java/jadx/tests/internal/annotations/TestAnnotations.java
View file @
50d31444
...
...
@@ -5,6 +5,7 @@ import jadx.core.dex.nodes.ClassNode;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
...
...
@@ -52,13 +53,14 @@ public class TestAnnotations extends InternalJadxTest {
System
.
out
.
println
(
code
);
assertThat
(
code
,
not
(
containsString
(
"@A(a = 255)"
)));
assertThat
(
code
,
contains
String
(
"@A(a = -1)"
));
assertThat
(
code
,
contains
String
(
"@A(a = -253)"
));
assertThat
(
code
,
contains
String
(
"@A(a = -11253)"
));
assertThat
(
code
,
contains
String
(
"@V(false)"
));
assertThat
(
code
,
contains
One
(
"@A(a = -1)"
));
assertThat
(
code
,
contains
One
(
"@A(a = -253)"
));
assertThat
(
code
,
contains
One
(
"@A(a = -11253)"
));
assertThat
(
code
,
contains
One
(
"@V(false)"
));
assertThat
(
code
,
not
(
containsString
(
"@D()"
)));
assertThat
(
code
,
containsOne
(
"@D"
));
assertThat
(
code
,
contains
String
(
"int a();"
));
assertThat
(
code
,
contains
String
(
"float value() default 1.1f;"
));
assertThat
(
code
,
contains
One
(
"int a();"
));
assertThat
(
code
,
contains
One
(
"float value() default 1.1f;"
));
}
}
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