-
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: don't eliminate StringBuilder if no String arg present
- Loading branch information
Showing
2 changed files
with
47 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
33 changes: 33 additions & 0 deletions
33
jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination4Neg.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,33 @@ | ||
package jadx.tests.integration.others; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class TestStringBuilderElimination4Neg extends IntegrationTest { | ||
|
||
public static class TestCls<K, V> { | ||
private K k; | ||
private V v; | ||
|
||
public String test() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(k); | ||
sb.append('='); | ||
sb.append(v); | ||
return sb.toString(); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsString("sb.append('=');")); | ||
} | ||
} |