Modern Apps git

← Modern-Apps.git

build: fork one test JVM per class in modules with Rust host libs

Commit
b1e994a5dc63d850e855afb191015135c436cf75
Author
Vayun Mathur <[email protected]>
When
2026-11-06 18:57 UTC (29 days ago)
Parents
4aed00e
A JNI library binds to one classloader per JVM. Plain JVM tests load it via the app
classloader and Robolectric tests via the sandbox loader, so suites mixing both failed
with "already loaded in another classloader" (17 office failures on main). Scoped to
modules that link host Rust libs, so other suites keep a shared JVM.

(cherry picked from commit bf0fb4c40ffecc5459c0eb1b00de1a639a7ca906)

Diff

build-logic/src/main/kotlin/RustNative.kt
diff --git a/build-logic/src/main/kotlin/RustNative.kt b/build-logic/src/main/kotlin/RustNative.ktindex 803a86fe86..c60db1b8c2 100644--- a/build-logic/src/main/kotlin/RustNative.kt+++ b/build-logic/src/main/kotlin/RustNative.kt@@ -892,6 +892,11 @@ fun Project.wireRustHostLibsForUnitTests() {                 ?.split(sep).orEmpty()             val merged = (existing + refs.map { it.libDir }).distinct()             systemProperty("java.library.path", merged.joinToString(sep))+            // A JNI library can be bound to only one classloader per JVM. Plain JVM tests+            // load it via the app classloader and Robolectric tests via its sandbox loader,+            // so mixing both in one JVM fails with "already loaded in another classloader".+            // One JVM per test class keeps each loader's System.loadLibrary isolated.+            forkEvery = 1         }     } }