One of the main goals of project Jigsaw in Java 9 is the reliable configuration. That is, Java 9 promises to address the classpath mechanism flaw that allows the java launcher to run a program without making sure that all necessary classes will be available to load in runtime, which used to result in java.lang.NoClassDefFoundErrors.
This is done by declaring module dependencies in module-info.java and by the brand new --module-path option. The module graph is analyzed before launching a Java application.
However, I can still do the following.
- Lets say I have two modules
com.spacey.explorerandcom.spacey.rocket.com.spacey.exploreruses a classcom.spacey.rocket.RocketZdefined and exported bycom.spacey.rocketmodule. After compiling and JARing both modules everything runs correctly. - Now I remove the
com.spacey.rocket.RocketZtype fromcom.spacey.rocketmodule and recompile and re-JAR only this one module. - I run the previously compiled
com.spacey.explorermodule with newly compiledcom.spacey.rocketmodule. - I get ...
java.lang.NoClassDefFoundError, which is possible after like 4 hours of application uptime.
Is there a way to really make sure that when running Java application not only the module graph (module path) completeness is verified but also a comprehensive check of the actual type accessibility is done ?