pxb1988/dex2jar · error · DexException
while accept code in method
Error message
while accept code in method:[%s] @%08x
What it means
DexException thrown when decoding a method's bytecode body fails. acceptCode() parses insns, try/catch blocks, debug info and labels for the method at code_off, and any exception inside is re-wrapped with the method name and code offset (@%08x) for diagnosis.
Solutions
- Read the cause and the @%08x offset to locate the failing code item in the dex
- Upgrade dex-translator/d2j to a version supporting the dex/opcode version in use
- Validate the dex with a checker (dexlint/dexdump) before conversion
- Catch DexException around accept() to skip the offending method and continue
Example fix
// before
reader.accept(dmv);
// after
try {
reader.accept(dmv);
} catch (DexException e) {
System.err.println("bad code: " + e.getMessage());
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check with external validator
Process p = Runtime.getRuntime().exec(new String[]{"dexdump", "-d", dexPath});
// fail early if dexdump reports malformed code items Try / catch
try {
reader.accept(dmv);
} catch (DexException e) {
logger.warn("bad method code: " + e.getMessage());
} Prevention
- Match d2j version to the dex/opcode version of the app
- Avoid converting dexes modified by packers
- Extract classes.dex fully (no truncation) before parsing
When it happens
Trigger: accept() encounters code_off != 0 and calls acceptCode(); the code item references invalid registers, unknown opcodes, truncated insns arrays, or malformed try/catch/debug structures.
Common situations: Converting dex files built by non-standard compilers, multidex with corrupted entries, dexes that use newer opcodes than this d2j version understands, or deliberately malformed files.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- zero-width instruction op=0x%02x
- Invalid extended opcode encountered
- while accept parameter annotation in method
- while accept method:[ ]
- While accepting parameter annotation in parameter
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/2f5b0b66855e46da.
Report an issue: GitHub.
Appendix: source
Thrown at dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java:1067
} catch (Exception e) {
throw new DexException(e, "while accept parameter annotation in method:%s.",
method.toString());
}
}
}
if (code_off != 0) {
boolean keep = true;
if (0 != (SKIP_CODE & config)) {
keep = 0 != (KEEP_CLINIT & config) && method.getName().equals("<clinit>");
}
if(keep) {
DexCodeVisitor dcv = dmv.visitCode();
if (dcv != null) {
try {
acceptCode(code_off, dcv, config, (method_access_flags & DexConstants.ACC_STATIC) != 0,
method);
} catch (Exception e) {
throw new DexException(e, "while accept code in method:[%s] @%08x", method.toString(),
code_off);
}
}
}
}
dmv.visitEnd();
}
} catch (Exception e) {
throw new DexException(e, "while accept method:[%s]", method.toString());
}
return method_id;
}
private void read_annotation_set_ref_list(int parameter_annotation_offset, DexMethodVisitor dmv) {
ByteBuffer in = annotationSetRefListIn;
in.position(parameter_annotation_offset);
View on GitHub (pinned to b5bda4fb49)