Class InternalErrorTrigger

java.lang.Object
org.ek9lang.compiler.InternalErrorTrigger

public final class InternalErrorTrigger extends Object
THE way to make the compiler fail INTERNALLY on demand (Steve, 2026-10-08): with -Dek9.internalError.at=<PHASE> on the compiling JVM (a CompilationPhase name, e.g. FULL_RESOLUTION or CODE_GENERATION_AGGREGATES) the compiler throws a plain RuntimeException at the START of that phase, after the phase has been recorded as entered - so the CLI's internal-error report names it, and exits INTERNAL_ERROR_EXIT_CODE (14).

It exists so the end-to-end proof of that report (InternalCompilerErrorE2ETest) does not depend on a source the compiler happens to mishandle today: every such source is a defect waiting to be fixed, and fixing it used to break the test. The property is read ONCE, when this class is loaded, the way ek9.lockMetrics and ek9.absent.strict are read; it is off by default and nothing in EK9 source can reach it. An unknown phase name is refused loudly (an IllegalArgumentException naming the valid ones) rather than silently never firing.

Checked in ONE place, the driver (Ek9Compiler), right after it records a phase as entered - for every phase, READING and PARSING included (Q11) - so the CLI's report names the phase that failed.

The language's own bootstrap compile (Ek9LanguageBootStrap, which runs the front end up to PLUGIN_RESOLUTION over the built-in modules before the developer's source is read) is exempt: the failure lands in the developer's compile, where the program has entered the phase and the report can name it.

  • Field Details

    • PROPERTY

      public static final String PROPERTY
      The JVM system property that names the phase to fail at.
      See Also:
  • Method Details

    • throwIfRequestedAt

      public static void throwIfRequestedAt(CompilationPhase phase)
      Throw the requested internal error if phase is the one named by "ek9.internalError.at".
    • whileBootstrapping

      static boolean whileBootstrapping(BooleanSupplier bootstrapCompile)
      Run the language's bootstrap compile, which the trigger never fires in (see the class comment).
    • phaseNamed

      static CompilationPhase phaseNamed(String value)
      The phase a property value names: null when it is unset or blank, the phase when it is a phase name.