antlr/antlr4 · error · IOException
Could not create checksum {}
Error message
Could not create checksum {} What it means
The inverse delimiter imbalance in split(pattern): more stop delimiters than start delimiters means a stop appeared with no matching start, so 'missing start tag' IllegalArgumentException is thrown. The scanner cannot decide which text belongs to a tag versus literal text when the pairing is broken.
Source
Thrown at antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java:47
MessageDigest complete = MessageDigest.getInstance("MD5");
try {
int n;
do {
n = in.read(buffer);
if (n > 0) {
complete.update(buffer, 0, n);
}
} while (n != -1);
} finally {
in.close();
}
return complete.digest();
} catch (NoSuchAlgorithmException ex) {
throw new IOException("Could not create checksum " + file, ex);
}
}
/**
* Given the source directory File object and the full PATH to a grammar, produce the
* path to the named grammar file in relative terms to the {@code sourceDirectory}.
* This will then allow ANTLR to produce output relative to the base of the output
* directory and reflect the input organization of the grammar files.
*
* @param sourceDirectory The source directory {@link File} object
* @param grammarFileName The full path to the input grammar file
*
* @return The path to the grammar file relative to the source directory
*/
public static String findSourceSubdir(File sourceDirectory, File grammarFile) {
String srcPath = sourceDirectory.getPath() + File.separator;
String path = grammarFile.getPath();
View on GitHub (pinned to 7d5770395b)
Solutions
- Escape literal '>' characters in text chunks with the escape sequence (e.g. \\>).
- Use custom delimiters that do not occur in the target syntax.
- Lint patterns for balanced delimiters before compiling.
Example fix
// before
ParseTreePattern p = m.compile("a > <ID>", R.expr); // stray '>' counts as stop
// after
ParseTreePattern p = m.compile("a \\> <ID>", R.expr); Defensive patterns
Strategy: try-catch
Validate before calling
long starts = pattern.chars().filter(c -> c == '<').count();
long stops = pattern.chars().filter(c -> c == '>').count();
if (starts < stops) throw new IllegalArgumentException("missing start tag: " + pattern); Type guard
boolean hasBalancedTags(String p) {
return p.chars().filter(c -> c=='<').count() == p.chars().filter(c -> c=='>').count();
} Try / catch
try {
pattern = matcher.compile(patternText, ruleIndex);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("missing start tag")) {
patternText = escapeLiteralStops(patternText);
pattern = matcher.compile(patternText, ruleIndex);
} else throw e;
} Prevention
- Escape literal '>' characters in text chunks.
- Choose delimiters absent from the target syntax for comparison-heavy grammars.
- Validate delimiter balance before compile.
When it happens
Trigger: Patterns like "ID> = <ID>" (stray '>' in text), or text containing the stop delimiter character without it being part of a tag.
Common situations: Matching expression grammars whose literal text includes '>' (comparisons, generics-like syntax, arrows '->'); forgetting to escape a literal stop delimiter.
Related errors
- Cannot handle relative paths containing '..'
- expected {} to be prefixed with {}
- index cannot be negative
- missing interface implementation
- Fatal error occured while evaluating the names of the gramma
AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14).
Data as JSON: /api/errors/0a19cc44014e55c2.
Report an issue: GitHub.