-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: additional checks for class signature
- Loading branch information
Showing
4 changed files
with
168 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
jadx-core/src/test/java/jadx/tests/integration/generics/TestClassSignature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package jadx.tests.integration.generics; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestClassSignature extends SmaliTest { | ||
// @formatter:off | ||
/* | ||
Incorrect class signature, super class is equals to this class: <T:Ljava/lang/Object;>Lgenerics/TestClassSignature<TT;>; | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
assertThat(getClassNodeFromSmali()) | ||
.code() | ||
.containsOne("Incorrect class signature") | ||
.doesNotContain("StackOverflowError"); | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
jadx-core/src/test/smali/generics/TestClassSignature.smali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
.class public abstract Lgenerics/TestClassSignature; | ||
.super Ljava/lang/Object; | ||
.source "SourceFile" | ||
|
||
# interfaces | ||
.implements Ljava/util/Iterator; | ||
|
||
|
||
# annotations | ||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"<T:", | ||
"Ljava/lang/Object;", | ||
">", | ||
"Lgenerics/TestClassSignature<", | ||
"TT;>;" | ||
} | ||
.end annotation | ||
|
||
|
||
# instance fields | ||
.field public f:Ljava/lang/Object; | ||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"TT;" | ||
} | ||
.end annotation | ||
.end field | ||
|
||
|
||
# direct methods | ||
.method public constructor <init>(Ljava/lang/Object;)V | ||
.registers 2 | ||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"(TT;)V" | ||
} | ||
.end annotation | ||
|
||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
iput-object p1, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
return-void | ||
.end method | ||
|
||
|
||
# virtual methods | ||
.method public abstract a(Ljava/lang/Object;)Ljava/lang/Object; | ||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"(TT;)TT;" | ||
} | ||
.end annotation | ||
.end method | ||
|
||
.method public final hasNext()Z | ||
.registers 2 | ||
|
||
.line 1 | ||
iget-object v0, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
if-eqz v0, :cond_6 | ||
const/4 v0, 0x1 | ||
goto :goto_7 | ||
|
||
:cond_6 | ||
const/4 v0, 0x0 | ||
|
||
:goto_7 | ||
return v0 | ||
.end method | ||
|
||
.method public final next()Ljava/lang/Object; | ||
.registers 3 | ||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"()TT;" | ||
} | ||
.end annotation | ||
|
||
invoke-virtual {p0}, Lgenerics/TestClassSignature;->hasNext()Z | ||
move-result v0 | ||
if-eqz v0, :cond_1b | ||
|
||
:try_start_6 | ||
iget-object v0, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
:try_end_8 | ||
.catchall {:try_start_6 .. :try_end_8} :catchall_11 | ||
|
||
iget-object v1, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
invoke-virtual {p0, v1}, Lgenerics/TestClassSignature;->a(Ljava/lang/Object;)Ljava/lang/Object; | ||
move-result-object v1 | ||
iput-object v1, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
return-object v0 | ||
|
||
:catchall_11 | ||
move-exception v0 | ||
|
||
iget-object v1, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
invoke-virtual {p0, v1}, Lgenerics/TestClassSignature;->a(Ljava/lang/Object;)Ljava/lang/Object; | ||
move-result-object v1 | ||
iput-object v1, p0, Lgenerics/TestClassSignature;->f:Ljava/lang/Object; | ||
throw v0 | ||
|
||
:cond_1b | ||
new-instance v0, Ljava/util/NoSuchElementException; | ||
invoke-direct {v0}, Ljava/util/NoSuchElementException;-><init>()V | ||
throw v0 | ||
.end method | ||
|
||
.method public final remove()V | ||
.registers 2 | ||
|
||
new-instance v0, Ljava/lang/UnsupportedOperationException; | ||
invoke-direct {v0}, Ljava/lang/UnsupportedOperationException;-><init>()V | ||
throw v0 | ||
.end method |