Class Ek9FailureMarker

java.lang.Object
org.ek9lang.compiler.common.Ek9FailureMarker
All Implemented Interfaces:
IntFunction<String>

public final class Ek9FailureMarker extends Object implements IntFunction<String>
THE marker line EK9 writes FIRST on stderr when EK9 ITSELF fails - the CLI, the compiler, or the generated ek9.Main entry point rejecting a program's arguments - e.g. ek9: compilation failed (exit 8). Use it; never format or parse the line elsewhere.

Why (Steve, 2026-10-05, decision C): a program's exit code shares the number space of Ek9ExitCodes. A program may return 3, 8 or 11 - scripts being replaced by EK9 programs need exactly the codes they had, and in production the compiled program runs without the ek9 wrapper - so no code can be reserved, and the number alone can never say whose it is. The marker can: a run whose first stderr line is a marker naming the same code as the exit failed in EK9; a program's own exit (normal, a returned Integer, an uncaught Exception's exitCode, a Panic) never carries one.

Writers: org.ek9lang.commands.CliStderr (the CLI process - it holds stderr so the marker can precede everything else) and MainClassGenerator (the program's entry point, which embeds apply(int) as a constant: 9 and 10 for the arguments, 18 for a URL policy that cannot be loaded, and the CLI's own codes when it refuses its command line - 2 for '-r' with no name, 4 for a program it does not have, 6 for none named among several, 5 for none at all). Readers: the MCP runner (Ek9SubprocessTool, RunProgramTool) through FirstLineFailureCode and WithoutFailureMarker; Ek9FailureMarkerCode reads one line.

"First" means after the JVM's own launcher lines (IsJvmLauncherLine, Picked up JAVA_TOOL_OPTIONS: ...), which no EK9 code can write ahead of; WithoutFailureMarker drops them too.

No statics (Steve, 2026-10-28): this is THE writer - hold an instance and apply the exit code.

  • Field Details

    • PREFIX

      public static final String PREFIX
      Every marker starts with this; it names the tool, as git: or javac: do.
      See Also:
  • Constructor Details

    • Ek9FailureMarker

      public Ek9FailureMarker()
  • Method Details

    • apply

      public String apply(int exitCode)
      The marker for an EK9-owned failure exit, e.g. ek9: compilation failed (exit 8); null for 0 and 1 (not failures) and for any code EK9 does not own.
      Specified by:
      apply in interface IntFunction<String>