pxb1988/dex2jar · error · CantNotFixContentException
a
Error message
a
What it means
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.
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
Example fix
// before
writeSwitch(op, new int[]{0, 2, 3});
// after
writeSwitch(op, new int[]{0, 1, 2}); Defensive patterns
Strategy: validation
Validate before calling
static boolean isConsecutive(int[] args) {
for (int i = 1; i < args.length; i++) if (args[i] != args[0] + i) return false;
return true;
} Try / catch
try { codeWriter.writeSwitch(op, args); } catch (CantNotFixContentException e) { /* renumber registers and retry */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- while accept code in method
- zero-width instruction op=0x%02x
- jump out of insns -> %04x
- bad payload for
- bad payload offset for
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/5b2a00691109db48.
Report an issue: GitHub.
Appendix: source
Thrown at dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java:851
// AA|op BBBB CCCC HHHH
public static class OP4rcc extends OpInsn {
final BaseItem mtd;
final BaseItem proto;
final int length;
final int start;
public OP4rcc(Op op, int[] args, BaseItem mtd, BaseItem proto) {
super(op);
this.mtd = mtd;
this.proto = proto;
length = args.length;
checkContentUByte(op, "AA", length);
if (length > 0) {
start = args[0];
checkContentUShort(op, "CCCC", start);
for (int i = 1; i < args.length; i++) {
if (start + i != args[i]) {
throw new CantNotFixContentException(op, "a", args[i]);
}
}
} else {
start = 0;
}
}
@Override
public void write(ByteBuffer out) {
checkContentUShort(op, "@BBBB", mtd.index);
checkContentUShort(op, "@HHHH", proto.index);
out
.put((byte) op.opcode).put((byte) length) //
.putShort((short) mtd.index) //
.putShort((short) start) //
.putShort((short) proto.index) //
;View on GitHub (pinned to b5bda4fb49)