Skip to content

A small application to demonstrate the Java Platform Module System

License

Notifications You must be signed in to change notification settings

nipafx/demo-jpms-monitor

 
 

Repository files navigation

↗️ This README only covers one section of the demo. The master branch contains more information.

Cyclic Dependencies at Run Time

Getting a dependency cycle past the compiler requires a little bit of effort:

  • build all modules as usual (i.e. without any cycle)
  • add dependency from monitor.persistence to monitor.rest and rebuild it against the usual modules
  • add dependency from monitor.rest to monitor.persistence and rebuild it against the usual modules
  • replace usual versions of monitor.persistence and monitor.rest with new ones

Because each half of the cycle was built against a version of the depended module that did not have the dependency back, the compiler never saw the cycle. Only when both versions come together is there actually a cycle.

(Only in compile.sh, not with Maven.)

The runtime catches it:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException:
Cycle detected: monitor.persistence -> monitor.rest -> monitor.persistence

About

A small application to demonstrate the Java Platform Module System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published