Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
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
b32dc17d
Commit
b32dc17d
authored
Jul 20, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: don't change AST before checks in ternary transform (#710)
parent
7c53b985
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
5 deletions
+47
-5
TernaryMod.java
.../main/java/jadx/core/dex/visitors/regions/TernaryMod.java
+4
-4
DebugUtils.java
jadx-core/src/main/java/jadx/core/utils/DebugUtils.java
+2
-1
TestTryWithEmptyCatch.java
...adx/tests/integration/trycatch/TestTryWithEmptyCatch.java
+41
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/TernaryMod.java
View file @
b32dc17d
...
...
@@ -253,10 +253,6 @@ public class TernaryMod implements IRegionIterativeVisitor {
}
private
static
void
replaceWithTernary
(
MethodNode
mth
,
IfRegion
ifRegion
,
BlockNode
block
,
InsnNode
insn
)
{
BlockNode
header
=
ifRegion
.
getConditionBlocks
().
get
(
0
);
if
(!
ifRegion
.
getParent
().
replaceSubBlock
(
ifRegion
,
header
))
{
return
;
}
RegisterArg
resArg
=
insn
.
getResult
();
if
(
resArg
.
getSVar
().
getUseList
().
size
()
!=
1
)
{
return
;
...
...
@@ -277,6 +273,10 @@ public class TernaryMod implements IRegionIterativeVisitor {
}
// all checks passed
BlockNode
header
=
ifRegion
.
getConditionBlocks
().
get
(
0
);
if
(!
ifRegion
.
getParent
().
replaceSubBlock
(
ifRegion
,
header
))
{
return
;
}
InsnList
.
remove
(
block
,
insn
);
TernaryInsn
ternInsn
=
new
TernaryInsn
(
ifRegion
.
getCondition
(),
phiInsn
.
getResult
(),
InsnArg
.
wrapInsnIntoArg
(
insn
),
otherArg
);
...
...
jadx-core/src/main/java/jadx/core/utils/DebugUtils.java
View file @
b32dc17d
...
...
@@ -119,7 +119,8 @@ public class DebugUtils {
CodeWriter
code
=
new
CodeWriter
();
ig
.
makeInsn
(
insn
,
code
);
String
insnStr
=
code
.
toString
().
substring
(
CodeWriter
.
NL
.
length
());
LOG
.
debug
(
"{}|> {}\t{}"
,
indent
,
insnStr
,
insn
.
getAttributesString
());
String
attrStr
=
insn
.
isAttrStorageEmpty
()
?
""
:
'\t'
+
insn
.
getAttributesString
();
LOG
.
debug
(
"{}|> {}{}"
,
indent
,
insnStr
,
attrStr
);
}
catch
(
CodegenException
e
)
{
LOG
.
debug
(
"{}|>!! {}"
,
indent
,
insn
);
}
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithEmptyCatch.java
0 → 100644
View file @
b32dc17d
package
jadx
.
tests
.
integration
.
trycatch
;
import
java.util.Properties
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
public
class
TestTryWithEmptyCatch
extends
IntegrationTest
{
public
static
class
TestCls
extends
Exception
{
private
static
final
long
serialVersionUID
=
-
5723049816464070603L
;
private
Properties
field
;
public
TestCls
(
String
str
)
{
super
(
str
);
Properties
properties
=
null
;
try
{
if
(
str
.
contains
(
"properties"
))
{
properties
=
new
Properties
();
}
}
catch
(
Exception
unused
)
{
// empty
}
this
.
field
=
properties
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"try {"
));
assertThat
(
code
,
containsOne
(
"if ("
));
}
}
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