antlr/antlr4 · critical · Error

ANTLR ErrorManager panic

Error message

ANTLR ErrorManager panic

What it means

ErrorManager.panic() throws java.lang.Error('ANTLR ErrorManager panic') as the static, tool-independent abort for the error manager. The comment in source explains it cannot call tool.panic because multiple Tool instances may share one error manager. It signals a fatal, non-recoverable error condition during tool execution.

Source

Thrown at tool/src/org/antlr/v4/tool/ErrorManager.java:314

	public void panic(ErrorType errorType, Object... args) {
		ToolMessage msg = new ToolMessage(errorType, args);
		ST msgST = getMessageTemplate(msg);
		String outputMsg = msgST.render();
		if ( formatWantsSingleLineMessage() ) {
			outputMsg = outputMsg.replace('\n', ' ');
		}
		panic(outputMsg);
	}

	public static void panic(String msg) {
		rawError(msg);
		panic();
	}

    public static void panic() {
        // can't call tool.panic since there may be multiple tools; just
        // one error manager
        throw new Error("ANTLR ErrorManager panic");
    }
}

View on GitHub (pinned to 7d5770395b)

Solutions

  1. Look at the raw error message printed just before the panic — it names the real failure
  2. Verify the antlr4 tool jar is intact and versions are consistent
  3. Minimize the grammar and report if the panic reproduces on the current release
Defensive patterns

Strategy: try-catch

Try / catch

try { /* tool invocation */ } catch (Error e) { if ("ANTLR ErrorManager panic".equals(e.getMessage())) { /* fatal tool error; inspect logged raw error above */ } }

Prevention

When it happens

Trigger: Fatal error paths in ErrorManager (e.g. panic(msg) after rawError), format-string/internal errors while emitting messages, or direct calls to ErrorManager.panic().

Common situations: Malformed message formatting resources, corrupted tool distribution, or bug-level conditions while processing broken grammars.

Related errors


AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14). Data as JSON: /api/errors/2a99f992ded7e950. Report an issue: GitHub.