Skip to content

build(gate): bin/gate and bin/fast run sbt on the JDK CI builds on - #430

Open
rcardin wants to merge 1 commit into
devfrom
build/env-jdk-25
Open

rcardin wants to merge 1 commit into
devfrom
build/env-jdk-25

Conversation

@rcardin

@rcardin rcardin commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Why

The build compiles with -release set to JdkFloor, which is 25, and CI builds on JDK 25. sbt runs on the java on the PATH, and that can be a newer JDK. On a newer JDK the compiler reads only the public API of JDK 25, so it does not see the package private members of JDK classes. Code that CI refuses can then compile locally.

Pull request #426 shows this. A local value name inside an anonymous ClassLoader subclass compiled locally on JDK 26, and bin/gate printed GATE GREEN. CI failed with [E049] Reference to name is ambiguous, because ClassLoader has a package private name(). So the gate did not run what CI runs.

What

  • bin/lib/env.sh reads JdkFloor from project/Toolchain.scala. That is the one source of the version.
  • When the java on the PATH is another JDK, env.sh looks for a JDK of that version in JAVA_HOME, then under the directories in EEZO_JDK_DIRS. The default directories are ~/.sdkman/candidates/java, ~/Library/Java/JavaVirtualMachines, /Library/Java/JavaVirtualMachines and /usr/lib/jvm. It reads the release file of each JDK and needs no other tool. It puts the JDK it finds first on the PATH, sets JAVA_HOME and prints one line about it.
  • When there is no such JDK, env.sh prints a warning on stderr. The warning names the JDK found, the JDK wanted, where it looked, and how to install or select one.
  • bin/fast warns and runs. This is the request.
  • bin/gate refuses to run and prints GATE RED: jdk. EEZO_GATE_ANY_JDK=1 runs it anyway, and the gate then says that its green is not the green of CI.
  • The workflows must keep a copy of the version, because a YAML file cannot read Toolchain. So the build now checks at load that each java-version in .github/workflows equals JdkFloor. This is the same style as the sbt.version check of the examples build.
  • The header of bin/gate, the usage of bin/fast and README Contributing describe the new behaviour.

Why the gate refuses and does not warn

The gate claims one thing: green here is green on the pull request. On another JDK that claim is false, and #426 shows that the gate then gives a wrong answer. A warning is easy to miss in a long log, and agents read only the last line. A refusal makes the last line true. The override keeps the gate usable on a machine that has no JDK 25, and it is explicit. bin/fast is the quick loop and does not claim CI parity, so it only warns.

How to review

  1. bin/lib/env.sh: the JDK block after the ROOT check. The messages are in eezo_jdk_switched and eezo_jdk_warning.
  2. bin/gate: refuse_jdk and the check after env.sh.
  3. project/Toolchain.scala: assertWorkflowJdkMatches, called from Global / onLoad in build.sbt.
  4. GateJdkSuite: each case runs the real bin/fast or bin/gate --dry-run in a temporary checkout, with fake JDKs and a fake sbt on the PATH.

How it was tested

GateJdkSuite in the plugin module runs on both axes of +test. It covers these cases:

  • The JDK 25 is already first on the PATH: no message, PATH and JAVA_HOME stay as they are.
  • A JDK 26 is first on the PATH and a JDK 25 is installed: under sdkman (a JDK 24 next to it is skipped), in JAVA_HOME, or in a macOS Contents/Home bundle. sbt runs on the JDK 25.
  • A JDK 26 is first on the PATH and no JDK 25 is installed: bin/fast warns and runs, bin/gate refuses with exit 1 before any step, and with EEZO_GATE_ANY_JDK=1 the gate runs its steps.
  • Commented lines and scaladoc that mention JdkFloor are not read as the version.
  • The scripts use nothing that the /bin/bash 3.2 of macOS does not have.

On a machine whose default JDK is 26, with a JDK 25 under sdkman:

$ bin/fast 'eval System.getProperty("java.home")'
fast: the java on the PATH is JDK 26 at ~/.sdkman/candidates/java/26-tem, so sbt runs on JDK 25 at ~/.sdkman/candidates/java/25.0.2-open, the JDK CI builds on
[info] ans: String = ~/.sdkman/candidates/java/25.0.2-open

The defect of #426 is now caught locally. A test source with val name = ... in a method, used inside new ClassLoader(...) { ... }, gives this with bin/fast 'core/Test/compile':

[error] -- [E049] Reference Error: .../AmbiguousNameProbe.scala:5:38
[error]   |           Reference to name is ambiguous.

The same source compiles on JDK 26 when no JDK 25 is found, after the warning.

A java-version: "24" in release.yml stops the build at load:

[error] JDK drift: JdkFloor in project/Toolchain.scala is 25, but .github/workflows/release.yml:42 sets up JDK 24, .github/workflows/release.yml:83 sets up JDK 24. Update the workflow by hand to match: CI builds on the JDK that -release names, and bin/gate chooses the same one from JdkFloor.

bin/gate printed GATE GREEN with this change, and its first line was the JDK switch above.

🤖 Generated with Claude Code

The build compiles with -release set to JdkFloor, and CI builds on that
JDK. On a newer JDK the compiler sees only the public API of the older
one, so a name that a package private member of a JDK class makes
ambiguous compiles locally and fails on CI with E049. Pull request 426
was green at the gate and red on CI for this reason.

bin/lib/env.sh now reads JdkFloor from project/Toolchain.scala. When the
java on the PATH is another JDK, it looks for one of the right version
in JAVA_HOME and under the directories of EEZO_JDK_DIRS, which default
to the sdkman candidates, the two macOS JavaVirtualMachines directories
and /usr/lib/jvm, and puts it first on the PATH. When there is none,
bin/fast warns and runs, and bin/gate refuses, since its green would not
be the green of CI. EEZO_GATE_ANY_JDK=1 runs the gate anyway.

The workflows keep a copy of the JDK version, so the build now checks at
load that each java-version in .github/workflows equals JdkFloor, as it
already checks sbt.version for the examples build.

GateJdkSuite runs the scripts in a temporary checkout with fake JDKs and
a fake sbt, on both axes of the plugin build.
@rcardin rcardin added the infra label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant