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
12bb6323
Commit
12bb6323
authored
Jul 10, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: always cast null objects in overloaded method (#707)
parent
e4fc6774
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+15
-7
TestCastOfNull.java
...st/java/jadx/tests/integration/others/TestCastOfNull.java
+7
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
12bb6323
...
...
@@ -807,11 +807,22 @@ public class InsnGen {
return
false
;
}
}
if
(
isCastNeeded
(
arg
,
origType
))
{
code
.
add
(
'('
);
useType
(
code
,
origType
);
code
.
add
(
") "
);
return
true
;
}
return
false
;
}
private
boolean
isCastNeeded
(
InsnArg
arg
,
ArgType
origType
)
{
ArgType
argType
=
arg
.
getType
();
if
(
argType
.
equals
(
origType
)
// null cast to object
&&
(!
arg
.
isLiteral
()
||
((
LiteralArg
)
arg
).
getLiteral
()
!=
0
||
(!
argType
.
isArray
()
&&
!
argType
.
isObject
())))
{
if
(
arg
.
isLiteral
()
&&
((
LiteralArg
)
arg
).
getLiteral
()
==
0
&&
(
argType
.
isObject
()
||
argType
.
isArray
()))
{
return
true
;
}
if
(
argType
.
equals
(
origType
))
{
return
false
;
}
if
(
origType
.
isGeneric
())
{
...
...
@@ -828,9 +839,6 @@ public class InsnGen {
((
InsnWrapArg
)
arg
).
getWrapInsn
().
add
(
AFlag
.
EXPLICIT_GENERICS
);
}
}
code
.
add
(
'('
);
useType
(
code
,
origType
);
code
.
add
(
") "
);
return
true
;
}
...
...
jadx-core/src/test/java/jadx/tests/integration/others/TestCastOfNull.java
View file @
12bb6323
package
jadx
.
tests
.
integration
.
others
;
import
java.util.List
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
...
...
@@ -15,6 +17,7 @@ public class TestCastOfNull extends IntegrationTest {
public
void
test
()
{
m
((
long
[])
null
);
m
((
String
)
null
);
m
((
List
<
String
>)
null
);
}
public
void
m
(
long
[]
a
)
{
...
...
@@ -22,6 +25,9 @@ public class TestCastOfNull extends IntegrationTest {
public
void
m
(
String
s
)
{
}
public
void
m
(
List
<
String
>
list
)
{
}
}
@Test
...
...
@@ -31,5 +37,6 @@ public class TestCastOfNull extends IntegrationTest {
assertThat
(
code
,
containsOne
(
"m((long[]) null);"
));
assertThat
(
code
,
containsOne
(
"m((String) null);"
));
assertThat
(
code
,
containsOne
(
"m((List<String>) null);"
));
}
}
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