{"record":{"id":"a4d56c4cc73741b6","repo":"pxb1988/dex2jar","slug":"invalid-array-type","errorCode":null,"errorMessage":"Invalid array type","messagePattern":"Invalid array type","errorType":"exception","errorClass":"AnalyzerException","httpStatus":null,"severity":"error","filePath":"dex-translator/src/main/java/com/googlecode/d2j/converter/J2IRConverter.java","lineNumber":528,"sourceCode":"                        switch (((IntInsnNode) insn).operand) {\n                            case T_BOOLEAN:\n                                return b(1, Exprs.nNewArray(\"Z\", local));\n                            case T_CHAR:\n                                return b(1, Exprs.nNewArray(\"C\", local));\n                            case T_BYTE:\n                                return b(1, Exprs.nNewArray(\"B\", local));\n                            case T_SHORT:\n                                return b(1, Exprs.nNewArray(\"S\", local));\n                            case T_INT:\n                                return b(1, Exprs.nNewArray(\"I\", local));\n                            case T_FLOAT:\n                                return b(1, Exprs.nNewArray(\"F\", local));\n                            case T_DOUBLE:\n                                return b(1, Exprs.nNewArray(\"D\", local));\n                            case T_LONG:\n                                return b(1, Exprs.nNewArray(\"J\", local));\n                            default:\n                                throw new AnalyzerException(insn, \"Invalid array type\");\n                        }\n                    case ANEWARRAY:\n                        String desc = \"L\" + ((TypeInsnNode) insn).desc + \";\";\n                        return b(1, Exprs.nNewArray(desc, local));\n                    case ARRAYLENGTH:\n                        return b(1, Exprs.nLength(local));\n                    case ATHROW:\n                        emit(Stmts.nThrow(local));\n                        return null;\n                    case CHECKCAST:\n                        String orgDesc = ((TypeInsnNode) insn).desc;\n                        desc = orgDesc.startsWith(\"[\") ? orgDesc : (\"L\" + orgDesc + \";\");\n                        return b(1, Exprs.nCheckCast(local, desc));\n                    case INSTANCEOF:\n                        return b(1, Exprs.nInstanceOf(local, \"L\" + ((TypeInsnNode) insn).desc + \";\"));\n                    case MONITORENTER:\n                        emit(Stmts.nLock(local));\n                        return null;","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-translator/src/main/java/com/googlecode/d2j/converter/J2IRConverter.java#L510-L546","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the offending method's bytecode with javap -c; regenerate or recompile the class so NEWARRAY uses valid type opcodes.","Remove or repair the bytecode-transforming tool that produced the invalid NEWARRAY instruction.","Validate class files before conversion (e.g. run with a verifier) to catch corruption early.","Patch unaryOperation to log the opcode value for diagnosis and/or map additional codes."],"exampleFix":"// before: corrupted NEWARRAY opcode -> AnalyzerException 'Invalid array type'\n// after: recompile the class cleanly\njavac MyClass.java && dx/d8 convert the fresh class","handlingStrategy":"validation","validationCode":"// Validate NEWARRAY opcodes before conversion\nint[] valid = {T_BOOLEAN, T_CHAR, T_FLOAT, T_DOUBLE, T_BYTE, T_SHORT, T_INT, T_LONG};\nfor (MethodNode m : classNode.methods)\n  for (AbstractInsnNode i : m.instructions)\n    if (i.getOpcode() >= NEWARRAY_BASE && isNewArray(i.getOpcode())\n        && !contains(valid, i.getOpcode()))\n      throw new MalformedBytecodeException(\"bad NEWARRAY type code\");","typeGuard":"boolean hasValidNewArrayOpcodes(ClassNode cn) {\n  return cn.methods.stream().flatMap(m -> Arrays.stream(m.instructions.toArray()))\n      .mapToInt(AbstractInsnNode::getOpcode)\n      .filter(op -> op >= Opcodes.T_BOOLEAN && op <= Opcodes.T_LONG || op == Opcodes.NEWARRAY)\n      .allMatch(op -> op != Opcodes.NEWARRAY);\n}","tryCatchPattern":"try {\n    analyzer.analyze(owner, methodNode);\n} catch (AnalyzerException e) {\n    if (\"Invalid array type\".equals(e.getMessage())) {\n        log.error(\"Corrupted NEWARRAY in \" + methodNode.name + \" — recompile or fix bytecode transformer\", e);\n    } else throw e;\n}","preventionTips":["Verify class files (java -Xverify or a verifier) before translation","Audit any bytecode instrumentation/obfuscation tools that rewrite instructions","Use javap -c to inspect suspicious methods before converting","Treat AnalyzerException with opcode context as malformed-input, not retryable"],"tags":["java","bytecode","dex-translation","analyzer-exception","array"],"backgroundTag":"invalid-enum-value","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}