diff --git a/openjdk-24.yaml b/openjdk-24.yaml new file mode 100644 index 00000000000..cf37fbce6c8 --- /dev/null +++ b/openjdk-24.yaml @@ -0,0 +1,286 @@ +package: + name: openjdk-24 + version: 24 + epoch: 0 + description: OpenJDK 24 Early Access Package + copyright: + - license: GPL-2.0-or-later + dependencies: + runtime: + - openjdk-24-jre + provides: + - java-ea=24 + +environment: + contents: + packages: + - alsa-lib-dev + - autoconf + - automake + - bash + - build-base + - busybox + - ca-certificates-bundle + - cups-dev + - file + - fontconfig-dev + - freetype-dev + - giflib-dev + - lcms2-dev + - libffi-dev + - libjpeg-turbo-dev + - libx11-dev + - libxext-dev + - libxi-dev + - libxrandr-dev + - libxrender-dev + - libxt-dev + - libxtst-dev + - openjdk-23 + - openjdk-23-default-jvm + - zip + environment: + # This is needed to work around the error date 1970-01-01T00:00:00Z is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z + SOURCE_DATE_EPOCH: 315532900 + +pipeline: + - uses: git-checkout + with: + repository: https://github.com/openjdk/jdk + tag: jdk-${{package.version}}+16 + expected-commit: c58fbef05eace85a2e429da1ac8ff1ae09a0b736 + + - working-directory: /home/build/googletest + pipeline: + - uses: fetch + with: + uri: https://github.com/google/googletest/archive/v1.14.0.tar.gz + expected-sha512: 765c326ccc1b87a01027385e69238266e356361cd4ee3e18e3c9d137a5d11fa5d657c164d02dd1be8fe693c8e10f2b580588dbfa57d27f070e2750f50d3e662c + + - runs: chmod +x configure + + # Note that despite using --with-extra-cflags, --with-extra-cxxflags, and + # --with-extra-ldflags, the configure still produces warnings like: + # https://github.com/wolfi-dev/os/issues/18747 + - uses: autoconf/configure + with: + opts: | + --with-extra-cflags="$CFLAGS" \ + --with-extra-cxxflags="$CXXFLAGS" \ + --with-extra-ldflags="$LDFLAGS" \ + --with-boot-jdk=/usr/lib/jvm/java-23-openjdk \ + --prefix=/usr/lib/jvm/java-24-openjdk \ + --with-vendor-name=wolfi \ + --with-vendor-url=https://wolfi.dev \ + --with-vendor-bug-url=https://github.com/wolfi-dev/os/issues \ + --with-version-opt="wolfi-r${{package.epoch}}" \ + --disable-warnings-as-errors \ + --disable-precompiled-headers \ + --enable-dtrace=no \ + --with-zlib=system \ + --with-debug-level=release \ + --with-native-debug-symbols=internal \ + --with-jvm-variants=server \ + --with-jtreg=no \ + --with-libpng=system \ + --with-jvm-variants=server \ + --with-libjpeg=system \ + --with-giflib=system \ + --with-lcms=system \ + --with-gtest="/home/build/googletest" \ + --with-version-pre="no" \ + --with-version-string="" + + - runs: make jdk-image legacy-jre-image + + # Check we built something valid + - runs: | + _java_bin="./build/*-server-release/images/jdk/bin" + + $_java_bin/javac -d . HelloWorld.java + $_java_bin/java HelloWorld + + # NOTE: Disable flakey tests for now as we're seeing builds hang on aarch64 + # # run the gtest unittest suites + # make test-hotspot-gtest + + - runs: | + _java_home="usr/lib/jvm/java-24-openjdk" + + mkdir -p "${{targets.destdir}}"/$_java_home + cp -r build/*-server-release/images/jdk/* "${{targets.destdir}}"/$_java_home + rm "${{targets.destdir}}"/$_java_home/lib/src.zip + +subpackages: + - name: "${{package.name}}-dbg" + description: "OpenJDK 24 Java Debug Symbols" + pipeline: + - uses: split/debug + dependencies: + runtime: + - ${{package.name}} + + - name: "${{package.name}}-jre" + description: "OpenJDK 24 Java Runtime Environment" + dependencies: + runtime: + - ${{package.name}}-jre-base + - alsa-lib + - freetype + - giflib + - libfontconfig1 + - libjpeg-turbo + - libx11 + - libxext + - libxi + - libxrender + - libxtst + - ttf-dejavu + pipeline: + - runs: | + _java_home="usr/lib/jvm/java-24-openjdk" + + mkdir -p "${{targets.subpkgdir}}"/$_java_home/lib + mv "${{targets.destdir}}"/$_java_home/lib/libawt_xawt.so \ + "${{targets.destdir}}"/$_java_home/lib/libfontmanager.so \ + "${{targets.destdir}}"/$_java_home/lib/libjavajpeg.so \ + "${{targets.destdir}}"/$_java_home/lib/libjawt.so \ + "${{targets.destdir}}"/$_java_home/lib/libjsound.so \ + "${{targets.destdir}}"/$_java_home/lib/liblcms.so \ + "${{targets.destdir}}"/$_java_home/lib/libsplashscreen.so \ + "${{targets.subpkgdir}}"/$_java_home/lib + + - name: "${{package.name}}-jre-base" + description: "OpenJDK 24 Java Runtime Environment (headless)" + dependencies: + runtime: + - java-common + - java-cacerts + pipeline: + - runs: | + _java_home="usr/lib/jvm/java-24-openjdk" + + mkdir -p "${{targets.subpkgdir}}"/$_java_home + mv "${{targets.destdir}}"/$_java_home/lib \ + "${{targets.subpkgdir}}"/$_java_home + + mkdir -p "${{targets.subpkgdir}}"/$_java_home/bin + for i in java \ + jfr \ + jrunscript \ + jwebserver \ + keytool \ + rmiregistry; do + mv "${{targets.destdir}}"/$_java_home/bin/$i "${{targets.subpkgdir}}"/$_java_home/bin/$i + done + + mv "${{targets.destdir}}"/$_java_home/legal "${{targets.subpkgdir}}"/$_java_home + mv "${{targets.destdir}}"/$_java_home/conf "${{targets.subpkgdir}}"/$_java_home + mv "${{targets.destdir}}"/$_java_home/release "${{targets.subpkgdir}}"/$_java_home + cp ASSEMBLY_EXCEPTION \ + LICENSE \ + README.md \ + "${{targets.subpkgdir}}"/$_java_home + + # symlink to shared java cacerts store + rm -f "${{targets.subpkgdir}}"/$_java_home/lib/security/cacerts + ln -sf /etc/ssl/certs/java/cacerts \ + "${{targets.subpkgdir}}"/$_java_home/lib/security/cacerts + + # symlink for `java-common` to work (which expects jre in $_java_home/jre) + ln -sf . "${{targets.subpkgdir}}/$_java_home/jre" + + - name: "${{package.name}}-jmods" + description: "OpenJDK 24 jmods" + dependencies: + provides: + - openjdk-jmods=${{package.full-version}} + pipeline: + - runs: | + mkdir -p "${{targets.subpkgdir}}"/usr/lib/jvm/java-24-openjdk + mv "${{targets.destdir}}"/usr/lib/jvm/java-24-openjdk/jmods \ + "${{targets.subpkgdir}}"/usr/lib/jvm/java-24-openjdk + + - name: "${{package.name}}-doc" + description: "OpenJDK 24 Documentation" + pipeline: + - runs: | + mkdir -p "${{targets.subpkgdir}}"/usr/lib/jvm/java-24-openjdk + mv "${{targets.destdir}}"/usr/lib/jvm/java-24-openjdk/man \ + "${{targets.subpkgdir}}"/usr/lib/jvm/java-24-openjdk + + - name: "${{package.name}}-demos" + description: "OpenJDK 24 Demos" + pipeline: + - runs: | + mkdir -p "${{targets.subpkgdir}}"/usr/lib/jvm/java-24-openjdk + mv "${{targets.destdir}}"/usr/lib/jvm/java-24-openjdk/demo \ + "${{targets.subpkgdir}}"/usr/lib/jvm/java-24-openjdk + + - name: "${{package.name}}-default-jvm" + description: "Use the openjdk-24 JVM as the default JVM" + dependencies: + runtime: + - ${{package.name}}-jre + provides: + - default-jvm=1.24 + pipeline: + - runs: | + mkdir -p "${{targets.subpkgdir}}"/usr/lib/jvm + ln -sf java-24-openjdk "${{targets.subpkgdir}}"/usr/lib/jvm/default-jvm + + - name: "${{package.name}}-default-jdk" + description: "Use the openjdk-24 JVM as the default JVM with the JDK installed" + dependencies: + runtime: + - ${{package.name}}-default-jvm + - ${{package.name}} + provides: + - default-jdk=1.24 + +update: + enabled: false + exclude-reason: Open JDK 24 is currently in development, the goal for this package is to provide early access to builds. + +test: + environment: + contents: + packages: + - openjdk-24-default-jdk + - openjdk-24-jmods + environment: + JAVA_HOME: /usr/lib/jvm/java-24-openjdk + pipeline: + # Test a basic Hello World + - working-directory: basic + runs: | + javac HelloWorld.java + java HelloWorld | grep -qi "Hello World!" + # Test a basic HTTP connection + - working-directory: basic + runs: | + javac RequestTest.java + java RequestTest | grep -qi "Successfully connected to example.org" + # Test modules + - working-directory: advanced/module-project + runs: | + mkdir output + javac -d output --module-source-path modules $(find modules -name "*.java") + + # Create a jar with the compiled classes + jar --verbose --create --file app.jar \ + --main-class dev.chainguard.module.main.Main \ + --module-version 1.0 \ + -C output/test.modules . \ + -C output/main.app . + + # Test the jar + java -jar app.jar + + # Test jlink + jlink --verbose --module-path "app.jar:$JAVA_HOME/jmods" \ + --add-modules test.modules \ + --output test-project-jre + + # Test custom JRE + test-project-jre/bin/java -jar app.jar diff --git a/openjdk-24/HelloWorld.java b/openjdk-24/HelloWorld.java new file mode 100644 index 00000000000..0be813a1901 --- /dev/null +++ b/openjdk-24/HelloWorld.java @@ -0,0 +1,3 @@ +public class HelloWorld { + public static void main(String[] args) { System.out.println("Hello World!"); } +} diff --git a/openjdk-24/advanced/module-project/modules/main.app/dev/chainguard/module/main/Main.java b/openjdk-24/advanced/module-project/modules/main.app/dev/chainguard/module/main/Main.java new file mode 100644 index 00000000000..619229be6f0 --- /dev/null +++ b/openjdk-24/advanced/module-project/modules/main.app/dev/chainguard/module/main/Main.java @@ -0,0 +1,9 @@ +package dev.chainguard.module.main; + +import dev.chainguard.module.test.Test; + +public class Main { + public static void main(String[] args) { + Test.doTest(); + } +} diff --git a/openjdk-24/advanced/module-project/modules/main.app/module-info.java b/openjdk-24/advanced/module-project/modules/main.app/module-info.java new file mode 100644 index 00000000000..67c64ffd80c --- /dev/null +++ b/openjdk-24/advanced/module-project/modules/main.app/module-info.java @@ -0,0 +1,3 @@ +module main.app { + requires test.modules; +} diff --git a/openjdk-24/advanced/module-project/modules/test.modules/dev.chainguard.module.test/Test.java b/openjdk-24/advanced/module-project/modules/test.modules/dev.chainguard.module.test/Test.java new file mode 100644 index 00000000000..5d774d146e2 --- /dev/null +++ b/openjdk-24/advanced/module-project/modules/test.modules/dev.chainguard.module.test/Test.java @@ -0,0 +1,7 @@ +package dev.chainguard.module.test; + +public class Test { + public static void doTest() { + System.out.println("testing a module output"); + } +} diff --git a/openjdk-24/advanced/module-project/modules/test.modules/module-info.java b/openjdk-24/advanced/module-project/modules/test.modules/module-info.java new file mode 100644 index 00000000000..20ff609f225 --- /dev/null +++ b/openjdk-24/advanced/module-project/modules/test.modules/module-info.java @@ -0,0 +1,3 @@ +module test.modules { + exports dev.chainguard.module.test; +} diff --git a/openjdk-24/basic/HelloWorld.java b/openjdk-24/basic/HelloWorld.java new file mode 100644 index 00000000000..0be813a1901 --- /dev/null +++ b/openjdk-24/basic/HelloWorld.java @@ -0,0 +1,3 @@ +public class HelloWorld { + public static void main(String[] args) { System.out.println("Hello World!"); } +} diff --git a/openjdk-24/basic/RequestTest.java b/openjdk-24/basic/RequestTest.java new file mode 100644 index 00000000000..3e7e7c9ad91 --- /dev/null +++ b/openjdk-24/basic/RequestTest.java @@ -0,0 +1,26 @@ +import javax.management.RuntimeErrorException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; + +public class RequestTest { + public static void main(String[] args) throws Exception { + // Remote connections can flake, so try a few times + int attempt = 0; + while (true) { + URL url = new URL("http://example.org"); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { + break; + } + + Thread.sleep(5000); // 5 seconds in millis is 5000 + + if (attempt++ >= 5) { + throw new RuntimeException("Failed to check connection to example.org"); + } + } + + System.out.println("Successfully connected to example.org"); + } +}