pxb1988/dex2jar · error · CantNotFixContentException
#+BBBB000000000000
Error message
#+BBBB000000000000
What it means
CodeWriter.build21h also handles CONST_WIDE_HIGH16, whose 21h format keeps only the high 16 bits of a 64-bit constant; all lower 48 bits must be zero. If the long value has any non-zero low 48 bits ((v & 0x0000FFFFffffFFFFL) != 0), the constant cannot be encoded exactly, so CantNotFixContentException is thrown with message '#+BBBB000000000000'.
Solutions
- Only emit CONST_WIDE_HIGH16 when (v & 0x0000FFFFffffFFFFL) == 0; otherwise use CONST_WIDE (51l).
- Change opcode selection to CONST_WIDE_32 or CONST_WIDE depending on value range.
- Fix the constant-classification logic that maps values to opcodes.
- Catch CantNotFixContentException and re-emit with a wider const format.
Example fix
// before emitConst(CONST_WIDE_HIGH16, a, 0x123456789ABCDEFL); // after if ((v & 0x0000FFFFffffFFFFL) == 0) emitConst(CONST_WIDE_HIGH16, a, v); else emitConst(CONST_WIDE, a, v);
Defensive patterns
Strategy: validation
Validate before calling
boolean fitsConstWideHigh16(long v) { return (v & 0x0000FFFFffffFFFFL) == 0; } Try / catch
try {
emitConst(CONST_WIDE_HIGH16, a, v);
} catch (CantNotFixContentException e) {
emitConst(CONST_WIDE, a, v); // fall back to full 64-bit const
} Prevention
- Test low 48 bits are zero before choosing const-wide/high16
- Use value-shape-based opcode selection, not size heuristics
- Add tests with longs like 0x123456789ABCDEFL
- Keep the full CONST_WIDE fallback available
When it happens
Trigger: visitConstStmt dispatching CONST_WIDE_HIGH16 with a long whose low 48 bits are non-zero, e.g. 0x0001_2345_6789_ABCD.
Common situations: Translation from Java long constants where the optimizer picks the smallest const opcode without verifying the trailing zero bits; JIT-like constant substitution passes.
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/b7ce4006ac9e54ec.
Report an issue: GitHub.
Appendix: source
Thrown at dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java:189
return copy(b);
}
// AA|op BBBB
private byte[] build21h(Op op, int vAA, Number value) {
checkRegAA(op, "vAA", vAA);
int realV;
if (op == CONST_HIGH16) { // op vAA, #+BBBB0000
int v = ((Number) value).intValue();
if ((v & 0xFFFF) != 0) {
throw new CantNotFixContentException(op, "#+BBBB0000", v);
}
realV = v >> 16;
} else { // CONST_WIDE_HIGH16 //op vAA, #+BBBB000000000000
long v = ((Number) value).longValue();
if ((v & 0x0000FFFFffffFFFFL) != 0) {
throw new CantNotFixContentException(op, "#+BBBB000000000000", v);
}
realV = (int) (v >> 48);
}
b.position(0);
b.put((byte) op.opcode).put((byte) vAA).putShort((short) realV);
return copy(b);
}
// AA|op BBBB
private byte[] build21s(Op op, int vAA, Number value) {
checkRegAA(op, "vAA", vAA);
int realV;
if (op == CONST_16) {
realV = value.intValue();
checkContentShort(op, "#+BBBB", realV);
} else {// CONST_WIDE_16
long v = value.longValue();
if (v > Short.MAX_VALUE || v < Short.MIN_VALUE) {View on GitHub (pinned to b5bda4fb49)