JEP 386: Alpine Linux Port

OwnerBoris Ulasevich
TypeFeature
ScopeImplementation
StatusClosed / Delivered
Release16
Componenthotspot / runtime
Discussionportola dash dev at openjdk dot java dot net
EffortM
DurationM
Reviewed byAlan Bateman, Vladimir Kozlov
Endorsed byMikael Vidstedt
Created2019/08/13 10:33
Updated2024/08/02 14:44
Issue8229469

Summary

Port the JDK to Alpine Linux, and to other Linux distributions that use musl as their primary C library, on both the x64 and AArch64 architectures,

Motivation

Musl is an implementation, for Linux-based systems, of the standard library functionality described in the ISO C and POSIX standards. Several Linux distributions including Alpine Linux and OpenWrt are based on musl, while some others provide an optional musl package (e.g., Arch Linux).

The Alpine Linux distribution is widely adopted in cloud deployments, microservices, and container environments due to its small image size. A Docker base image for Alpine Linux, for example, is less than 6 MB. Enabling Java to run out-of-the-box in such settings will allow Tomcat, Jetty, Spring, and other popular frameworks to work in such environments natively.

By using jlink (JEP 282) to reduce the size of the Java runtime, a user will be able to create an even smaller image targeted to run a specific application. The set of modules required by an application can be determined via the jdeps command. For example, if a target application depends only on the java.base module then a Docker image with Alpine Linux and a Java runtime with just that module and the server VM fits in 38 MB.

The same motivation applies to embedded deployments, which also have size constraints.

Description

This JEP intends to integrate the Portola Project upstream.

This port will not support the attach mechanism of the HotSpot Serviceability Agent.

To build a musl variant of the JDK on Alpine Linux, the following packages are required:

alpine-sdk alsa-lib alsa-lib-dev autoconf bash cups-dev cups-libs fontconfig fontconfig-dev freetype freetype-dev grep libx11 libx11-dev libxext libxext-dev libxrandr libxrandr-dev libxrender libxrender-dev libxt libxt-dev libxtst libxtst-dev linux-headers zip

Once these packages are installed, the JDK build process works as usual.

Musl ports for other architectures may be implemented in follow-up enhancements, if there is demand.

Alternatives

Testing