Class DirectiveUpdateSink

java.lang.Object
org.ek9lang.compiler.directives.DirectiveUpdateSink

public final class DirectiveUpdateSink extends Object
THE shared sink for directive-test @IR/@IR_PARAMETERISED/@LLVM/@BYTECODE UPDATE blocks emitted by the directive listeners when a golden mismatches.

When the system property ek9.directive.update.file is set, the UPDATE blocks are written (append) to that file under a single shared lock; otherwise they fall back to System.err (legacy behaviour).

WHY this exists: the per-line failure diagnostic (LineByLineComparator -> System.err) and general test output share the console streams with the UPDATE blocks. Java's System.out/System.err are independently buffered and (under parallel test execution) written concurrently, so the diagnostic text interleaves character-by-character INTO the UPDATE blocks — corrupting the auto-update scripts' input for multi-file directive tests, which then mangle a few golden files. Routing the blocks to a dedicated file (one clean, lock-synchronised stream, no diagnostics) makes the regen reliable. ALL directive listeners MUST emit their UPDATE block through out() under lock().

Usage from a test/regen run: -Dek9.directive.update.file=/tmp/updates.txt; feed that file to the update_*_directives.py script.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    The single lock every listener synchronises its whole-block emission on, so blocks from different listeners (IR / LLVM / BYTECODE) can never interleave with each other in the update-file.
    out()
    The stream to emit UPDATE blocks to: the configured ek9.directive.update.file (opened once, append, auto-flush), or System.err as the legacy fallback when the property is unset or the file cannot be opened.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • lock

      public static Object lock()
      The single lock every listener synchronises its whole-block emission on, so blocks from different listeners (IR / LLVM / BYTECODE) can never interleave with each other in the update-file.
    • out

      public static PrintStream out()
      The stream to emit UPDATE blocks to: the configured ek9.directive.update.file (opened once, append, auto-flush), or System.err as the legacy fallback when the property is unset or the file cannot be opened. Callers MUST hold lock() around the full block.