Class ModuleFinder


  • public class ModuleFinder
    extends java.lang.Object
    A class to find the visible modules.
    • Field Detail

      • systemModuleRefs

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

        private java.util.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.
    • Constructor Detail

      • ModuleFinder

        public ModuleFinder​(java.lang.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 Detail

      • getSystemModuleRefs

        public java.util.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 java.util.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​(java.lang.Object layer,
                                    java.util.Set<java.lang.Object> layerVisited,
                                    java.util.Set<java.lang.Object> parentLayers,
                                    java.util.Deque<java.lang.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 java.util.List<ModuleRef> findModuleRefs​(java.util.LinkedHashSet<java.lang.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 java.util.List<ModuleRef> findModuleRefsFromCallstack​(java.lang.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