pxb1988/dex2jar · error · RuntimeException
Fail to assemble
Error message
Fail to assemble ${file} What it means
Jasmins.parse(Path) reads a Jasmin assembly (.j) file and feeds it to the ANTLR-based parser. If the parser raises a RecognitionException (invalid Jasmin syntax), parse wraps it in a RuntimeException with the message 'Fail to assemble <file>' and the original exception as cause. This converts a parser error into an unchecked exception that propagates up through Jasmin2JarCmd.
Solutions
- Read the cause (RecognitionException) stack trace for the exact line/column of the syntax error.
- Fix the Jasmin source at the reported line (mnemonic, directive, or operand issue).
- Verify the file is genuine Jasmin assembly and not a class/dex/jar renamed to .j.
- Compare syntax against a known-good .j sample for the dex2jar version in use.
- If needed, catch RuntimeException around Jasmins.parse and report/skip the offending file.
Example fix
// before ireturn 0 // ireturn takes no operand -> RecognitionException // after iconst_0 ireturn
Defensive patterns
Strategy: try-catch
Validate before calling
// Basic sanity check before parsing
if (!file.toString().endsWith(".j") || Files.size(file) == 0) {
throw new IllegalArgumentException("Not a plausible Jasmin source: " + file);
} Try / catch
try {
ClassNode cn = Jasmins.parse(file);
} catch (RuntimeException e) {
Throwable cause = e.getCause(); // RecognitionException with line/column
System.err.println("Syntax error in " + file + ": " + cause.getMessage());
} Prevention
- Lint Jasmin sources against the grammar for your dex2jar version before batch conversion.
- Keep the RecognitionException cause for precise line/column diagnostics.
- Ensure .j files are genuine Jasmin assembly, not renamed binaries.
- Test hand-written assembly against a known-good sample first.
When it happens
Trigger: Calling Jasmins.parse(file) on a .j file containing malformed Jasmin directives, bad instruction mnemonics, or wrong operand syntax that ANTLR cannot recognize; also invoked indirectly when d2j-jasmin2jar processes a directory containing an invalid .j file.
Common situations: Hand-written Jasmin files with typos, files generated for a different assembler syntax, corrupted/renamed non-Jasmin files given a .j extension, or Jasmin grammar differences from the version of dex2jar being used.
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
- cant mix use .param and .parameter on method
- can't pase string
- not support access flags " + name
- can't get owner and type from '"+str+"'
- RecognitionException on invalid annotation element keyword…
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/59512634e63c4e54.
Report an issue: GitHub.
Appendix: source
Thrown at d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmins.java:35
package com.googlecode.d2j.jasmin;
import org.antlr.runtime.ANTLRReaderStream;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.objectweb.asm.tree.ClassNode;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Jasmins {
public static ClassNode parse(Path file) throws IOException {
try (BufferedReader bufferedReader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
return parse(file.toString(), bufferedReader);
} catch (RecognitionException e) {
throw new RuntimeException("Fail to assemble " + file, e);
}
}
public static ClassNode parse(String fileName, Reader bufferedReader) throws IOException, RecognitionException {
ANTLRStringStream is = new ANTLRReaderStream(bufferedReader);
is.name = fileName;
JasminLexer lexer = new JasminLexer(is);
CommonTokenStream ts = new CommonTokenStream(lexer);
JasminParser parser = new JasminParser(ts);
return parser.parse();
}
public static ClassNode parse(String fileName, InputStream is) throws IOException, RecognitionException {
return parse(fileName, new InputStreamReader(is, StandardCharsets.UTF_8));
}
}
View on GitHub (pinned to b5bda4fb49)