{"record":{"id":"b7ce4006ac9e54ec","repo":"pxb1988/dex2jar","slug":"bbbb000000000000","errorCode":null,"errorMessage":"#+BBBB000000000000","messagePattern":"#\\+BBBB000000000000","errorType":"exception","errorClass":"CantNotFixContentException","httpStatus":null,"severity":"error","filePath":"dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java","lineNumber":189,"sourceCode":"\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);\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) {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java#L171-L207","documentation":"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'.","triggerScenarios":"visitConstStmt dispatching CONST_WIDE_HIGH16 with a long whose low 48 bits are non-zero, e.g. 0x0001_2345_6789_ABCD.","commonSituations":"Translation from Java long constants where the optimizer picks the smallest const opcode without verifying the trailing zero bits; JIT-like constant substitution passes.","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."],"exampleFix":"// before\nemitConst(CONST_WIDE_HIGH16, a, 0x123456789ABCDEFL);\n// after\nif ((v & 0x0000FFFFffffFFFFL) == 0) emitConst(CONST_WIDE_HIGH16, a, v); else emitConst(CONST_WIDE, a, v);","handlingStrategy":"validation","validationCode":"boolean fitsConstWideHigh16(long v) { return (v & 0x0000FFFFffffFFFFL) == 0; }","typeGuard":null,"tryCatchPattern":"try {\n    emitConst(CONST_WIDE_HIGH16, a, v);\n} catch (CantNotFixContentException e) {\n    emitConst(CONST_WIDE, a, v); // fall back to full 64-bit const\n}","preventionTips":["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"],"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"}