Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Java module system compatibility



The library has several method allowing to check if one or several Jar files are compatible with the Java module system[1]
See See ModuleFinder.of(Path...) for more information
. All the relevant methods are in the JavaModulesUtilities class.

Check that one Jar file is compatible with the Java module system

The JavaModulesUtilities.isModulesCompatible(JarDependencies) method allows to check that one Jar file is compatible with the Java module system. It will return true in the following conditions:
  • If the JarDependencies is a directory, the method will only check if no class are in the default package
  • If the JarDependencies is a Jar file, the method will check if no class are in the default package, and if there is a Manifest and it contains the "Automatic-Module-Name" attribute
For example:
  JarDependencies depend = new JarDependencies(<myJarFile>);
  boolean isCompatible = JavaModulesUtilities.isModulesCompatible(depend);

Check that several Jar files are compatible with the Java module system

The JavaModulesUtilities.isModulesCompatible(List) method allows to check that several jar files are compatible with the Java module system, and also with each other as modules. It will return true in the following conditions:
  • All of the jar files are compatible with Java modules
  • The jar files have different Manifest "Automatic-Module-Name" attribute values
  • The jar files don't have classes in the same package
For example:
  JarDependencies depend = new JarDependencies(<myJarFile>);
  JarDependencies anotherDepend = new JarDependencies(<aSecondJarFile>);
  boolean isCompatible = JavaModulesUtilities.isModulesCompatible(depend, anotherDepend);

Notes

  1. ^ See See ModuleFinder.of(Path...) for more information

Categories: general

Copyright 2019 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 licence