Projects STRLCPY jadx Commits 6bac5c16
🤬
  • core: select correct array type element

  • Loading...
  • Skylot committed 1 decade ago
    6bac5c16
    1 parent 5cbf71bd
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
    skipped 471 lines
    472 472   ArgType elType = insn.getElementType();
    473 473   if (!elType.equals(insnElementType) && !insnArrayType.equals(ArgType.OBJECT)) {
    474 474   ErrorsCounter.methodError(mth,
    475  - "Incorrect type for fill-array insn " + InsnUtils.formatOffset(insn.getOffset()));
     475 + "Incorrect type for fill-array insn " + InsnUtils.formatOffset(insn.getOffset())
     476 + + ", element type: " + elType + ", insn element type: " + insnElementType);
     477 + if (!elType.isTypeKnown()) {
     478 + elType = insnElementType.isTypeKnown() ? insnElementType : elType.selectFirst();
     479 + }
    476 480   }
    477 481   StringBuilder str = new StringBuilder();
    478 482   Object data = insn.getData();
    skipped 233 lines
  • ■ ■ ■ ■ ■ ■
    jadx-core/src/test/java/jadx/tests/internal/TestTmp2.java
     1 +package jadx.tests.internal;
     2 + 
     3 +import jadx.api.InternalJadxTest;
     4 +import jadx.core.dex.nodes.ClassNode;
     5 + 
     6 +import org.junit.Test;
     7 + 
     8 +import static org.hamcrest.CoreMatchers.containsString;
     9 +import static org.hamcrest.CoreMatchers.not;
     10 +import static org.junit.Assert.assertThat;
     11 + 
     12 +public class TestTmp2 extends InternalJadxTest {
     13 + 
     14 + public static class TestCls extends Exception {
     15 + int c;
     16 + String d;
     17 + String f;
     18 + 
     19 + public void testComplexIf(String a, int b) {
     20 + if (d == null || (c == 0 && b != -1 && d.length() == 0)) {
     21 + c = a.codePointAt(c);
     22 + } else {
     23 + if (a.hashCode() != 0xCDE) {
     24 + c = f.compareTo(a);
     25 + }
     26 + }
     27 + }
     28 + }
     29 + 
     30 + @Test
     31 + public void test() {
     32 + ClassNode cls = getClassNode(TestCls.class);
     33 + String code = cls.getCode().toString();
     34 + System.out.println(code);
     35 + 
     36 + assertThat(code, containsString("return;"));
     37 + assertThat(code, not(containsString("else")));
     38 + }
     39 +}
     40 + 
Please wait...
Page is in error, reload to recover