{"record":{"id":"71777f55ee8501b6","repo":"pxb1988/dex2jar","slug":"bad-payload-for-s","errorCode":null,"errorMessage":"bad payload for %s","messagePattern":"bad payload for (.+?)","errorType":"exception","errorClass":"BadOpException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java","lineNumber":1257,"sourceCode":"                            }\r\n                            break;\r\n                        }\r\n                        case 0x02:// sparse-switch-data\r\n                        {\r\n                            int size = ushort(insns, u1SwitchData + 2);\r\n                            int b = u1SwitchData + 4 + 4 * size;// targets\r\n                            for (int i = 0; i < size; i++) {\r\n                                target = offset + sint(insns, b + i * 4);\r\n                                if (target < 0 || target * 2 > insns.length ) {\r\n                                    throw new BadOpException(\"jump out of insns %s -> %04x\", op, target);\r\n                                }\r\n                                q.add(target);\r\n                                order(labelsMap, target);\r\n                            }\r\n                            break;\r\n                        }\r\n                        default:\r\n                            throw new BadOpException(\"bad payload for %s\", op);\r\n                    }\r\n            } else {\r\n                throw new BadOpException(\"bad payload offset for %s\", op);\r\n            }\r\n        }\r\n\r\n        if (canContinue) {\r\n            int idx = Integer.MAX_VALUE;\r\n            switch (op.indexType) {\r\n            case kIndexStringRef:\r\n                if (op.format == InstructionFormat.kFmt31c) {\r\n                    idx = uint(insns, u1offset + 2);\r\n                } else {// other\r\n                    idx = ushort(insns, u1offset + 2);\r\n                }\r\n                canContinue = idx >= 0 && idx < string_ids_size;\r\n                break;\r\n            case kIndexTypeRef:\r","sourceCodeStart":1239,"sourceCodeEnd":1275,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java#L1239-L1275","documentation":"DexFileReader throws BadOpException when an instruction requires a data payload (switch or fill-array-data pseudo-op) but the payload found at the computed offset is not a valid packed-switch/sparse-switch/array-data payload for that opcode. The reader cannot interpret the referenced data, indicating a malformed or tampered dex.","triggerScenarios":"Decoding a dex where a switch/fill-array-data instruction points at an offset whose payload opcode does not match the expected pseudo-op (e.g., a packed-switch op pointing at a payload that is not kPackedSwitchPayload).","commonSituations":"Analyzing dex files rewritten by obfuscators; hand-patched bytecode where offsets were edited; tools that reassemble dex with incorrect pseudo-op links.","solutions":["Re-acquire the dex from a trusted build; rebuild if it came from a custom toolchain.","Validate the dex with a verifier (e.g., dx/dexdump) before running d2j.","If analyzing protected apps, use a deobfuscation pass that fixes pseudo-op payloads first.","Catch BadOpException per method and skip/report the offending method instead of aborting."],"exampleFix":"// before\ndexReader.accept(visitor, 0);\n// after\ntry {\n    dexReader.accept(visitor, 0);\n} catch (BadOpException e) {\n    LOG.warn(\"bad payload: \" + e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"// run a structural pass with a verifier before d2j\n// dexdump -d classes.dex  (or apkanalyzer dex packages) to reject malformed input","typeGuard":null,"tryCatchPattern":"try {\n    dexReader.accept(visitor, 0);\n} catch (BadOpException e) {\n    LOG.warn(\"bad payload for op: \" + e.getMessage());\n}","preventionTips":["Verify dex with official tooling before decompilation","Avoid feeding hand-patched or tool-rewritten dex directly","Isolate per-method conversion so one bad payload doesn't abort everything"],"tags":["dex","android","bytecode","payload"],"backgroundTag":"malformed-dex-opcode","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"}