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
9f51cabf
Commit
9f51cabf
authored
Dec 20, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix anonymous class codegen
parent
1c60e5e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+4
-4
ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+5
-3
TestInner.java
jadx-samples/src/main/java/jadx/samples/TestInner.java
+16
-1
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
9f51cabf
...
...
@@ -524,10 +524,10 @@ public class InsnGen {
if
(
cls
!=
null
&&
cls
.
isAnonymous
())
{
// anonymous class construction
ClassInfo
parent
;
if
(
cls
.
getSuperClass
()
!=
null
&&
!
cls
.
getSuperClass
().
isObject
())
{
parent
=
cls
.
getSuperClass
();
}
else
{
if
(
cls
.
getInterfaces
().
size
()
==
1
)
{
parent
=
cls
.
getInterfaces
().
get
(
0
);
}
else
{
parent
=
cls
.
getSuperClass
();
}
MethodNode
defCtr
=
cls
.
getDefaultConstructor
();
if
(
RegionUtils
.
notEmpty
(
defCtr
.
getRegion
()))
{
...
...
@@ -535,7 +535,7 @@ public class InsnGen {
}
else
{
defCtr
.
getAttributes
().
add
(
AttributeFlag
.
DONT_GENERATE
);
}
code
.
add
(
"new "
).
add
(
useClass
(
parent
)).
add
(
"() "
);
code
.
add
(
"new "
).
add
(
parent
==
null
?
"Object"
:
useClass
(
parent
)).
add
(
"() "
);
code
.
incIndent
(
2
);
new
ClassGen
(
cls
,
mgen
.
getClassGen
().
getParentGen
(),
fallback
).
makeClassBody
(
code
);
code
.
decIndent
(
2
);
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
View file @
9f51cabf
...
...
@@ -338,15 +338,17 @@ public class ClassNode extends LineAttrNode implements ILoadable {
}
public
boolean
isAnonymous
()
{
MethodNode
defConstrExists
=
getDefaultConstructor
();
return
defConstrExists
!=
null
&&
getShortName
().
startsWith
(
Consts
.
ANONYMOUS_CLASS_PREFIX
);
return
clsInfo
.
isInner
()
&&
getShortName
().
startsWith
(
Consts
.
ANONYMOUS_CLASS_PREFIX
)
&&
getDefaultConstructor
()
!=
null
;
}
public
MethodNode
getDefaultConstructor
()
{
for
(
MethodNode
mth
:
methods
)
{
if
(
mth
.
getAccessFlags
().
isConstructor
()
&&
mth
.
getMethodInfo
().
isConstructor
()
&&
mth
.
getArguments
(
false
).
isEmpty
())
{
&&
(
mth
.
getMethodInfo
().
getArgsCount
()
==
0
||
(
mth
.
getArguments
(
false
)
!=
null
&&
mth
.
getArguments
(
false
).
isEmpty
())))
{
return
mth
;
}
}
...
...
jadx-samples/src/main/java/jadx/samples/TestInner.java
View file @
9f51cabf
...
...
@@ -63,6 +63,19 @@ public class TestInner extends AbstractTest {
}.
run
();
}
public
String
func3
()
{
return
new
Object
()
{
{
count
+=
7
;
}
@Override
public
String
toString
()
{
count
+=
8
;
return
Integer
.
toString
(
count
);
}
}.
toString
();
}
@SuppressWarnings
(
"serial"
)
public
static
class
MyException
extends
Exception
{
public
MyException
(
String
str
,
Exception
e
)
{
...
...
@@ -94,6 +107,8 @@ public class TestInner extends AbstractTest {
thread
.
join
();
thread2
.
join
();
return
TestInner
.
count
==
26
;
assertEquals
(
func3
(),
"41"
);
return
TestInner
.
count
==
41
;
}
}
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