From 7db64531e9ccbf88aa891fe69439267fe730b5a3 Mon Sep 17 00:00:00 2001 From: vladimirg Date: Thu, 15 Oct 2026 14:18:02 +0000 Subject: [PATCH] fix(build): add --add-opens JVM args to test task **Which sample(s) or area?** Build (build.gradle) **What changed?** - Added the `--add-opens` JVM args to the `test` task. - Extracted the args shared by `execute` and `test` into `addOpensArgs`. **Why?** On JDK 17 `./gradlew build` failed in `:test` with InaccessibleObjectException (the Cadence client reflects into java.base) and the test run then hung. The `execute` task already had these flags. **How did you test it?** - `./gradlew build` on JDK 17: BUILD SUCCESSFUL. - Manual run, following the README: 1. Start Cadence Server (compose file from the README): `docker-compose up` 2. Register the domain. This is required once: without it the sample fails with `Domain samples-domain does not exist`: `./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain` 3. Run the sample, which prints `Hello World!`: `./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloActivity` **Potential risks** None expected; the flags only affect the test JVM. **Release notes** N/A **Documentation Changes** N/A Signed-off-by: vladimirg --- build.gradle | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index dc31b6e9..8dfbd5a8 100644 --- a/build.gradle +++ b/build.gradle @@ -58,11 +58,19 @@ compileJava { options.warnings = false } +def addOpensArgs = [ + '--add-opens=java.base/java.lang=ALL-UNNAMED', // Upgrade to Java 21 + '--add-opens=java.base/java.time=ALL-UNNAMED', // Upgrade to Java 21 +] + task execute(type: JavaExec) { main = findProperty("mainClass") ?: "" classpath = sourceSets.main.runtimeClasspath - jvmArgs += '--add-opens=java.base/java.lang=ALL-UNNAMED' // Upgrade to Java 21 - jvmArgs += '--add-opens=java.base/java.time=ALL-UNNAMED' // Upgrade to Java 21 + jvmArgs addOpensArgs +} + +test { + jvmArgs addOpensArgs } license {