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
bcfed5b3
Commit
bcfed5b3
authored
Apr 14, 2019
by
Ahmed Ashour
Committed by
skylot
Apr 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: generics constructor types (PR #594)
parent
4cb9f23a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
23 deletions
+34
-23
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+26
-3
AFlag.java
jadx-core/src/main/java/jadx/core/dex/attributes/AFlag.java
+2
-0
TestCastInOverloadedInvoke.java
.../tests/integration/invoke/TestCastInOverloadedInvoke.java
+0
-13
TestVariablesUsageWithLoops.java
...ts/integration/variables/TestVariablesUsageWithLoops.java
+6
-7
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
bcfed5b3
...
...
@@ -569,6 +569,21 @@ public class InsnGen {
}
else
{
code
.
add
(
"new "
);
useClass
(
code
,
insn
.
getClassType
());
ArgType
argType
=
insn
.
getResult
().
getSVar
().
getCodeVar
().
getType
();
if
(
argType
.
isGeneric
())
{
code
.
add
(
'<'
);
if
(
insn
.
contains
(
AFlag
.
EXPLICIT_GENERICS
))
{
boolean
first
=
true
;
for
(
ArgType
type
:
argType
.
getGenericTypes
())
{
if
(!
first
)
{
code
.
add
(
','
);
}
mgen
.
getClassGen
().
useType
(
code
,
type
);
first
=
false
;
}
}
code
.
add
(
'>'
);
}
}
MethodNode
callMth
=
mth
.
dex
().
resolveMethod
(
insn
.
getCallMth
());
generateMethodArguments
(
code
,
insn
,
0
,
callMth
);
...
...
@@ -749,9 +764,17 @@ public class InsnGen {
if
(
argType
.
equals
(
origType
))
{
return
false
;
}
if
(
origType
.
isGeneric
()
&&
origType
.
getObject
().
equals
(
argType
.
getObject
()))
{
return
false
;
if
(
origType
.
isGeneric
())
{
if
(!
argType
.
isGeneric
()
&&
arg
.
isInsnWrap
())
{
((
InsnWrapArg
)
arg
).
getWrapInsn
().
getResult
().
setType
(
ArgType
.
generic
(
argType
.
getObject
(),
origType
.
getGenericTypes
()));
}
if
(
origType
.
getObject
().
equals
(
argType
.
getObject
()))
{
return
false
;
}
if
(
arg
.
isInsnWrap
())
{
((
InsnWrapArg
)
arg
).
getWrapInsn
().
add
(
AFlag
.
EXPLICIT_GENERICS
);
}
}
code
.
add
(
'('
);
useType
(
code
,
origType
);
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/AFlag.java
View file @
bcfed5b3
...
...
@@ -48,5 +48,7 @@ public enum AFlag {
FALL_THROUGH
,
EXPLICIT_GENERICS
,
INCONSISTENT_CODE
,
// warning about incorrect decompilation
}
jadx-core/src/test/java/jadx/tests/integration/invoke/TestCastInOverloadedInvoke.java
View file @
bcfed5b3
...
...
@@ -5,7 +5,6 @@ import java.util.List;
import
org.junit.jupiter.api.Test
;
import
jadx.NotYetImplemented
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
...
...
@@ -55,18 +54,6 @@ public class TestCastInOverloadedInvoke extends IntegrationTest {
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"call(new ArrayList());"
));
assertThat
(
code
,
containsOne
(
"call((List<String>) new ArrayList());"
));
assertThat
(
code
,
containsOne
(
"call((String) obj);"
));
}
@Test
@NotYetImplemented
public
void
testNYI
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"call(new ArrayList<>());"
));
assertThat
(
code
,
containsOne
(
"call((List<String>) new ArrayList<String>());"
));
...
...
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariablesUsageWithLoops.java
View file @
bcfed5b3
...
...
@@ -15,11 +15,10 @@ public class TestVariablesUsageWithLoops extends IntegrationTest {
public
static
class
TestEnhancedFor
{
@SuppressWarnings
(
"rawtypes"
)
public
void
test
()
{
List
list
;
List
<
Object
>
list
;
synchronized
(
this
)
{
list
=
new
ArrayList
();
list
=
new
ArrayList
<>
();
}
for
(
Object
o
:
list
)
{
System
.
out
.
println
(
o
);
...
...
@@ -32,15 +31,15 @@ public class TestVariablesUsageWithLoops extends IntegrationTest {
ClassNode
cls
=
getClassNode
(
TestEnhancedFor
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
" list = new ArrayList"
));
assertThat
(
code
,
containsString
(
" list = new ArrayList
<>
"
));
}
public
static
class
TestForLoop
{
public
void
test
()
{
List
list
;
List
<
Object
>
list
;
synchronized
(
this
)
{
list
=
new
ArrayList
();
list
=
new
ArrayList
<>
();
}
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
System
.
out
.
println
(
i
);
...
...
@@ -53,6 +52,6 @@ public class TestVariablesUsageWithLoops extends IntegrationTest {
ClassNode
cls
=
getClassNode
(
TestForLoop
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
" list = new ArrayList"
));
assertThat
(
code
,
containsString
(
" list = new ArrayList
<>
"
));
}
}
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