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
380b73d1
Commit
380b73d1
authored
Nov 08, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: sort methods by source line number
parent
ef85e29a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+16
-1
Utils.java
jadx-core/src/main/java/jadx/core/utils/Utils.java
+4
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
View file @
380b73d1
...
@@ -24,6 +24,7 @@ import jadx.core.utils.exceptions.CodegenException;
...
@@ -24,6 +24,7 @@ import jadx.core.utils.exceptions.CodegenException;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
...
@@ -39,6 +40,13 @@ import com.android.dx.rop.code.AccessFlags;
...
@@ -39,6 +40,13 @@ import com.android.dx.rop.code.AccessFlags;
public
class
ClassGen
{
public
class
ClassGen
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ClassGen
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ClassGen
.
class
);
public
static
final
Comparator
<
MethodNode
>
METHOD_LINE_COMPARATOR
=
new
Comparator
<
MethodNode
>()
{
@Override
public
int
compare
(
MethodNode
a
,
MethodNode
b
)
{
return
Utils
.
compare
(
a
.
getSourceLine
(),
b
.
getSourceLine
());
}
};
private
final
ClassNode
cls
;
private
final
ClassNode
cls
;
private
final
ClassGen
parentGen
;
private
final
ClassGen
parentGen
;
private
final
AnnotationGen
annotationGen
;
private
final
AnnotationGen
annotationGen
;
...
@@ -239,7 +247,8 @@ public class ClassGen {
...
@@ -239,7 +247,8 @@ public class ClassGen {
}
}
private
void
addMethods
(
CodeWriter
code
)
{
private
void
addMethods
(
CodeWriter
code
)
{
for
(
MethodNode
mth
:
cls
.
getMethods
())
{
List
<
MethodNode
>
methods
=
sortMethodsByLine
(
cls
.
getMethods
());
for
(
MethodNode
mth
:
methods
)
{
if
(
mth
.
contains
(
AFlag
.
DONT_GENERATE
))
{
if
(
mth
.
contains
(
AFlag
.
DONT_GENERATE
))
{
continue
;
continue
;
}
}
...
@@ -255,6 +264,12 @@ public class ClassGen {
...
@@ -255,6 +264,12 @@ public class ClassGen {
}
}
}
}
private
static
List
<
MethodNode
>
sortMethodsByLine
(
List
<
MethodNode
>
methods
)
{
List
<
MethodNode
>
out
=
new
ArrayList
<
MethodNode
>(
methods
);
Collections
.
sort
(
out
,
METHOD_LINE_COMPARATOR
);
return
out
;
}
private
boolean
isMethodsPresents
()
{
private
boolean
isMethodsPresents
()
{
for
(
MethodNode
mth
:
cls
.
getMethods
())
{
for
(
MethodNode
mth
:
cls
.
getMethods
())
{
if
(!
mth
.
contains
(
AFlag
.
DONT_GENERATE
))
{
if
(!
mth
.
contains
(
AFlag
.
DONT_GENERATE
))
{
...
...
jadx-core/src/main/java/jadx/core/utils/Utils.java
View file @
380b73d1
...
@@ -90,4 +90,8 @@ public class Utils {
...
@@ -90,4 +90,8 @@ public class Utils {
throwable
.
printStackTrace
(
pw
);
throwable
.
printStackTrace
(
pw
);
return
sw
.
getBuffer
().
toString
();
return
sw
.
getBuffer
().
toString
();
}
}
public
static
int
compare
(
int
x
,
int
y
)
{
return
(
x
<
y
)
?
-
1
:
((
x
==
y
)
?
0
:
1
);
}
}
}
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