pxb1988/dex2jar · error · AnalyzerException

Invalid array type

Error message

Invalid array type

What it means

In J2IRConverter.unaryOperation, the NEWARRAY instruction carries an ASM opcode (T_BOOLEAN..T_LONG) identifying the primitive element type. When the opcode is not one of the recognized NEWARRAY variants, the default branch throws AnalyzerException('Invalid array type'), meaning the bytecode's newarray type code is outside the expected set.

Solutions

  1. Verify the offending method's bytecode with javap -c; regenerate or recompile the class so NEWARRAY uses valid type opcodes.
  2. Remove or repair the bytecode-transforming tool that produced the invalid NEWARRAY instruction.
  3. Validate class files before conversion (e.g. run with a verifier) to catch corruption early.
  4. Patch unaryOperation to log the opcode value for diagnosis and/or map additional codes.

Example fix

// before: corrupted NEWARRAY opcode -> AnalyzerException 'Invalid array type'
// after: recompile the class cleanly
javac MyClass.java && dx/d8 convert the fresh class
Defensive patterns

Strategy: validation

Validate before calling

// Validate NEWARRAY opcodes before conversion
int[] valid = {T_BOOLEAN, T_CHAR, T_FLOAT, T_DOUBLE, T_BYTE, T_SHORT, T_INT, T_LONG};
for (MethodNode m : classNode.methods)
  for (AbstractInsnNode i : m.instructions)
    if (i.getOpcode() >= NEWARRAY_BASE && isNewArray(i.getOpcode())
        && !contains(valid, i.getOpcode()))
      throw new MalformedBytecodeException("bad NEWARRAY type code");

Type guard

boolean hasValidNewArrayOpcodes(ClassNode cn) {
  return cn.methods.stream().flatMap(m -> Arrays.stream(m.instructions.toArray()))
      .mapToInt(AbstractInsnNode::getOpcode)
      .filter(op -> op >= Opcodes.T_BOOLEAN && op <= Opcodes.T_LONG || op == Opcodes.NEWARRAY)
      .allMatch(op -> op != Opcodes.NEWARRAY);
}

Try / catch

try {
    analyzer.analyze(owner, methodNode);
} catch (AnalyzerException e) {
    if ("Invalid array type".equals(e.getMessage())) {
        log.error("Corrupted NEWARRAY in " + methodNode.name + " — recompile or fix bytecode transformer", e);
    } else throw e;
}

Prevention

When it happens

Trigger: A NEWARRAY instruction whose opcode is not T_BOOLEAN, T_CHAR, T_FLOAT, T_DOUBLE, T_BYTE, T_SHORT, T_INT, or T_LONG — typically caused by corrupted/patched bytecode or a malformed/transformed method node fed to the analyzer.

Common situations: Running the converter on bytecode that was modified by instrumentation or obfuscation tools that corrupted NEWARRAY opcodes; custom class-generation bugs producing invalid newarray type codes.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08). Data as JSON: /api/errors/a4d56c4cc73741b6. Report an issue: GitHub.

Appendix: source

Thrown at dex-translator/src/main/java/com/googlecode/d2j/converter/J2IRConverter.java:528

                        switch (((IntInsnNode) insn).operand) {
                            case T_BOOLEAN:
                                return b(1, Exprs.nNewArray("Z", local));
                            case T_CHAR:
                                return b(1, Exprs.nNewArray("C", local));
                            case T_BYTE:
                                return b(1, Exprs.nNewArray("B", local));
                            case T_SHORT:
                                return b(1, Exprs.nNewArray("S", local));
                            case T_INT:
                                return b(1, Exprs.nNewArray("I", local));
                            case T_FLOAT:
                                return b(1, Exprs.nNewArray("F", local));
                            case T_DOUBLE:
                                return b(1, Exprs.nNewArray("D", local));
                            case T_LONG:
                                return b(1, Exprs.nNewArray("J", local));
                            default:
                                throw new AnalyzerException(insn, "Invalid array type");
                        }
                    case ANEWARRAY:
                        String desc = "L" + ((TypeInsnNode) insn).desc + ";";
                        return b(1, Exprs.nNewArray(desc, local));
                    case ARRAYLENGTH:
                        return b(1, Exprs.nLength(local));
                    case ATHROW:
                        emit(Stmts.nThrow(local));
                        return null;
                    case CHECKCAST:
                        String orgDesc = ((TypeInsnNode) insn).desc;
                        desc = orgDesc.startsWith("[") ? orgDesc : ("L" + orgDesc + ";");
                        return b(1, Exprs.nCheckCast(local, desc));
                    case INSTANCEOF:
                        return b(1, Exprs.nInstanceOf(local, "L" + ((TypeInsnNode) insn).desc + ";"));
                    case MONITORENTER:
                        emit(Stmts.nLock(local));
                        return null;

View on GitHub (pinned to b5bda4fb49)