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
f9e7a29c
Commit
f9e7a29c
authored
Aug 16, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix sythetic constructor replacement (#334)
parent
6cb14a1c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
32 deletions
+77
-32
ModVisitor.java
...core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
+2
-2
BaseExternalTest.java
...e/src/test/java/jadx/tests/external/BaseExternalTest.java
+40
-30
TestOuterConstructorCall.java
...adx/tests/integration/inner/TestOuterConstructorCall.java
+35
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
View file @
f9e7a29c
...
@@ -396,14 +396,14 @@ public class ModVisitor extends AbstractVisitor {
...
@@ -396,14 +396,14 @@ public class ModVisitor extends AbstractVisitor {
return
filledArr
;
return
filledArr
;
}
}
private
static
boolean
allArgsNull
(
InsnNode
insn
)
{
private
static
boolean
allArgsNull
(
ConstructorInsn
insn
)
{
for
(
InsnArg
insnArg
:
insn
.
getArguments
())
{
for
(
InsnArg
insnArg
:
insn
.
getArguments
())
{
if
(
insnArg
.
isLiteral
())
{
if
(
insnArg
.
isLiteral
())
{
LiteralArg
lit
=
(
LiteralArg
)
insnArg
;
LiteralArg
lit
=
(
LiteralArg
)
insnArg
;
if
(
lit
.
getLiteral
()
!=
0
)
{
if
(
lit
.
getLiteral
()
!=
0
)
{
return
false
;
return
false
;
}
}
}
else
if
(!
insnArg
.
isThis
())
{
}
else
{
return
false
;
return
false
;
}
}
}
}
...
...
jadx-core/src/test/java/jadx/tests/external/BaseExternalTest.java
View file @
f9e7a29c
...
@@ -25,6 +25,7 @@ import jadx.core.dex.visitors.IDexTreeVisitor;
...
@@ -25,6 +25,7 @@ import jadx.core.dex.visitors.IDexTreeVisitor;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.IntegrationTest
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
...
@@ -58,7 +59,7 @@ public abstract class BaseExternalTest extends IntegrationTest {
...
@@ -58,7 +59,7 @@ public abstract class BaseExternalTest extends IntegrationTest {
}
else
{
}
else
{
Pattern
clsPtrn
=
Pattern
.
compile
(
clsPatternStr
);
Pattern
clsPtrn
=
Pattern
.
compile
(
clsPatternStr
);
Pattern
mthPtrn
=
mthPatternStr
==
null
?
null
:
Pattern
.
compile
(
mthPatternStr
);
Pattern
mthPtrn
=
mthPatternStr
==
null
?
null
:
Pattern
.
compile
(
mthPatternStr
);
process
Mth
ByPatterns
(
jadx
,
clsPtrn
,
mthPtrn
);
processByPatterns
(
jadx
,
clsPtrn
,
mthPtrn
);
}
}
printErrorReport
(
jadx
);
printErrorReport
(
jadx
);
}
}
...
@@ -69,12 +70,22 @@ public abstract class BaseExternalTest extends IntegrationTest {
...
@@ -69,12 +70,22 @@ public abstract class BaseExternalTest extends IntegrationTest {
}
}
}
}
private
void
process
Mth
ByPatterns
(
JadxDecompiler
jadx
,
Pattern
clsPattern
,
@Nullable
Pattern
mthPattern
)
{
private
void
processByPatterns
(
JadxDecompiler
jadx
,
Pattern
clsPattern
,
@Nullable
Pattern
mthPattern
)
{
List
<
IDexTreeVisitor
>
passes
=
Jadx
.
getPassesList
(
jadx
.
getArgs
());
List
<
IDexTreeVisitor
>
passes
=
Jadx
.
getPassesList
(
jadx
.
getArgs
());
RootNode
root
=
JadxInternalAccess
.
getRoot
(
jadx
);
RootNode
root
=
JadxInternalAccess
.
getRoot
(
jadx
);
int
processed
=
0
;
for
(
ClassNode
classNode
:
root
.
getClasses
(
true
))
{
for
(
ClassNode
classNode
:
root
.
getClasses
(
true
))
{
String
clsFullName
=
classNode
.
getClassInfo
().
getFullName
();
String
clsFullName
=
classNode
.
getClassInfo
().
getFullName
();
if
(
clsPattern
.
matcher
(
clsFullName
).
matches
())
{
if
(
clsPattern
.
matcher
(
clsFullName
).
matches
())
{
if
(
processCls
(
mthPattern
,
passes
,
classNode
))
{
processed
++;
}
}
}
assertThat
(
"No classes processed"
,
processed
,
greaterThan
(
0
));
}
private
boolean
processCls
(
@Nullable
Pattern
mthPattern
,
List
<
IDexTreeVisitor
>
passes
,
ClassNode
classNode
)
{
classNode
.
load
();
classNode
.
load
();
boolean
decompile
=
false
;
boolean
decompile
=
false
;
if
(
mthPattern
==
null
)
{
if
(
mthPattern
==
null
)
{
...
@@ -87,7 +98,9 @@ public abstract class BaseExternalTest extends IntegrationTest {
...
@@ -87,7 +98,9 @@ public abstract class BaseExternalTest extends IntegrationTest {
}
}
}
}
}
}
if
(
decompile
)
{
if
(!
decompile
)
{
return
false
;
}
for
(
IDexTreeVisitor
visitor
:
passes
)
{
for
(
IDexTreeVisitor
visitor
:
passes
)
{
DepthTraversal
.
visit
(
visitor
,
classNode
);
DepthTraversal
.
visit
(
visitor
,
classNode
);
}
}
...
@@ -103,10 +116,7 @@ public abstract class BaseExternalTest extends IntegrationTest {
...
@@ -103,10 +116,7 @@ public abstract class BaseExternalTest extends IntegrationTest {
LOG
.
info
(
"Code: \n{}"
,
classNode
.
getCode
());
LOG
.
info
(
"Code: \n{}"
,
classNode
.
getCode
());
}
}
checkCode
(
classNode
);
checkCode
(
classNode
);
// SaveCode.save(jadx.getArgs().getOutDirSrc(), jadx.getArgs(), classNode);
return
true
;
}
}
}
}
}
private
void
printMethods
(
ClassNode
classNode
,
@NotNull
Pattern
mthPattern
)
{
private
void
printMethods
(
ClassNode
classNode
,
@NotNull
Pattern
mthPattern
)
{
...
...
jadx-core/src/test/java/jadx/tests/integration/inner/TestOuterConstructorCall.java
0 → 100644
View file @
f9e7a29c
package
jadx
.
tests
.
integration
.
inner
;
import
org.junit.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestOuterConstructorCall
extends
IntegrationTest
{
public
static
class
TestCls
{
private
TestCls
(
Inner
inner
)
{
System
.
out
.
println
(
inner
);
}
private
class
Inner
{
private
TestCls
test
()
{
return
new
TestCls
(
this
);
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"private class Inner {"
));
assertThat
(
code
,
containsString
(
"return new TestOuterConstructorCall$TestCls(this);"
));
assertThat
(
code
,
not
(
containsString
(
"synthetic"
)));
}
}
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