Using jdeps to outline module relationships

We used jdeps to identify the usage of internal JDK APIs. The tool can do much more than that! One feature that comes in handy when migrating code to Java 9 is the -summary option. What this does is go through your compiled modules and identify the relationships between different modules. This makes sure that you get the right requires relationship specified in your modules, including the automatic modules.

Run the following jdeps command in the 11-migrating-application/02-migrating-to-one-module folder:

$ jdeps -cp lib/commons-collections4-4.1.jar -recursive -summary out
commons-collections4-4.1.jar -> java.base
out -> lib/commons-collections4-4.1.jar
out -> java.base
out -> java.logging

The -recursive flag instructs jdeps to recursively navigate subfolders and list the dependencies of modules found in them too.

Notice that you get a really helpful output listing what module reads what. This is very handy when you have a bunch of JAR dependencies that were compiled in Java 8 or earlier, and you are trying to add them as automatic modules; rather than guessing what modules need to read these automatic modules, you can just run this command and get a good overview.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.249.174