pxb1988/dex2jar · error · RuntimeException
Invalid extended opcode encountered
Error message
Invalid extended opcode encountered
What it means
The debug info opcode decoder hit an extended (0x09-prefixed) opcode it does not recognize, and the value is also below DBG_FIRST_SPECIAL, so there is no special-opcode fallback. The reader throws a RuntimeException because the debug state machine cannot interpret the opcode. This signals a corrupt or non-standard debug_info_item.
Solutions
- Rebuild the dex from sources with standard tooling to regenerate valid debug info
- Strip debug info (dx --no-debug-info / d8 --no-debug-info) to avoid decoding the debug stream at all
- Hexdump and repair the debug_info_item containing the bad opcode
- Patch the reader's default case to skip unknown opcodes if you must process untrusted inputs
Example fix
// before // DexFileReader.accept(reader) on a corrupted dex -> RuntimeException // after: strip debug info at build time // d8 --release --no-debug-info --output out/ input.jar
Defensive patterns
Strategy: try-catch
Try / catch
try {
new DexFileReader(file).accept(visitor);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Invalid extended opcode encountered")) {
return retryWithoutDebugInfo(file); // rebuild/strip debug info and retry
}
throw e;
} Prevention
- Verify dex integrity (header checksum) before parsing — a single corrupted byte can produce unknown opcodes
- Strip debug info with --no-debug-info for untrusted inputs
- Regenerate dex with standard toolchains rather than parsing hand-written debug data
When it happens
Trigger: A debug_info stream containing an unknown extended opcode < DBG_FIRST_SPECIAL (0x0a) in the default case of the switch — corrupted dex, truncated debug data, or a dex from a tool emitting opcodes outside the spec's DBG_END_SEQUENCE..DBG_SET_FILE range.
Common situations: Partially corrupted files (one byte flipped inside debug data); research dex generated by custom writers; old/odd toolchains emitting unexpected debug opcodes; dex2jar conversions of such files.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Encountered RESTART_LOCAL on new v
- while accept code in method
- zero-width instruction op=0x%02x
- not support
- Odex unsupported.
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/9bd7f675d325ca63.
Report an issue: GitHub.
Appendix: source
Thrown at dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java:569
case DBG_ADVANCE_LINE:
line += readLeb128i(in);
break;
case DBG_SET_PROLOGUE_END:
order(labelMap, address);
dcv.visitPrologue(labelMap.get(address));
break;
case DBG_SET_EPILOGUE_BEGIN:
order(labelMap, address);
dcv.visitEpiogue(labelMap.get(address));
break;
case DBG_SET_FILE:
// skip
break;
default:
if (opcode < DBG_FIRST_SPECIAL) {
throw new RuntimeException("Invalid extended opcode encountered " + opcode);
}
int adjopcode = opcode - DBG_FIRST_SPECIAL;
address += adjopcode / DBG_LINE_RANGE;
line += DBG_LINE_BASE + (adjopcode % DBG_LINE_RANGE);
order(labelMap, address);
dcv.visitLineNumber(line, labelMap.get(address));
break;
}
}
}
@Override
public int getDexVersion() {
return dex_version;
View on GitHub (pinned to b5bda4fb49)