pxb1988/dex2jar · error · CantNotFixContentException
#+BBBBBBBB
Error message
#+BBBBBBBB
What it means
CodeWriter.build31i assembles the 31i format (const-wide/32), whose immediate is a signed 32-bit value. If the long value exceeds Integer.MAX_VALUE or is below Integer.MIN_VALUE, it cannot fit in the 32-bit slot, so CantNotFixContentException with message '#+BBBBBBBB' is thrown. CONST op values are not range-checked here since they are 32-bit by definition.
Solutions
- Range-check: only use CONST_WIDE_32 when v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE.
- Otherwise emit the full 64-bit CONST_WIDE (51l format).
- Fix the value-classification logic in visitConstStmt to test the int range before selecting 31i.
- Catch CantNotFixContentException and re-emit with CONST_WIDE.
Example fix
// before emitConst(CONST_WIDE_32, a, 8589934592L); // after if (v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE) emitConst(CONST_WIDE_32, a, v); else emitConst(CONST_WIDE, a, v);
Defensive patterns
Strategy: validation
Validate before calling
boolean fitsInt(long v) { return v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE; } Try / catch
try {
emitConst(CONST_WIDE_32, a, v);
} catch (CantNotFixContentException e) {
emitConst(CONST_WIDE, a, v); // full 64-bit const
} Prevention
- Verify long values fit int range before selecting const-wide/32
- Test narrowing at Integer.MIN_VALUE/MAX_VALUE boundaries
- Fall back to CONST_WIDE for full 64-bit values
- Keep opcode selection value-shape driven
When it happens
Trigger: visitConstStmt dispatching CONST_WIDE_32 with a long outside the int range, e.g. 0x1_0000_0000L.
Common situations: Constant-narrowing optimizations that classify longs as 32-bit encodable without an int-range check; translated Java code with large long literals.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/5b227dd7195c62c2.
Report an issue: GitHub.
Appendix: source
Thrown at dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java:267
private byte[] build23x(Op op, int vAA, int vBB, int vCC) {
checkRegAA(op, "vAA", vAA);
checkRegAA(op, "vBB", vBB);
checkRegAA(op, "vCC", vCC);
b.position(0);
b.put((byte) op.opcode).put((byte) vAA).put((byte) vBB).put((byte) vCC);
return copy(b);
}
// AA|op BBBBlo BBBBhi
private byte[] build31i(Op op, int vAA, Number value) {
checkRegAA(op, "vAA", vAA);
int realV;
if (op == CONST) {
realV = value.intValue();
} else if (op == CONST_WIDE_32) {
long v = value.longValue();
if (v > Integer.MAX_VALUE || v < Integer.MIN_VALUE) {
throw new CantNotFixContentException(op, "#+BBBBBBBB", v);
}
realV = (int) v;
} else {
throw new RuntimeException();
}
b.position(0);
b.put((byte) op.opcode).put((byte) vAA).putInt(realV);
return copy(b);
}
// ØØ|op AAAA BBBB
private byte[] build32x(Op op, int vAAAA, int vBBBB) {
checkRegAAAA(op, "vAAAA", vAAAA);
checkRegAAAA(op, "vBBBB", vBBBB);
b.position(0);
b.put((byte) op.opcode).put((byte) 0).putShort((short) vAAAA).putShort((short) vBBBB);
return copy(b);
}View on GitHub (pinned to b5bda4fb49)