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
63c003a0
Commit
63c003a0
authored
Mar 02, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix generic types for local variables
parent
5557fd81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
2 deletions
+56
-2
PostTypeResolver.java
...re/dex/visitors/typeresolver/finish/PostTypeResolver.java
+8
-2
TestGenerics2.java
...test/java/jadx/tests/internal/generics/TestGenerics2.java
+48
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/typeresolver/finish/PostTypeResolver.java
View file @
63c003a0
...
...
@@ -7,6 +7,7 @@ import jadx.core.dex.instructions.args.ArgType;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.LiteralArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.TypedVar
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
...
...
@@ -88,8 +89,13 @@ public class PostTypeResolver {
case
CHECK_CAST:
{
ArgType
castType
=
(
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
();
// workaround for compiler bug (see TestDuplicateCast)
insn
.
getResult
().
getTypedVar
().
forceSetType
(
castType
);
TypedVar
typedVar
=
insn
.
getResult
().
getTypedVar
();
// don't override generic types of same base class
boolean
skip
=
castType
.
isObject
()
&&
castType
.
getObject
().
equals
(
typedVar
.
getType
().
getObject
());
if
(!
skip
)
{
// workaround for compiler bug (see TestDuplicateCast)
typedVar
.
forceSetType
(
castType
);
}
return
true
;
}
...
...
jadx-core/src/test/java/jadx/tests/internal/generics/TestGenerics2.java
0 → 100644
View file @
63c003a0
package
jadx
.
tests
.
internal
.
generics
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.WeakReference
;
import
java.util.Map
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestGenerics2
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
static
class
ItemReference
<
V
>
extends
WeakReference
<
V
>
{
private
Object
id
;
public
ItemReference
(
V
item
,
Object
id
,
ReferenceQueue
<?
super
V
>
queue
)
{
super
(
item
,
queue
);
this
.
id
=
id
;
}
}
public
static
class
ItemReferences
<
V
>
{
private
Map
<
Object
,
ItemReference
<
V
>>
items
;
public
V
get
(
Object
id
)
{
WeakReference
<
V
>
ref
=
this
.
items
.
get
(
id
);
return
(
ref
!=
null
)
?
ref
.
get
()
:
null
;
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsString
(
"public ItemReference(V item, Object id, ReferenceQueue<? super V> queue) {"
));
assertThat
(
code
,
containsString
(
"public V get(Object id) {"
));
assertThat
(
code
,
containsString
(
"WeakReference<V> ref = "
));
assertThat
(
code
,
containsString
(
"return (ref != null) ? ref.get() : 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