Skip to content

Translators: a printer's AssertionError is recorded as a crash, as the other errors are - #143

Merged
bnaudts merged 1 commit into
develfrom
fix/translators-catch-assertion-error
Oct 16, 2026
Merged

bnaudts merged 1 commit into
develfrom
fix/translators-catch-assertion-error

Conversation

@tomtourwe

@tomtourwe tomtourwe commented Oct 16, 2026 •

Copy link
Copy Markdown

What

KotlinTranslator and CSharpTranslator record a crash of the printer on one compilation unit and go on with the others. They catch RuntimeException and StackOverflowError, but not AssertionError:

} catch (RuntimeException | StackOverflowError e) {                    // before
} catch (RuntimeException | AssertionError | StackOverflowError e) {   // after

When the JVM runs with assertions enabled (-ea, as the tests do), an assertion that fails while one unit is printed escaped and ended the whole translation, instead of being recorded as a crash of that unit as the class documentation describes ("A crash of the printer on one compilation unit is recorded and the others go on").

Consistency

In devel (1ce51a4), these two catches are the only ones that take StackOverflowError without AssertionError. Every other such catch, 22 in 10 files, takes all three: catch (RuntimeException | AssertionError | StackOverflowError e). This PR makes the translators consistent with them:

File Lines
maddi-cst-print-kotlin/.../KotlinNullability.java 211, 414
maddi-inspection-openjdk/.../JavaInspectorImpl.java 568, 1067
maddi-inspection-parser/.../ResolverImpl.java 143, 152, 163, 170
maddi-java-bytecode/.../ByteCodeInspectorImpl.java 265
maddi-java-openjdk/.../ClassSymbolScanner.java 2609
maddi-java-openjdk/.../ScanCompilationUnit.java 369, 462, 1155, 2191, 3258
maddi-java-openjdk/.../ScanCompilationUnits.java 324, 343, 496, 684
maddi-java-parser/.../ParseTypeDeclaration.java 117
maddi-run-main/.../RunAnalyzer.java 226
maddi-run-openjdk/.../RunAnalyzer.java 298 (the runner that calls these translators)

After this PR, no catch in maddi takes StackOverflowError without AssertionError.

Effect to be aware of

With assertions enabled, the J2K and J2C# ratchets (which call these translators) now count such a failure as a crash of that unit instead of failing. Without -ea nothing changes.

Not built locally; two-line change.

🤖 Generated with Claude Code

…e other errors are

KotlinTranslator and CSharpTranslator record a crash of the printer on one compilation unit and go on
with the others, for a RuntimeException and a StackOverflowError. An AssertionError, thrown when the JVM
runs with assertions enabled (-ea, as the tests do), escaped instead and ended the whole translation.
Elsewhere in maddi, a catch that takes StackOverflowError takes AssertionError too (KotlinNullability,
JavaInspectorImpl, ResolverImpl).

With assertions enabled, the J2K and J2C# ratchets now count such a failure as a crash of that unit
instead of failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A33UTsWTyE5kyknvBfqHC5
Signed-off-by: Tom Tourwe <Tom.Tourwe@codelaser.io>
@bnaudts
bnaudts merged commit e85f661 into devel Oct 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants