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
995cf2ad
Commit
995cf2ad
authored
Dec 05, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: use types with generics for overloaded method casts (#402)
parent
b9fffa14
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+1
-1
TestCastInOverloadedInvoke.java
.../tests/integration/invoke/TestCastInOverloadedInvoke.java
+54
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
995cf2ad
...
...
@@ -694,7 +694,7 @@ public class InsnGen {
* Add additional cast for overloaded method argument.
*/
private
boolean
processOverloadedArg
(
CodeWriter
code
,
MethodNode
callMth
,
InsnArg
arg
,
int
origPos
)
{
ArgType
origType
=
callMth
.
get
MethodInfo
().
getArgumentsTypes
().
get
(
origPos
);
ArgType
origType
=
callMth
.
get
Arguments
(
false
).
get
(
origPos
).
getInitType
(
);
if
(!
arg
.
getType
().
equals
(
origType
))
{
code
.
add
(
'('
);
useType
(
code
,
origType
);
...
...
jadx-core/src/test/java/jadx/tests/integration/invoke/TestCastInOverloadedInvoke.java
0 → 100644
View file @
995cf2ad
package
jadx
.
tests
.
integration
.
invoke
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.junit.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestCastInOverloadedInvoke
extends
IntegrationTest
{
public
static
class
TestCls
{
public
void
test
()
{
call
(
new
ArrayList
<>());
call
((
List
<
String
>)
new
ArrayList
<
String
>());
}
public
void
test2
(
Object
obj
)
{
if
(
obj
instanceof
String
)
{
call
((
String
)
obj
);
}
}
public
void
call
(
String
str
)
{
}
public
void
call
(
List
<
String
>
list
)
{
}
public
void
call
(
ArrayList
<
String
>
list
)
{
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
// TODO: implement more checks for casts in overloaded methods
// assertThat(code, containsOne("call(new ArrayList<>());"));
assertThat
(
code
,
containsOne
(
"call((ArrayList<String>) new ArrayList());"
));
// TODO: fix generics in constructors
// assertThat(code, containsOne("call((List<String>) new ArrayList<String>());"));
assertThat
(
code
,
containsOne
(
"call((List<String>) new ArrayList());"
));
assertThat
(
code
,
containsOne
(
"call((String) obj);"
));
}
}
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