{"record":{"id":"e290aa41aff06d8f","repo":"pxb1988/dex2jar","slug":"bbbb","errorCode":null,"errorMessage":"#+BBBB","messagePattern":"#\\+BBBB","errorType":"exception","errorClass":"CantNotFixContentException","httpStatus":null,"severity":"error","filePath":"dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java","lineNumber":208,"sourceCode":"            }\n            realV = (int) (v >> 48);\n        }\n        b.position(0);\n        b.put((byte) op.opcode).put((byte) vAA).putShort((short) realV);\n        return copy(b);\n    }\n\n    // AA|op BBBB\n    private byte[] build21s(Op op, int vAA, Number value) {\n        checkRegAA(op, \"vAA\", vAA);\n        int realV;\n        if (op == CONST_16) {\n            realV = value.intValue();\n            checkContentShort(op, \"#+BBBB\", realV);\n        } else {// CONST_WIDE_16\n            long v = value.longValue();\n            if (v > Short.MAX_VALUE || v < Short.MIN_VALUE) {\n                throw new CantNotFixContentException(op, \"#+BBBB\", v);\n            }\n            realV = (int) v;\n        }\n        b.position(0);\n        b.put((byte) op.opcode).put((byte) vAA).putShort((short) realV);\n        return copy(b);\n    }\n\n    // AA|op CC|BB\n    private byte[] build22b(Op op, int vAA, int vBB, int cc) {\n        checkRegAA(op, \"vAA\", vAA);\n        checkRegAA(op, \"vBB\", vBB);\n        checkContentByte(op, \"#+CC\", cc);\n\n        b.position(0);\n        b.put((byte) op.opcode).put((byte) vAA).put((byte) vBB).put((byte) cc);\n        return copy(b);\n    }","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java#L190-L226","documentation":"CodeWriter.build21s assembles the 21s format (const/16 and const-wide/16), whose immediate is a signed 16-bit value. For CONST_WIDE_16, if the long value exceeds Short.MAX_VALUE or is below Short.MIN_VALUE, it cannot be stored in the signed 16-bit slot, so CantNotFixContentException with message '#+BBBB' is thrown (the CONST_16 path is guarded by checkContentShort).","triggerScenarios":"visitConstStmt dispatching CONST_WIDE_16 with a long outside -32768..32767, e.g. 100000.","commonSituations":"Optimizers that try to narrow wide constants to 16-bit forms purely by size heuristics; translators that mislabel int constants as wide without range checks.","solutions":["Verify the value fits Short range before choosing CONST_WIDE_16; otherwise emit CONST_WIDE_32 or CONST_WIDE.","Fix the opcode-selection heuristic in visitConstStmt to range-check before narrowing.","Cast only after the range check: if (v >= Short.MIN_VALUE && v <= Short.MAX_VALUE) use 21s.","Catch CantNotFixContentException as a fallback trigger to re-emit with a wider opcode."],"exampleFix":"// before\nemitConst(CONST_WIDE_16, a, 100000L);\n// after\nif (v >= Short.MIN_VALUE && v <= Short.MAX_VALUE) emitConst(CONST_WIDE_16, a, v); else emitConst(CONST_WIDE_32, a, v);","handlingStrategy":"validation","validationCode":"boolean fitsShort(long v) { return v >= Short.MIN_VALUE && v <= Short.MAX_VALUE; }","typeGuard":null,"tryCatchPattern":"try {\n    emitConst(CONST_WIDE_16, a, v);\n} catch (CantNotFixContentException e) {\n    emitConst(CONST_WIDE_32, a, v);\n}","preventionTips":["Range-check against Short.MIN_VALUE/MAX_VALUE before narrowing to 16-bit consts","Don't classify int values as wide-16 without a range test","Test constant narrowing at boundary values (-32768, 32767, 32768)","Preserve a fallback chain: 16 -> 32 -> wide"],"tags":["dex","bytecode","constant-encoding","value-out-of-range"],"backgroundTag":"value-out-of-range","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"}