Skip to content

Commit 84d426c

Browse files
authored
Add OpenJ9 JDK 21 CI build (#3768)
* Use jfr-polyfill when compiling for/running on OpenJ9 * Disable exception message tests on OpenJ9 JVMs * Disable JFR-related tests on OpenJ9 JVMs * Disable test on OpenJ9 due to Kotlin DSL issues
1 parent f5ec47f commit 84d426c

File tree

21 files changed

+145
-10
lines changed

21 files changed

+145
-10
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
name: Set up Test JDK
22
description: Sets up the JDK required to run platform-tooling-support-tests
3+
inputs:
4+
distribution:
5+
required: true
6+
description: 'The JDK distribution to use'
7+
default: 'temurin'
38
runs:
49
using: "composite"
510
steps:
611
- uses: actions/setup-java@v4
712
with:
8-
distribution: temurin
13+
distribution: ${{ inputs.distribution }}
914
java-version: 8
1015
- shell: bash
1116
run: echo "JDK8=$JAVA_HOME" >> $GITHUB_ENV

.github/workflows/cross-version.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
jdk: [22, 23]
21+
jdk: [ 22, 23 ]
2222
name: "OpenJDK ${{ matrix.jdk }}"
2323
runs-on: ubuntu-latest
2424
steps:
@@ -41,11 +41,44 @@ jobs:
4141
uses: ./.github/actions/run-gradle
4242
with:
4343
arguments: |
44-
-PjavaToolchainVersion=${{ matrix.jdk }}
44+
-PjavaToolchain.version=${{ matrix.jdk }}
4545
-Dscan.tag.JDK_${{ matrix.jdk }}
4646
build
4747
- name: Upload Test Distribution trace files
4848
uses: actions/upload-artifact@v4
4949
with:
5050
name: "Test Distribution trace files (OpenJDK ${{ matrix.jdk }})"
5151
path: '**/build/test-results/*/trace.json'
52+
openj9:
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
jdk: [ 21 ]
57+
name: "OpenJ9 ${{ matrix.jdk }}"
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Check out repository
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 1
64+
- name: Set up Test JDK
65+
uses: ./.github/actions/setup-test-jdk
66+
with:
67+
distribution: semeru
68+
- name: 'Set up JDK ${{ matrix.jdk }}'
69+
uses: actions/setup-java@v4
70+
with:
71+
distribution: semeru
72+
java-version: ${{ matrix.jdk }}
73+
- name: 'Prepare JDK${{ matrix.jdk }} env var'
74+
shell: bash
75+
run: echo "JDK${{ matrix.jdk }}=$JAVA_HOME" >> $GITHUB_ENV
76+
- name: Build
77+
uses: ./.github/actions/run-gradle
78+
with:
79+
arguments: |
80+
-PjavaToolchain.version=${{ matrix.jdk }}
81+
-PjavaToolchain.implementation=j9
82+
-Dscan.tag.JDK_${{ matrix.jdk }}
83+
-Dscan.tag.OpenJ9
84+
build

documentation/documentation.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ dependencies {
6464
because("Jimfs is used in src/test/java")
6565
}
6666

67+
if (java.toolchain.implementation.orNull == JvmImplementation.J9) {
68+
testRuntimeOnly(libs.jfrPolyfill) {
69+
because("OpenJ9 does not include JFR")
70+
}
71+
}
72+
6773
standaloneConsoleLauncher(projects.junitPlatformConsoleStandalone)
6874
}
6975

documentation/src/test/java/example/AssertionsDemo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ void dependentAssertions() {
8585
);
8686
}
8787

88+
// end::user_guide[]
89+
@extensions.DisabledOnOpenJ9
90+
// tag::user_guide[]
8891
@Test
8992
void exceptionTesting() {
9093
Exception exception = assertThrows(ArithmeticException.class, () ->

documentation/src/test/java/example/testkit/EngineTestKitAllEventsDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void verifyAllJupiterEvents() {
6262
message(m -> m.contains("abc does not contain Z")))),
6363
event(test("failingTest"), started()),
6464
event(test("failingTest"), finishedWithFailure(
65-
instanceOf(ArithmeticException.class), message("/ by zero"))),
65+
instanceOf(ArithmeticException.class), message(it -> it.endsWith("by zero")))),
6666
event(container(ExampleTestCase.class), finishedSuccessfully()),
6767
event(engine(), finishedSuccessfully()));
6868
}

documentation/src/test/java/example/testkit/EngineTestKitFailedMethodDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void verifyJupiterMethodFailed() {
3636
.assertThatEvents().haveExactly(1, // <5>
3737
event(test("failingTest"),
3838
finishedWithFailure(
39-
instanceOf(ArithmeticException.class), message("/ by zero"))));
39+
instanceOf(ArithmeticException.class), message(it -> it.endsWith("by zero")))));
4040
}
4141

4242
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2015-2024 the original author or authors.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License v2.0 which
6+
* accompanies this distribution and is available at
7+
*
8+
* https://www.eclipse.org/legal/epl-v20.html
9+
*/
10+
11+
package extensions;
12+
13+
import java.lang.annotation.ElementType;
14+
import java.lang.annotation.Retention;
15+
import java.lang.annotation.RetentionPolicy;
16+
import java.lang.annotation.Target;
17+
18+
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
19+
20+
@Target(ElementType.METHOD)
21+
@Retention(RetentionPolicy.RUNTIME)
22+
@DisabledIfSystemProperty(named = "java.vm.vendor", matches = ".*OpenJ9.*")
23+
public @interface DisabledOnOpenJ9 {
24+
}

documentation/src/test/kotlin/example/KotlinAssertionsDemo.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ class KotlinAssertionsDemo {
3838
assertEquals(0, result)
3939
}
4040

41+
// tag::user_guide[]
4142
@Test
43+
// end::user_guide[]
44+
@extensions.DisabledOnOpenJ9
4245
fun `expected exception testing`() {
4346
val calculator = Calculator()
4447
val exception = assertThrows<ArithmeticException> ("Should throw an exception") {

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ gradle-versions = { module = "com.github.ben-manes:gradle-versions-plugin", vers
4242
groovy4 = { module = "org.apache.groovy:groovy", version = "4.0.21" }
4343
groovy2-bom = { module = "org.codehaus.groovy:groovy-bom", version = "2.5.21" }
4444
hamcrest = { module = "org.hamcrest:hamcrest", version = "2.2" }
45+
jfrPolyfill = { module = "org.gradle.jfr.polyfill:jfr-polyfill", version = "1.0.2" }
4546
jfrunit = { module = "org.moditect.jfrunit:jfrunit-core", version = "1.0.0.Alpha2" }
4647
jimfs = { module = "com.google.jimfs:jimfs", version = "1.3.0" }
4748
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }

gradle/plugins/build-parameters/build.gradle.kts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ buildParameters {
1111
defaultValue = false
1212
fromEnvironment()
1313
}
14-
integer("javaToolchainVersion") {
15-
description = "Defines the Java toolchain version to use for compiling code"
14+
group("javaToolchain") {
15+
description = "Parameters controlling the Java toolchain used for compiling code and running tests"
16+
integer("version") {
17+
description = "JDK version"
18+
}
19+
string("implementation") {
20+
description = "JDK implementation (for example, 'j9')"
21+
}
1622
}
1723
group("documentation") {
1824
description = "Parameters controlling how the documentation is built"

0 commit comments

Comments
 (0)