{"record":{"id":"1bc49b995dd13319","repo":"pxb1988/dex2jar","slug":"bbbb0000","errorCode":null,"errorMessage":"#+BBBB0000","messagePattern":"#\\+BBBB0000","errorType":"exception","errorClass":"CantNotFixContentException","httpStatus":null,"severity":"error","filePath":"dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java","lineNumber":182,"sourceCode":"\n    // B|A|op\n    private byte[] build12x(Op op, int vA, int vB) {\n        checkRegA(op, \"vA\", vA);\n        checkRegA(op, \"vB\", vB);\n        b.position(0);\n        b.put((byte) op.opcode).put((byte) ((vA & 0xF) | (vB << 4)));\n\n        return copy(b);\n    }\n\n    // AA|op BBBB\n    private byte[] build21h(Op op, int vAA, Number value) {\n        checkRegAA(op, \"vAA\", vAA);\n        int realV;\n        if (op == CONST_HIGH16) { // op vAA, #+BBBB0000\n            int v = ((Number) value).intValue();\n            if ((v & 0xFFFF) != 0) {\n                throw new CantNotFixContentException(op, \"#+BBBB0000\", v);\n            }\n            realV = v >> 16;\n\n        } else { // CONST_WIDE_HIGH16 //op vAA, #+BBBB000000000000\n            long v = ((Number) value).longValue();\n            if ((v & 0x0000FFFFffffFFFFL) != 0) {\n                throw new CantNotFixContentException(op, \"#+BBBB000000000000\", v);\n            }\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);","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java#L164-L200","documentation":"CodeWriter.build21h assembles the 21h instruction format (const/const-wide/high16), which stores only the high 16 bits of the constant; the low bits must be zero. If a CONST_HIGH16 value has any non-zero low 16 bits, the instruction cannot represent it exactly, so CantNotFixContentException is thrown with message '#+BBBB0000'.","triggerScenarios":"visitConstStmt dispatching a CONST_HIGH16 op whose int value has (v & 0xFFFF) != 0, e.g. const/high16 with literal 0x12345678.","commonSituations":"Constant folding or translation pipelines that select the high16 opcode based only on magnitude without checking the low bits are zero; writing optimizers that replace const with const/high16 as a size optimization incorrectly.","solutions":["Mask-check the constant: only use CONST_HIGH16 when (v & 0xFFFF) == 0, otherwise emit CONST_32 (CONST).","Change the emitted opcode to CONST (31i format) for arbitrary 32-bit constants.","Fix the opcode-selection logic in visitConstStmt/optimizer to test low bits before choosing 21h.","Catch CantNotFixContentException around const emission and fall back to the wide format."],"exampleFix":"// before: assumes magnitude implies encodable\nemitConst(CONST_HIGH16, a, 0x12345678);\n// after: choose format by value shape\nif ((v & 0xFFFF) == 0) emitConst(CONST_HIGH16, a, v); else emitConst(CONST, a, v);","handlingStrategy":"validation","validationCode":"boolean fitsConstHigh16(int v) { return (v & 0xFFFF) == 0; }","typeGuard":null,"tryCatchPattern":"try {\n    emitConst(CONST_HIGH16, a, v);\n} catch (CantNotFixContentException e) {\n    emitConst(CONST, a, v); // fall back to full 32-bit const\n}","preventionTips":["Check (v & 0xFFFF) == 0 before selecting const/high16","Never pick const opcodes by magnitude alone; test the actual bit pattern","Unit-test constant narrowing with values like 0x12345678","Keep a fallback path to the full-width const opcode"],"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"}