From bcc43eed5c2060d2fc56ca5f3b938f5e044eab31 Mon Sep 17 00:00:00 2001 From: Tom Tourwe Date: Fri, 16 Oct 2026 16:25:02 +0200 Subject: [PATCH] Translators: a printer's AssertionError is recorded as a crash, as the 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 Claude-Session: https://claude.ai/code/session_01A33UTsWTyE5kyknvBfqHC5 Signed-off-by: Tom Tourwe --- .../io/codelaser/maddi/cst/print/csharp/CSharpTranslator.java | 2 +- .../io/codelaser/maddi/cst/print/kotlin/KotlinTranslator.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maddi-cst-print-csharp/src/main/java/io/codelaser/maddi/cst/print/csharp/CSharpTranslator.java b/maddi-cst-print-csharp/src/main/java/io/codelaser/maddi/cst/print/csharp/CSharpTranslator.java index 13b8754f9..4bffc73ca 100644 --- a/maddi-cst-print-csharp/src/main/java/io/codelaser/maddi/cst/print/csharp/CSharpTranslator.java +++ b/maddi-cst-print-csharp/src/main/java/io/codelaser/maddi/cst/print/csharp/CSharpTranslator.java @@ -73,7 +73,7 @@ public static Result translate(Runtime runtime, List types, CSharpProg Files.createDirectories(file.getParent()); Files.writeString(file, formatter.write(result.output()) + "\n"); files.add(file.toAbsolutePath().normalize()); - } catch (RuntimeException | StackOverflowError e) { + } catch (RuntimeException | AssertionError | StackOverflowError e) { // the frames where it happened: a StackOverflowError's top frames are its cycle StackTraceElement[] trace = e.getStackTrace(); crashes.add(type.fullyQualifiedName() + ": " + e + Arrays.stream(trace).limit(12) diff --git a/maddi-cst-print-kotlin/src/main/java/io/codelaser/maddi/cst/print/kotlin/KotlinTranslator.java b/maddi-cst-print-kotlin/src/main/java/io/codelaser/maddi/cst/print/kotlin/KotlinTranslator.java index e87128acb..452d68c94 100644 --- a/maddi-cst-print-kotlin/src/main/java/io/codelaser/maddi/cst/print/kotlin/KotlinTranslator.java +++ b/maddi-cst-print-kotlin/src/main/java/io/codelaser/maddi/cst/print/kotlin/KotlinTranslator.java @@ -62,7 +62,7 @@ public static Result translate(Runtime runtime, List types, KotlinPrin Files.createDirectories(file.getParent()); Files.writeString(file, kotlin); files.add(file.toAbsolutePath().normalize()); - } catch (RuntimeException | StackOverflowError e) { + } catch (RuntimeException | AssertionError | StackOverflowError e) { crashes.add(type.fullyQualifiedName() + ": " + e); } }