Bug 293467 - Mk/Uses/java.mk: add support for JAVA_VERSION=default and JAVA_VERSION=latest
Summary: Mk/Uses/java.mk: add support for JAVA_VERSION=default and JAVA_VERSION=latest
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Package Infrastructure (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-java (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-02-26 16:50 UTC by Dmitry Marakasov
Modified: 2026-02-26 17:41 UTC (History)
2 users (show)

See Also:


Attachments
Patch (2.55 KB, patch)
2026-02-26 16:50 UTC, Dmitry Marakasov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov freebsd_committer freebsd_triage 2026-02-26 16:50:17 UTC
Created attachment 268380 [details]
Patch

Currently, USES=java picks openjdk version inconsistently to what we do for other ecosystems, preferring ancient versions and ignoring value set in bsd.default-versions.mk. Apart from using outdated openjdk, this behavior tends to bring unnecessary numerous openjdk versions to the system (when many java ports with different JAVA_VERSION settings) and leaves maintainers wondering about which JAVA_VERSION to use.

This patch adds support for JAVA_VERSION=default (which translates the the version from bsd.default-version.mk or later) and JAVA_VERSION=latest (which translates to the latest available version).

This change is non-breaking and does not affect existing ports, but allows ports to gradually switch to JAVA_VERSION=default, which will reduce the assortment of required openjdk versions and bring in newer one. In the future I hope that we will switch to it by default.
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2026-02-26 17:13:18 UTC
Check this bug #289858.
IMHO, something like priority would be better.
Comment 2 Vladimir Druzenko freebsd_committer freebsd_triage 2026-02-26 17:23:19 UTC
Also default java just updated to 21 in bug #272855.
Comment 3 Ronald Klop freebsd_committer freebsd_triage 2026-02-26 17:25:12 UTC
I like the idea of your change.
The JAVA_VERSION=latest seems a nice new feature to me.

What I don’t understand, how is JAVA_VERSION=default different from not setting JAVA_VERSION at all?

And do you have an example of “preferring ancient versions and ignoring value set in bsd.default-versions.mk”? I saw a port with JAVA_VERSION=17+ correctly choosing openjdk21 now 21 is the default.
https://www.freshports.org/astro/traccar/
Comment 4 Dmitry Marakasov freebsd_committer freebsd_triage 2026-02-26 17:35:01 UTC
I'm generally against any logic which relies on which ports are installed - this makes behavior inconsistent between different port install orders and between ports and packages, and is still inconsistent to how we handle other ecosystems (and that we do by pinning exact version of e.g. python).

In fact, while my `JAVA_VERSION=default` equals to `JAVA_VERSION=${JAVA_DEFAULT}+` to stay closer to status quo where `X+` are used in most ports, IMO it would make more sense to pin specific version (`JAVA_VERSION=${JAVA_DEFAULT}`) as long as `JAVA_DEFAULT` is being reliably kept up to date.

That said, it doesn't look that these patches are conflicting - my patch is about choosing a version range (effecively limiting it from below), and a patch from 289858 is about picking a version in that range.
Comment 5 Dmitry Marakasov freebsd_committer freebsd_triage 2026-02-26 17:37:09 UTC
(In reply to Ronald Klop from comment #3)
> What I don’t understand, how is JAVA_VERSION=default different from not setting > JAVA_VERSION at all?

Not setting JAVA_VERSION at all currently equals to 8+, which picks openjdk8 if no newer one is installed.
Comment 6 Dmitry Marakasov freebsd_committer freebsd_triage 2026-02-26 17:41:56 UTC
> And do you have an example of “preferring ancient versions and ignoring value set in bsd.default-versions.mk”? I saw a port with JAVA_VERSION=17+ correctly choosing openjdk21 now 21 is the default.

Oh, that seem to have changed just a moment ago.

> Also default java just updated to 21 in bug #272855.

Not sure if either patch is needed any more.