-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't inline anonymous in self inner class (#1645)
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
jadx-core/src/test/java/jadx/tests/integration/inner/TestAnonymousClass20.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,39 @@ | ||
package jadx.tests.integration.inner; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.api.JadxInternalAccess; | ||
import jadx.api.JavaClass; | ||
import jadx.core.dex.attributes.AType; | ||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestAnonymousClass20 extends IntegrationTest { | ||
|
||
@SuppressWarnings({ "unused", "checkstyle:TypeName", "Convert2Lambda", "Anonymous2MethodRef" }) | ||
public static class Test$Cls { | ||
public Runnable test() { | ||
return new Runnable() { | ||
@Override | ||
public void run() { | ||
new Test$Cls(); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(Test$Cls.class); | ||
assertThat(cls.get(AType.ANONYMOUS_CLASS)).isNull(); | ||
|
||
JavaClass javaClass = JadxInternalAccess.convertClassNode(jadxDecompiler, cls); | ||
assertThat(javaClass.getTopParentClass()).isEqualTo(javaClass); | ||
|
||
assertThat(cls) | ||
.code() | ||
.containsOne("new TestAnonymousClass20$Test$Cls();"); | ||
} | ||
} |