{"record":{"id":"f0a94e8ffbd6ec34","repo":"pxb1988/dex2jar","slug":"zero-width-instruction-op-0x-02x","errorCode":null,"errorMessage":"zero-width instruction op=0x%02x","messagePattern":"zero-width instruction op=0x%02x","errorType":"exception","errorClass":"BadOpException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java","lineNumber":1154,"sourceCode":"            } catch (IndexOutOfBoundsException indexOutOfRange){\r\n                badOps.set(offset);\r\n                WARN(\"GLITCH: %04x %s | not enough space for reading instruction\", offset, method.toString());\r\n            } catch (BadOpException badOp){\r\n                badOps.set(offset);\r\n                WARN(\"GLITCH: %04x %s | %s\", offset, method.toString(), badOp.getMessage());\r\n            }\r\n        }\r\n    }\r\n\r\n    private void travelInsn(Map<Integer, DexLabel> labelsMap, Queue<Integer> q, byte[] insns, int offset) {\r\n        int u1offset = offset * 2;\r\n        if (u1offset >= insns.length) {\r\n            throw new IndexOutOfBoundsException();\r\n        }\r\n        int opcode = 0xFF & insns[u1offset];\r\n        Op op = Op.ops[opcode];\r\n        if (op == null || op.format == null) {\r\n            throw new BadOpException(\"zero-width instruction op=0x%02x\", opcode);\r\n        }\r\n        int target;\r\n        boolean canContinue = true;\r\n        if (op.canBranch()) {\r\n            switch (op.format) {\r\n            case kFmt10t:\r\n                target = offset + insns[u1offset + 1];\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                break;\r\n            case kFmt20t:\r\n            case kFmt21t:\r\n                target = offset + sshort(insns, u1offset + 2);\r\n                if (target < 0 || target * 2 > insns.length ) {\r\n                    throw new BadOpException(\"jump out of insns %s -> %04x\", op, target);\r","sourceCodeStart":1136,"sourceCodeEnd":1172,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java#L1136-L1172","documentation":"BadOpException thrown while traversing method instructions: the opcode byte maps to no known Op or the Op has no instruction format, i.e. a zero-width (undecodable) instruction at u1offset. The traversal cannot make progress, so it aborts.","triggerScenarios":"acceptCode's opcode walker reads insns[u1offset] and Op.ops[opcode] is null or op.format == null — an unknown/invalid opcode byte where an instruction is expected.","commonSituations":"Dex compiled for a newer ART/dalvik version with opcodes this d2j doesn't know, obfuscated dexes with junk bytes, or a bad offset landing mid-instruction.","solutions":["Upgrade to a d2j/dex-translator version whose Op table covers the dex's opcode version","Check the op=0x%02x value against the dalvik opcode table to identify the missing opcode","Disassemble the method with baksmali to confirm the bytecode is valid","Rebuild/reobfuscate the app disabling the transformation that injects junk opcodes"],"exampleFix":"// before\n// d2j 2.x Op table lacking newer opcodes\n// after\n// upgrade dependency:\n// <artifactId>dex-reader</artifactId> <version>latest</version>","handlingStrategy":"validation","validationCode":"// Check opcode support before accepting\nint opcodeByte = 0xFF & insns[offset];\nif (opcodeByte > maxSupportedOpcode) throw new IllegalArgumentException(\"unsupported op 0x\" + Integer.toHexString(opcodeByte));","typeGuard":null,"tryCatchPattern":"try {\n    reader.accept(dmv);\n} catch (DexException e) {\n    if (e.getCause() instanceof BadOpException) { /* skip method */ }\n}","preventionTips":["Keep the d2j library current so Op tables cover new opcodes","Detect the dex's minSdk/version and reject dexes with unsupported opcodes early","Beware dexes from aggressive protectors injecting junk instructions"],"tags":["dex","opcode","bytecode","unsupported-opcode"],"backgroundTag":"unsupported-operation","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"}