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
ca448fc4
Commit
ca448fc4
authored
Mar 10, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix variable definitions for 'try' blocks
parent
7a51c0d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
9 deletions
+28
-9
AbstractRegion.java
...e/src/main/java/jadx/core/dex/regions/AbstractRegion.java
+4
-1
ProcessTryCatchRegions.java
...adx/core/dex/visitors/regions/ProcessTryCatchRegions.java
+9
-0
ProcessVariables.java
...java/jadx/core/dex/visitors/regions/ProcessVariables.java
+1
-1
TestVariablesDefinitions.java
...st/java/jadx/tests/internal/TestVariablesDefinitions.java
+14
-7
No files found.
jadx-core/src/main/java/jadx/core/dex/regions/AbstractRegion.java
View file @
ca448fc4
...
...
@@ -5,7 +5,7 @@ import jadx.core.dex.nodes.IRegion;
public
abstract
class
AbstractRegion
extends
AttrNode
implements
IRegion
{
private
final
IRegion
parent
;
private
IRegion
parent
;
public
AbstractRegion
(
IRegion
parent
)
{
this
.
parent
=
parent
;
...
...
@@ -16,4 +16,7 @@ public abstract class AbstractRegion extends AttrNode implements IRegion {
return
parent
;
}
public
void
setParent
(
IRegion
parent
)
{
this
.
parent
=
parent
;
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessTryCatchRegions.java
View file @
ca448fc4
...
...
@@ -5,6 +5,7 @@ import jadx.core.dex.nodes.BlockNode;
import
jadx.core.dex.nodes.IContainer
;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.AbstractRegion
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.trycatch.CatchAttr
;
import
jadx.core.dex.trycatch.ExceptionHandler
;
...
...
@@ -144,6 +145,14 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
region
.
getSubBlocks
().
removeAll
(
newRegion
.
getSubBlocks
());
newRegion
.
getAttributes
().
add
(
tb
.
getCatchAttr
());
// fix parents
for
(
IContainer
cont
:
newRegion
.
getSubBlocks
())
{
if
(
cont
instanceof
AbstractRegion
)
{
AbstractRegion
aReg
=
(
AbstractRegion
)
cont
;
aReg
.
setParent
(
newRegion
);
}
}
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
View file @
ca448fc4
...
...
@@ -60,7 +60,7 @@ public class ProcessVariables extends AbstractVisitor {
@Override
public
String
toString
()
{
return
arg
+
"
"
+
assigns
+
"
"
+
usage
;
return
arg
+
"
, a:"
+
assigns
+
", u:
"
+
usage
;
}
}
...
...
jadx-core/src/test/java/jadx/tests/internal/TestVariablesDefinitions.java
View file @
ca448fc4
...
...
@@ -6,10 +6,16 @@ import jadx.core.dex.visitors.DepthTraverser;
import
jadx.core.dex.visitors.IDexTreeVisitor
;
import
jadx.core.utils.exceptions.DecodeException
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestVariablesDefinitions
extends
InternalJadxTest
{
public
static
class
TestCls
{
...
...
@@ -20,23 +26,24 @@ public class TestVariablesDefinitions extends InternalJadxTest {
public
void
run
()
{
try
{
cls
.
load
();
for
(
IDexTreeVisitor
visitor
:
passes
)
{
DepthTraverser
.
visit
(
visitor
,
cls
);
Iterator
<
IDexTreeVisitor
>
iterator
=
passes
.
iterator
();
while
(
iterator
.
hasNext
())
{
DepthTraverser
.
visit
(
iterator
.
next
(),
cls
);
}
}
catch
(
DecodeException
e
)
{
LOG
.
error
(
"Decode exception: "
+
cls
,
e
);
}
finally
{
cls
.
unload
();
}
}
}
//
@Test
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
// 'iterator' variable must be declared inside 'try' block
assertThat
(
code
,
containsString
(
makeIndent
(
3
)
+
"Iterator<IDexTreeVisitor> iterator = "
));
assertThat
(
code
,
not
(
containsString
(
"iterator;"
)));
}
}
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