Skip to content

java: default to Temurin, keep Azul as the fallback - #305

Merged
eirikb merged 4 commits into
mainfrom
feature/eirikb/temurin-default-distribution
Jul 28, 2026
Merged

java: default to Temurin, keep Azul as the fallback#305
eirikb merged 4 commits into
mainfrom
feature/eirikb/temurin-default-distribution

Conversation

@eirikb

@eirikb eirikb commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Switches the default JDK distribution from Azul to Temurin, and fixes the selection bugs that turned up while verifying it.

Why Temurin

Temurin is the most-used OpenJDK build by a wide margin (308M docker pulls vs Zulu's 30M) and api.adoptium.net is a documented, versioned API. Azul's is a WordPress admin-ajax.php endpoint that returns 6.2MB in ~9s and, when it hands back anything but JSON, panicked the whole run - that alone accounted for a chunk of our red CI.

Adoptium doesn't publish the older feature releases, so java@14 would 404. Azul stays as the fallback, which keeps java@14 and the README examples working. An explicit -azul/-tem is left alone.

Also fetches all available releases instead of just LTS + newest, so java@20 resolves at all, and takes the lts tag and the offline fallback list from the API rather than a hardcoded [8, 11, 17, 21] that had gone stale. That's 13 versions instead of 6, so the requests run concurrently rather than one after the other.

Fixes that came out of it

java@-jdk+jre never worked - it's in the README and help output, and it was broken on main too, so this part isn't fallout from the switch. Three things had to line up: Adoptium publishes jre images and we discarded them; -jdk parses into the distribution slot because the syntax is shared with java@-temurin; and defaults are required tags, so a dropped one has to leave that set or the request demands jre and jdk at once.

Cache path ignored the distribution. Once -jdk meant something, java and java@-jdk shared a directory and a plain java could hand you a JRE with no javac. Distribution is part of the path now, which also stops java@17-azul and java@17-temurin aliasing (that one predates this branch).

The fallback only checked the version, but tags are applied later. Temurin carries none of the +fx/+headless/+sts that only Azul publishes, so java@+fx failed outright instead of falling back. It now asks get_url_matches, the same predicate that makes the final call.

Azul no longer panics on a bad response, and an empty fallback no longer discards a usable Temurin list.

Verification

161 unit tests pass. Verified cold on Linux x86_64 - each lands in its own cache dir, and only the JDK ones carry javac:

selector result
java Temurin JDK
java@-jdk Temurin JRE
java@-jdk+jre Temurin JRE
java@+fx Zulu 26.32 (fallback)
java@14 Zulu 14.29 (fallback)
java@-temurin Temurin JDK

Known gaps

  • needs_fallback isn't unit-testable as written (the distribution handler is a bare fn field), so that decision is only covered end-to-end.
  • zulu isn't registered as an alias for azul, so java@-zulu resolves to Temurin. .sdkmanrc files spell it that way, so worth deciding before this lands.
  • Per-version Temurin fan-out failures are still swallowed silently.

eirikb added 4 commits July 27, 2026 15:30
Temurin is the most-used OpenJDK build by a wide margin (308M docker
pulls vs Zulu's 30M) and api.adoptium.net is a documented, versioned
API. Azul's is a WordPress admin-ajax endpoint that returns 6.2MB in
~9s and, when it hands back anything but JSON, panics the whole run -
that alone accounts for a chunk of our red CI.

Adoptium doesn't publish the older feature releases though, so java@14
would 404. Fall back to Azul when the default can't satisfy a version,
which keeps java@14 and the README examples working. An explicit
-azul/-tem is left alone.

Also fetch all available releases instead of just LTS + newest, so
java@20 resolves at all, and take the lts tag and the offline fallback
list from the API rather than a hardcoded [8, 11, 17, 21] that had gone
stale. That's 13 versions instead of 6, so the requests now run
concurrently rather than one after the other.
An unreachable api.adoptium.net comes back as an empty download list rather
than an error. A versioned request already coped - nothing matches, so Azul
takes over - but a bare `java` has no version to check against and fell
straight through to an empty list. Azul used to be the default, so that case
never had a way to fail before this branch; treat empty as unsatisfiable too.

The fallback itself had no coverage: the existing java tests only exercise
.java-version / .sdkmanrc parsing. Pin the default distribution, that the
fallback name still resolves, and has_matching_version around the cases that
drive it - java@14 missing from Adoptium, an empty list, and downloads with
no parseable version.
…serve

`java@-jdk+jre` is in the README and the help output, and it has been broken for
a while - on main too, so this is not fallout from the Temurin switch. Three
things had to line up:

Adoptium publishes jre images and we threw them away, so keep them and let the
image_type tag decide. `-jdk` parses into the distribution slot, because the
syntax is shared with `java@-temurin`, so a name that is not a registered
distribution is now read as the tag removal it was meant to be. And defaults are
required tags, so a dropped one has to leave that set as well, or the request
asks for jre while still demanding jdk and matches nothing.

That gives `-jdk` real meaning, which the cache path did not know about - it is
built from tags only, so `java` and `java@-jdk` shared a directory and a plain
`java` could hand you a JRE with no javac. Distribution goes into the path now,
which also stops `java@17-azul` and `java@17-temurin` aliasing.

The Azul fallback was decided on version alone, but tags are applied later.
Temurin carries none of the +fx/+headless/+sts that only Azul publishes, so
`java@+fx` failed outright instead of falling back. Ask get_url_matches, the
same predicate that makes the final call. While Azul is on the automatic path,
drop the unwrap/expect too - admin-ajax.php answering with HTML should not
panic a run Temurin could have served - and keep the Temurin list when the
fallback comes back empty.

Verified cold on Linux x86_64: java, java@-jdk, java@-jdk+jre, java@+fx,
java@14 and java@-temurin all resolve, land in six distinct cache dirs, and
only the JDK ones carry javac.
@eirikb
eirikb enabled auto-merge (squash) July 28, 2026 13:07
@eirikb
eirikb merged commit 42c866d into main Jul 28, 2026
702 of 708 checks passed
@eirikb
eirikb deleted the feature/eirikb/temurin-default-distribution branch July 28, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant