Interface JarModuleInfo

All Known Implementing Classes:
AuomaticModuleJarModuleInfo, ModJarMetadata, ModuleJarModuleInfo

public interface JarModuleInfo
Describes the modular properties of a Jar file, with direct access to the module name and version, as well as the ability to create a module descriptor for a given JarContents, which may involve scanning the Jar file for packages.
  • Method Details

    • name

      String name()
    • version

    • createDescriptor

      ModuleDescriptor createDescriptor(JarContents contents)
    • from

      static JarModuleInfo from(JarContents jar)
      Builds the jar metadata for a jar following the normal rules for Java jars.

      If the jar has a module-info.class file, the module info is read from there. Otherwise, the jar is an automatic module, whose name is optionally derived from Automatic-Module-Name in the manifest.

    • scanAutomaticModule

      static void scanAutomaticModule(JarContents jar, ModuleDescriptor.Builder builder, String... excludedRootDirectories)
      Scans an automatic module for the following and applies them to the given module builder.
      • Packages containing class files.
      • Java ServiceLoader providers found in META-INF/services/
      Parameters:
      excludedRootDirectories - Allows for additional root directories to be completely ignored for scanning packages. Useful if it is known beforehand that certain subdirectories are unlikely to contain classes.
    • scanModulePackages

      static Set<String> scanModulePackages(JarContents jar)
      Scans a given Jar for all packages that contain files for use with ModuleDescriptor.read(InputStream, Supplier).

      Unlike scanAutomaticModule(JarContents, ModuleDescriptor.Builder, String...), this also finds packages that contain only resource files, which is consistent with the behavior of ModuleFinder for modular Jar files.