-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: invoke in nested anonymous classes (#1305)
- Loading branch information
Showing
5 changed files
with
104 additions
and
3 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
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
60 changes: 60 additions & 0 deletions
60
jadx-core/src/test/java/jadx/tests/integration/inner/TestAnonymousClass18.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,60 @@ | ||
package jadx.tests.integration.inner; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.api.CommentsLevel; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestAnonymousClass18 extends IntegrationTest { | ||
|
||
@SuppressWarnings({ "Convert2Lambda", "Anonymous2MethodRef", "unused" }) | ||
public static class TestCls { | ||
|
||
public interface Job { | ||
void executeJob(); | ||
} | ||
|
||
public void start() { | ||
runJob(new Job() { | ||
@Override | ||
public void executeJob() { | ||
runJob(new Job() { | ||
@Override | ||
public void executeJob() { | ||
doSomething(); | ||
} | ||
}); | ||
} | ||
|
||
private void doSomething() { | ||
} | ||
}); | ||
} | ||
|
||
public static void runJob(Job job) { | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
getArgs().setCommentsLevel(CommentsLevel.WARN); | ||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
.doesNotContain("AnonymousClass1.this") | ||
.doesNotContain("class AnonymousClass1") | ||
// .doesNotContain("TestAnonymousClass18$TestCls.runJob(") // TODO: ??? | ||
.containsOne(indent() + "doSomething();"); | ||
} | ||
|
||
@Test | ||
public void testNoInline() { | ||
getArgs().setInlineAnonymousClasses(false); | ||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
.containsOne("class AnonymousClass1 implements Job {") | ||
.containsOne("class C00001 implements Job {") | ||
.containsOne("AnonymousClass1.this.doSomething();"); | ||
} | ||
} |