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
df115251
Commit
df115251
authored
Jan 10, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: print original value near replaced with field value in switch
parent
02f9c25f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
9 deletions
+14
-9
RegionGen.java
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
+9
-5
ModVisitor.java
...core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
+1
-1
TestSwitchLabels.java
...ava/jadx/tests/integration/switches/TestSwitchLabels.java
+2
-2
TestSwitchWithFallThroughCase.java
...s/integration/switches/TestSwitchWithFallThroughCase.java
+1
-0
TestSwitchWithFallThroughCase2.java
.../integration/switches/TestSwitchWithFallThroughCase2.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
View file @
df115251
...
...
@@ -5,8 +5,6 @@ import jadx.core.dex.attributes.AType;
import
jadx.core.dex.attributes.nodes.DeclareVariablesAttr
;
import
jadx.core.dex.attributes.nodes.ForceReturnAttr
;
import
jadx.core.dex.attributes.nodes.LoopLabelAttr
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.SwitchNode
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.NamedArg
;
...
...
@@ -17,6 +15,7 @@ import jadx.core.dex.nodes.IBlock;
import
jadx.core.dex.nodes.IContainer
;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.parser.FieldValueAttr
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.regions.SwitchRegion
;
import
jadx.core.dex.regions.SynchronizedRegion
;
...
...
@@ -249,11 +248,16 @@ public class RegionGen extends InsnGen {
code
.
add
(
fn
.
getName
());
}
else
{
staticField
(
code
,
fn
.
getFieldInfo
());
// print original value, sometimes replace with incorrect field
FieldValueAttr
valueAttr
=
fn
.
get
(
AType
.
FIELD_VALUE
);
if
(
valueAttr
!=
null
&&
valueAttr
.
getValue
()
!=
null
)
{
code
.
add
(
" /*"
).
add
(
valueAttr
.
getValue
().
toString
()).
add
(
"*/"
);
}
}
}
else
if
(
k
instanceof
IndexInsnNode
)
{
staticField
(
code
,
(
FieldInfo
)
((
IndexInsnNode
)
k
).
getIndex
());
}
else
{
}
else
if
(
k
instanceof
Integer
)
{
code
.
add
(
TypeGen
.
literalToString
((
Integer
)
k
,
arg
.
getType
()));
}
else
{
throw
new
JadxRuntimeException
(
"Unexpected key in switch: "
+
(
k
!=
null
?
k
.
getClass
()
:
k
));
}
code
.
add
(
':'
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
View file @
df115251
...
...
@@ -90,7 +90,7 @@ public class ModVisitor extends AbstractVisitor {
for
(
int
k
=
0
;
k
<
sn
.
getCasesCount
();
k
++)
{
FieldNode
f
=
parentClass
.
getConstField
(
sn
.
getKeys
()[
k
]);
if
(
f
!=
null
)
{
sn
.
getKeys
()[
k
]
=
new
IndexInsnNode
(
InsnType
.
SGET
,
f
.
getFieldInfo
(),
0
)
;
sn
.
getKeys
()[
k
]
=
f
;
}
}
break
;
...
...
jadx-core/src/test/java/jadx/tests/integration/switches/TestSwitchLabels.java
View file @
df115251
...
...
@@ -38,11 +38,11 @@ public class TestSwitchLabels extends IntegrationTest {
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"case CONST_ABC
:
"
));
assertThat
(
code
,
containsString
(
"case CONST_ABC"
));
assertThat
(
code
,
containsString
(
"return CONST_CDE;"
));
cls
.
addInnerClass
(
getClassNode
(
TestCls
.
Inner
.
class
));
assertThat
(
code
,
containsString
(
"case CONST_CDE_PRIVATE
:
"
));
assertThat
(
code
,
containsString
(
"case CONST_CDE_PRIVATE"
));
assertThat
(
code
,
containsString
(
".CONST_ABC;"
));
}
}
jadx-core/src/test/java/jadx/tests/integration/switches/TestSwitchWithFallThroughCase.java
View file @
df115251
...
...
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertThat;
public
class
TestSwitchWithFallThroughCase
extends
IntegrationTest
{
@SuppressWarnings
(
"fallthrough"
)
public
static
class
TestCls
{
public
String
test
(
int
a
,
boolean
b
,
boolean
c
)
{
String
str
=
""
;
...
...
jadx-core/src/test/java/jadx/tests/integration/switches/TestSwitchWithFallThroughCase2.java
View file @
df115251
...
...
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertThat;
public
class
TestSwitchWithFallThroughCase2
extends
IntegrationTest
{
@SuppressWarnings
(
"fallthrough"
)
public
static
class
TestCls
{
public
String
test
(
int
a
,
boolean
b
,
boolean
c
)
{
String
str
=
""
;
...
...
@@ -56,7 +57,6 @@ public class TestSwitchWithFallThroughCase2 extends IntegrationTest {
@Test
public
void
test
()
{
setOutputCFG
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
...
...
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