{"record":{"id":"5b2a00691109db48","repo":"pxb1988/dex2jar","slug":"a-5b2a00","errorCode":null,"errorMessage":"a","messagePattern":"a","errorType":"exception","errorClass":"CantNotFixContentException","httpStatus":null,"severity":"error","filePath":"dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java","lineNumber":851,"sourceCode":"    // AA|op BBBB CCCC HHHH\n    public static class OP4rcc extends OpInsn {\n        final BaseItem mtd;\n        final BaseItem proto;\n        final int length;\n        final int start;\n\n        public OP4rcc(Op op, int[] args, BaseItem mtd, BaseItem proto) {\n            super(op);\n            this.mtd = mtd;\n            this.proto = proto;\n            length = args.length;\n            checkContentUByte(op, \"AA\", length);\n            if (length > 0) {\n                start = args[0];\n                checkContentUShort(op, \"CCCC\", start);\n                for (int i = 1; i < args.length; i++) {\n                    if (start + i != args[i]) {\n                        throw new CantNotFixContentException(op, \"a\", args[i]);\n                    }\n                }\n            } else {\n                start = 0;\n            }\n\n        }\n\n        @Override\n        public void write(ByteBuffer out) {\n            checkContentUShort(op, \"@BBBB\", mtd.index);\n            checkContentUShort(op, \"@HHHH\", proto.index);\n            out\n                    .put((byte) op.opcode).put((byte) length) //\n                    .putShort((short) mtd.index) //\n                    .putShort((short) start) //\n                    .putShort((short) proto.index) //\n            ;","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java#L833-L869","documentation":"CodeWriter's packed-switch/sparse-switch payload builder validates that switch targets form a contiguous register range starting at args[0]. When args[i] != start + i for some entry, it throws CantNotFixContentException with key 'a', meaning the register arguments cannot be encoded as the required consecutive sequence.","triggerScenarios":"Calling CodeWriter's switch-instruction API with register args that are not consecutive (e.g. v0, v2, v3 instead of v0, v1, v2), or with a start register whose value plus index overflows/misses a subsequent register number.","commonSituations":"Code generators translating high-level switch statements into dex register arrays after register reallocation; optimizations that removed registers without compacting the list; hand-built args arrays.","solutions":["Renumber/compact the target registers so they are strictly consecutive starting at args[0]","Ensure args[0] is a valid ushort start register and length matches args.length-1","Check the register allocator: re-run allocation after any dead-register elimination"],"exampleFix":"// before\nwriteSwitch(op, new int[]{0, 2, 3});\n// after\nwriteSwitch(op, new int[]{0, 1, 2});","handlingStrategy":"validation","validationCode":"static boolean isConsecutive(int[] args) {\n    for (int i = 1; i < args.length; i++) if (args[i] != args[0] + i) return false;\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try { codeWriter.writeSwitch(op, args); } catch (CantNotFixContentException e) { /* renumber registers and retry */ }","preventionTips":["Sort and compact target registers before building the args array","Re-run register allocation after any optimization pass","Unit-test switch emission with non-trivial register layouts"],"tags":["dex","bytecode","register-allocation"],"backgroundTag":"invalid-argument-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"}