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
2478fc3a
Commit
2478fc3a
authored
Sep 02, 2014
by
Anton Dyachenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix instance initializer producing (don't generate super() call)
parent
5a68d3be
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
4 deletions
+136
-4
ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+1
-4
MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+25
-0
ModVisitor.java
...core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
+6
-0
TestInitializers.java
...-samples/src/main/java/jadx/samples/TestInitializers.java
+104
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
View file @
2478fc3a
...
...
@@ -377,10 +377,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
public
MethodNode
getDefaultConstructor
()
{
for
(
MethodNode
mth
:
methods
)
{
if
(
mth
.
getAccessFlags
().
isConstructor
()
&&
mth
.
getMethodInfo
().
isConstructor
()
&&
(
mth
.
getMethodInfo
().
getArgsCount
()
==
0
||
(
mth
.
getArguments
(
false
)
!=
null
&&
mth
.
getArguments
(
false
).
isEmpty
())))
{
if
(
mth
.
isDefaultConstructor
())
{
return
mth
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
View file @
2478fc3a
...
...
@@ -461,6 +461,31 @@ public class MethodNode extends LineAttrNode implements ILoadable {
}
return
false
;
}
public
boolean
isDefaultConstructor
()
{
boolean
result
=
false
;
if
(
accFlags
.
isConstructor
()
&&
mthInfo
.
isConstructor
())
{
int
defaultArgCount
=
0
;
/** workaround for non-static inner class constructor, that has
* synthetic argument */
if
((
parentClass
!=
null
)
&&
parentClass
.
getClassInfo
().
isInner
())
{
if
(!
parentClass
.
getAccessFlags
().
isStatic
())
{
ClassNode
outerCls
=
parentClass
.
getParentClass
();
if
((
argsList
!=
null
)
&&
(
argsList
.
size
()
>=
1
))
{
if
(
argsList
.
get
(
0
).
getType
().
equals
(
outerCls
.
getClassInfo
().
getType
()))
{
defaultArgCount
=
1
;
}
}
}
}
result
=
(
argsList
==
null
)
||
(
argsList
.
size
()
==
defaultArgCount
);
}
return
result
;
}
public
int
getRegsCount
()
{
return
regsCount
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
View file @
2478fc3a
...
...
@@ -76,6 +76,12 @@ public class ModVisitor extends AbstractVisitor {
remove
=
true
;
}
}
// remove super() call in instance initializer
if
(
parentClass
.
isAnonymous
()
&&
mth
.
isDefaultConstructor
()
&&
co
.
isSuper
())
{
remove
=
true
;
}
if
(
remove
)
{
remover
.
add
(
insn
);
}
else
{
...
...
jadx-samples/src/main/java/jadx/samples/TestInitializers.java
0 → 100644
View file @
2478fc3a
package
jadx
.
samples
;
public
class
TestInitializers
extends
AbstractTest
{
private
static
String
a
;
private
static
int
counter
;
private
A
c_a
;
public
static
class
A
{
public
static
String
a
;
static
{
a
=
"a1"
;
}
public
boolean
z
()
{
return
true
;
}
}
public
class
B
{
private
int
b
;
private
int
bbb
;
public
B
()
{
if
(
c_a
.
z
())
{
b
=
-
1
;
}
else
{
b
=
1
;
}
}
public
B
(
int
_b
)
{
b
=
_b
;
}
public
void
setB
(
int
_b
)
{
b
=
_b
;
}
public
int
getB
()
{
return
b
;
}
public
int
getBBB
()
{
return
bbb
;
}
{
bbb
=
123
;
}
}
static
{
a
=
"a0"
;
counter
=
0
;
}
{
c_a
=
new
A
();
}
@Override
public
boolean
testRun
()
throws
Exception
{
assertTrue
(
counter
==
0
);
assertTrue
(
a
.
equals
(
"a0"
));
assertTrue
(
A
.
a
.
equals
(
"a1"
));
B
b1
=
new
B
()
{
{
TestInitializers
.
counter
++;
setB
(
TestInitializers
.
counter
);
}
};
assertTrue
(
b1
.
getB
()
==
1
);
B
b2
=
new
B
()
{
@SuppressWarnings
(
"unused"
)
private
int
bb
;
public
int
getB
()
{
return
super
.
getB
();
}
{
bb
=
100
;
}
};
assertTrue
(
b2
.
getB
()
==
-
1
);
assertTrue
((
new
B
()).
getB
()
==
-
1
);
assertTrue
(
counter
==
1
);
B
b3
=
new
B
(
3
);
assertTrue
((
b3
.
getB
()
==
3
)
&&
(
b3
.
getBBB
()
==
123
));
return
true
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
TestInitializers
().
testRun
();
}
}
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