Class ModuleFinder

java.lang.Object
nonapi.io.github.classgraph.classpath.ModuleFinder

public class ModuleFinder extends Object
A class to find the visible modules.
  • Field Details

    • systemModuleRefs

      private List<ModuleRef> systemModuleRefs
      The system module refs.
    • nonSystemModuleRefs

      private List<ModuleRef> nonSystemModuleRefs
      The non system module refs.
    • forceScanJavaClassPath

      private boolean forceScanJavaClassPath
      If true, must forcibly scan java.class.path, since there was an anonymous module layer.
    • reflectionUtils

      private final ReflectionUtils reflectionUtils
  • Constructor Details

    • ModuleFinder

      public ModuleFinder(Class<?>[] callStack, ScanSpec scanSpec, boolean scanNonSystemModules, boolean scanSystemModules, ReflectionUtils reflectionUtils, LogNode log)
      A class to find the visible modules.
      Parameters:
      callStack - the callstack.
      scanSpec - The scan spec.
      scanNonSystemModules - whether to scan unnamed and non-system modules
      scanSystemModules - whether to scan system modules
      log - The log.
  • Method Details

    • getSystemModuleRefs

      public List<ModuleRef> getSystemModuleRefs()
      Get the system modules as ModuleRef wrappers.
      Returns:
      The system modules as ModuleRef wrappers, or null if no modules were found (e.g. on JDK 7 or 8).
    • getNonSystemModuleRefs

      public List<ModuleRef> getNonSystemModuleRefs()
      Get the non-system modules as ModuleRef wrappers.
      Returns:
      The non-system modules as ModuleRef wrappers, or null if no modules were found (e.g. on JDK 7 or 8).
    • forceScanJavaClassPath

      public boolean forceScanJavaClassPath()
      Force scan java class path.
      Returns:
      If true, must forcibly scan java.class.path, since there was an anonymous module layer.
    • findLayerOrder

      private void findLayerOrder(Object layer, Set<Object> layerVisited, Set<Object> parentLayers, Deque<Object> layerOrderOut)
      Recursively find the topological sort order of ancestral layers.

      (The JDK (as of 10.0.0.1) uses a broken (non-topological) DFS ordering for layer resolution in ModuleLayer#layers() and Configuration#configurations() but when I reported this bug on the Jigsaw mailing list, Alan didn't see what the problem was.)

      Parameters:
      layer - the layer
      layerVisited - layer visited
      parentLayers - the parent layers
      layerOrderOut - the layer order
    • findModuleRefs

      private List<ModuleRef> findModuleRefs(LinkedHashSet<Object> layers, ScanSpec scanSpec, LogNode log)
      Get all visible ModuleReferences in a list of layers.
      Parameters:
      layers - the layers
      scanSpec - the scan spec
      log - the log
      Returns:
      the list
    • findModuleRefsFromCallstack

      private List<ModuleRef> findModuleRefsFromCallstack(Class<?>[] callStack, ScanSpec scanSpec, boolean scanNonSystemModules, LogNode log)
      Get all visible ModuleReferences in all layers, given an array of stack frame Class<?> references.
      Parameters:
      callStack - the call stack
      scanSpec - the scan spec
      scanNonSystemModules - whether to include unnamed and non-system modules
      log - the log
      Returns:
      the list