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
2063fd07
Commit
2063fd07
authored
Sep 02, 2014
by
skylot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17 from NeoSpb/fix2
Fix2 by NeoSpb
parents
5a68d3be
128fe8a8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
232 additions
and
6 deletions
+232
-6
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+10
-2
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
TestInner3.java
jadx-samples/src/main/java/jadx/samples/TestInner3.java
+86
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
2063fd07
...
...
@@ -129,8 +129,16 @@ public class InsnGen {
}
private
void
instanceField
(
CodeWriter
code
,
FieldInfo
field
,
InsnArg
arg
)
throws
CodegenException
{
FieldNode
fieldNode
=
mth
.
getParentClass
().
searchField
(
field
);
if
(
fieldNode
!=
null
)
{
ClassNode
pCls
=
mth
.
getParentClass
();
FieldNode
fieldNode
=
pCls
.
searchField
(
field
);
while
((
fieldNode
==
null
)
&&
(
pCls
.
getParentClass
()
!=
pCls
)
&&
(
pCls
.
getParentClass
()
!=
null
))
{
pCls
=
pCls
.
getParentClass
();
fieldNode
=
pCls
.
searchField
(
field
);
}
if
(
fieldNode
!=
null
)
{
FieldReplaceAttr
replace
=
fieldNode
.
get
(
AType
.
FIELD_REPLACE
);
if
(
replace
!=
null
)
{
FieldInfo
info
=
replace
.
getFieldInfo
();
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
View file @
2063fd07
...
...
@@ -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 @
2063fd07
...
...
@@ -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 @
2063fd07
...
...
@@ -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 @
2063fd07
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
();
}
}
jadx-samples/src/main/java/jadx/samples/TestInner3.java
0 → 100644
View file @
2063fd07
package
jadx
.
samples
;
public
class
TestInner3
extends
AbstractTest
{
private
String
i0
;
public
class
A
{
protected
String
a
;
public
A
()
{
a
=
""
;
}
public
String
a
()
{
return
""
;
}
}
public
class
I0
{
private
String
i0
;
private
String
i1
;
public
class
I1
{
private
String
i0
;
private
String
i1
;
private
String
i2
;
public
I1
()
{
TestInner3
.
this
.
i0
=
"i0"
;
I0
.
this
.
i0
=
"i1"
;
I0
.
this
.
i1
=
"i2"
;
i0
=
"i0"
;
i1
=
"i1"
;
i2
=
"i2"
;
}
public
String
i
()
{
String
result
=
TestInner3
.
this
.
i0
+
I0
.
this
.
i0
+
I0
.
this
.
i1
+
i0
+
i1
+
i2
;
A
a
=
new
A
()
{
public
String
a
()
{
TestInner3
.
this
.
i0
=
"i1"
;
I0
.
this
.
i0
=
"i2"
;
I0
.
this
.
i1
=
"i3"
;
I1
.
this
.
i0
=
"i1"
;
I1
.
this
.
i1
=
"i2"
;
I1
.
this
.
i2
=
"i3"
;
a
=
"a"
;
return
TestInner3
.
this
.
i0
+
I0
.
this
.
i0
+
I0
.
this
.
i1
+
I1
.
this
.
i0
+
I1
.
this
.
i1
+
I1
.
this
.
i2
+
a
;
}
};
return
result
+
a
.
a
();
}
}
public
I0
()
{
TestInner3
.
this
.
i0
=
"i-"
;
i0
=
"i0"
;
i1
=
"i1"
;
}
public
String
i
()
{
String
result
=
TestInner3
.
this
.
i0
+
i0
+
i1
;
return
result
+
(
new
I1
()).
i
();
}
}
@Override
public
boolean
testRun
()
throws
Exception
{
assertTrue
((
new
I0
()).
i
().
equals
(
"i-i0i1i0i1i2i0i1i2i1i2i3i1i2i3a"
));
assertTrue
(
i0
.
equals
(
"i1"
));
return
true
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
TestInner2
().
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