=== Improve OpenJDK on FreeBSD

Links: +
link:https://freebsdfoundation.org/project/improving-openjdk-on-freebsd/[Project description] URL: https://freebsdfoundation.org/project/improving-openjdk-on-freebsd/[] +
link:https://github.com/freebsd/openjdk[Project repository] URL: https://github.com/freebsd/openjdk[]

Contact: +
Harald Eilertsen <haraldei@FreeBSD.org> +
FreeBSD Java mailing list <freebsd-java@lists.freebsd.org>

The goal of this project is to improve OpenJDK support for FreeBSD/amd64 and FreeBSD/arm64.

Java is an important runtime environment for many high performance, critical enterprise systems.
Making sure Java based applications run correctly and efficiently on FreeBSD is important to ensure that FreeBSD will continue to be a viable and attractive platform for enterprises, as well as businesses and organizations of all sizes.

In this quarter the following issues/milestones were reached:

* link:https://reviews.freebsd.org/D53326[Released a port] for OpenJDK 25, later link:https://reviews.freebsd.org/D53975[updated to OpenJDK 25.0.1].
  Thanks to Greg Lewis and Kurt Miller for helping.
* Added link:https://kodeknekkeriet.net/en/blog/introducing-flavors-in-openjdk-freebsd/[`headless` and `jre` FLAVORS] to the OpenJDK 25 port.
  This enables building and installing only a headless (no GUI) version of the JDK or just the Java Runtime Environment (no compiler or dev tools).
  It is also possible to combine these to only install a `headless-jre` variant.
  This is useful in server environments, or other resource constrained environments where the full JDK and tools are not necessary.
  The plan is to extend these FLAVORS to the remaining OpenJDK ports as well.
* Submitted link:https://bugs.openjdk.org/browse/JDK-8371637[a fix upstream] that fixed invalid memory alignment on systems using `jemalloc`, or other allocators that do not use the link:https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2293.htm[strong alignment interpretation] of the C standard alignment requirements.
  This caused problems when allocating small off-heap memory segments using the `java.lang.foreign.Arena` API on FreeBSD.
  This fix will be included in OpenJDK 26.
* Deprecated OpenJDK ports link:https://reviews.freebsd.org/D54176[no longer supported] by upstream.
  The ports will expire and be removed throughout the first half of 2026, leaving the LTS versions and the latest maintained ports behind.

Other notes:

* Spent some time digging into link:https://github.com/battleblow/jdk25u/pull/4[the history of `getrlimitusage(2)` system call] discovering it was available since version 14.2 despite the man page saying it first appeared in version 15.
  See also link:https://reviews.freebsd.org/D53320[related review by emaste].
  This was relevant because link:https://www.freebsd.org/status/report-2025-07-2025-09/#_improve_openjdk_on_freebsd[the performance improvements from previous quarter] relies on this system call.
  Knowing that it is available for all currently maintained versions of FreeBSD, means we do not need to keep code to fall back to less efficient ways of obtaining the same information.
* Updates made to the Mac OS X implementation of the Hotspot Serviceability Agent debugging facility broke the BSD implementation.
  Due to history, these implementations share the same source files and directories despite being somewhat different implementations.
  Work link:https://bugs.openjdk.org/browse/JDK-8374372[has been started] on moving the OS X code to it's own implementation, so that we can work on the BSD implementation without having to step on each others toes.
* Work on changing the way we bootstrap OpenJDK builds in the ports system has been resumed.
  This work is more relevant again as deprecating unmaintained ports breaks the previous assumption that you could depend on the previous OpenJDK version to build the current version.
  The new bootstrapping mechanism must be in place before actually expiring the existing ports.
* I lost access to my Aarch64 test system in the beginning of this quarter, so I have not been able to test as well as I want on that architecture.
  This situation is now remedied, and I am in the process of getting the new system set up for building and testing.

Sponsor: The FreeBSD Foundation
