Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Gradle Under the Hood: Hybrid JPMS Process Isolation & Dynamic Module Reflection

Over the first four articles of our Gradle Under the Hood series, we explored source-driven incremental tracking, network-immune classloader harvesting, compile-only dependency isolation, and our federated plugin architecture. Today, in Part 5 , we tackle one of the biggest friction points in modern enterprise Java builds: How do you run build-time JPA tooling—like bytecode enhancement, schema…

In Part 5 of the Gradle Under the Hood series, we tackle the challenge of running build-time JPA tooling against modular Java applications without weakening module encapsulation. The Java Platform Module System (JPMS) provides strong encapsulation, but standard Gradle workers on a flat classpath hit a wall when encountering deep reflection used by persistence tools like Hibernate.

To address this, we engineered JPMSWorkerSupport, a hybrid execution router that inspects the target source set's compiled output directory and chooses the optimal Gradle WorkerExecutor isolation strategy based on whether module-info.class is present. For modular projects, JPMSWorkerSupport automatically switches to hermetic OS-level processIsolation, while non-modular projects execute in-process using fast classLoaderIsolation.

Dynamic ModuleDescriptor inspection reads the compiled module-info.class binary directly using Java's ModuleDescriptor API to generate the exact --add-opens flags for the forked worker JVM, ensuring build-time tools get temporary, scoped reflective access without compromising production module descriptors. Additionally, we exposed custom settings like Hibernate default schema and dialect in the worker's SPI factory initialization, allowing for fine-tuned provider behavior.

This hybrid execution approach removes friction for enterprise persistence projects adopting JPMS, enabling clean production descriptors, zero overhead for legacy modules, and full vendor control over custom settings.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Sentinel Dev Diary: Believed, Not Checked

Most entries so far have followed a build step. Step one was read against The Semantic Model , step four against the watchdog, step six against The Rules Engine .

  • Security Model integrated into other steps, gaps unnoticed until testing
  • Published table assigns bus permissions to principals, insufficient for system
  • Fix adds inbox requirement per principal, resolves timeouts and failures

More from Monday 23 November →