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
a324376e
Commit
a324376e
authored
Jun 27, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: replace assertions with jadx exceptions throw
parent
04e50afa
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
17 deletions
+28
-17
Jadx.java
jadx-core/src/main/java/jadx/core/Jadx.java
+1
-5
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+12
-6
ArithNode.java
...e/src/main/java/jadx/core/dex/instructions/ArithNode.java
+0
-1
InsnWrapArg.java
...ain/java/jadx/core/dex/instructions/args/InsnWrapArg.java
+4
-1
DebugInfoParser.java
...main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
+7
-3
IfRegion.java
.../main/java/jadx/core/dex/regions/conditions/IfRegion.java
+4
-1
No files found.
jadx-core/src/main/java/jadx/core/Jadx.java
View file @
a324376e
...
...
@@ -31,7 +31,6 @@ import jadx.core.dex.visitors.ssa.EliminatePhiNodes;
import
jadx.core.dex.visitors.ssa.SSATransform
;
import
jadx.core.dex.visitors.typeinference.FinishTypeInference
;
import
jadx.core.dex.visitors.typeinference.TypeInference
;
import
jadx.core.utils.Utils
;
import
java.io.File
;
import
java.net.URL
;
...
...
@@ -50,9 +49,6 @@ public class Jadx {
if
(
Consts
.
DEBUG
)
{
LOG
.
info
(
"debug enabled"
);
}
if
(
Jadx
.
class
.
desiredAssertionStatus
())
{
LOG
.
info
(
"assertions enabled"
);
}
}
public
static
List
<
IDexTreeVisitor
>
getPassesList
(
IJadxArgs
args
,
File
outDir
)
{
...
...
@@ -115,7 +111,7 @@ public class Jadx {
public
static
String
getVersion
()
{
try
{
ClassLoader
classLoader
=
Utils
.
class
.
getClassLoader
();
ClassLoader
classLoader
=
Jadx
.
class
.
getClassLoader
();
if
(
classLoader
!=
null
)
{
Enumeration
<
URL
>
resources
=
classLoader
.
getResources
(
"META-INF/MANIFEST.MF"
);
while
(
resources
.
hasMoreElements
())
{
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
a324376e
...
...
@@ -450,7 +450,7 @@ public class InsnGen {
/* fallback mode instructions */
case
IF:
assert
isFallback
()
:
"if insn in not fallback mode"
;
fallbackOnlyInsn
(
insn
)
;
IfNode
ifInsn
=
(
IfNode
)
insn
;
code
.
add
(
"if ("
);
addArg
(
code
,
insn
.
getArg
(
0
));
...
...
@@ -461,17 +461,17 @@ public class InsnGen {
break
;
case
GOTO:
assert
isFallback
(
);
fallbackOnlyInsn
(
insn
);
code
.
add
(
"goto "
).
add
(
MethodGen
.
getLabelName
(((
GotoNode
)
insn
).
getTarget
()));
break
;
case
MOVE_EXCEPTION:
assert
isFallback
(
);
fallbackOnlyInsn
(
insn
);
code
.
add
(
"move-exception"
);
break
;
case
SWITCH:
assert
isFallback
(
);
fallbackOnlyInsn
(
insn
);
SwitchNode
sw
=
(
SwitchNode
)
insn
;
code
.
add
(
"switch("
);
addArg
(
code
,
insn
.
getArg
(
0
));
...
...
@@ -489,7 +489,7 @@ public class InsnGen {
break
;
case
FILL_ARRAY:
assert
isFallback
(
);
fallbackOnlyInsn
(
insn
);
FillArrayNode
arrayNode
=
(
FillArrayNode
)
insn
;
Object
data
=
arrayNode
.
getData
();
String
arrStr
;
...
...
@@ -509,7 +509,7 @@ public class InsnGen {
case
NEW_INSTANCE:
// only fallback - make new instance in constructor invoke
assert
isFallback
(
);
fallbackOnlyInsn
(
insn
);
code
.
add
(
"new "
+
insn
.
getResult
().
getType
());
break
;
...
...
@@ -518,6 +518,12 @@ public class InsnGen {
}
}
private
void
fallbackOnlyInsn
(
InsnNode
insn
)
throws
CodegenException
{
if
(!
fallback
)
{
throw
new
CodegenException
(
insn
.
getType
()
+
" can be used only in fallback mode"
);
}
}
private
void
filledNewArray
(
FilledNewArrayNode
insn
,
CodeWriter
code
)
throws
CodegenException
{
code
.
add
(
"new "
);
useType
(
code
,
insn
.
getArrayType
());
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/ArithNode.java
View file @
a324376e
...
...
@@ -40,7 +40,6 @@ public class ArithNode extends InsnNode {
addReg
(
insn
,
2
,
type
);
}
}
assert
getArgsCount
()
==
2
;
}
public
ArithNode
(
ArithOp
op
,
RegisterArg
res
,
InsnArg
a
,
InsnArg
b
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/InsnWrapArg.java
View file @
a324376e
package
jadx
.
core
.
dex
.
instructions
.
args
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
org.jetbrains.annotations.NotNull
;
...
...
@@ -20,7 +21,9 @@ public final class InsnWrapArg extends InsnArg {
@Override
public
void
setParentInsn
(
InsnNode
parentInsn
)
{
assert
parentInsn
!=
wrappedInsn
:
"Can't wrap instruction info itself: "
+
parentInsn
;
if
(
parentInsn
==
wrappedInsn
)
{
throw
new
JadxRuntimeException
(
"Can't wrap instruction info itself: "
+
parentInsn
);
}
this
.
parentInsn
=
parentInsn
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
View file @
a324376e
...
...
@@ -11,10 +11,14 @@ import jadx.core.utils.exceptions.DecodeException;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.android.dex.Dex.Section
;
public
class
DebugInfoParser
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DebugInfoParser
.
class
);
private
static
final
int
DBG_END_SEQUENCE
=
0x00
;
private
static
final
int
DBG_ADVANCE_PC
=
0x01
;
private
static
final
int
DBG_ADVANCE_LINE
=
0x02
;
...
...
@@ -58,15 +62,15 @@ public class DebugInfoParser {
int
paramsCount
=
section
.
readUleb128
();
List
<
RegisterArg
>
mthArgs
=
mth
.
getArguments
(
false
);
assert
paramsCount
==
mthArgs
.
size
();
for
(
int
i
=
0
;
i
<
paramsCount
;
i
++)
{
int
id
=
section
.
readUleb128
()
-
1
;
if
(
id
!=
DexNode
.
NO_INDEX
)
{
String
name
=
dex
.
getString
(
id
);
if
(
i
<
mthArgs
.
size
())
{
mthArgs
.
get
(
i
).
setName
(
name
);
}
}
}
for
(
RegisterArg
arg
:
mthArgs
)
{
int
rn
=
arg
.
getRegNum
();
...
...
jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfRegion.java
View file @
a324376e
...
...
@@ -5,6 +5,7 @@ import jadx.core.dex.nodes.IBranchRegion;
import
jadx.core.dex.nodes.IContainer
;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.regions.AbstractRegion
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -20,7 +21,9 @@ public final class IfRegion extends AbstractRegion implements IBranchRegion {
public
IfRegion
(
IRegion
parent
,
BlockNode
header
)
{
super
(
parent
);
assert
header
.
getInstructions
().
size
()
==
1
;
if
(
header
.
getInstructions
().
size
()
!=
1
)
{
throw
new
JadxRuntimeException
(
"Expected only one instruction in 'if' header"
);
}
this
.
header
=
header
;
this
.
condition
=
IfCondition
.
fromIfBlock
(
header
);
}
...
...
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