Class ModuleFinder
- java.lang.Object
-
- nonapi.io.github.classgraph.classpath.ModuleFinder
-
public class ModuleFinder extends java.lang.ObjectA class to find the visible modules.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanforceScanJavaClassPathIf true, must forcibly scanjava.class.path, since there was an anonymous module layer.private java.util.List<ModuleRef>nonSystemModuleRefsThe non system module refs.private ReflectionUtilsreflectionUtilsprivate java.util.List<ModuleRef>systemModuleRefsThe system module refs.
-
Constructor Summary
Constructors Constructor Description ModuleFinder(java.lang.Class<?>[] callStack, ScanSpec scanSpec, boolean scanNonSystemModules, boolean scanSystemModules, ReflectionUtils reflectionUtils, LogNode log)A class to find the visible modules.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidfindLayerOrder(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.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.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 frameClass<?>references.booleanforceScanJavaClassPath()Force scan java class path.java.util.List<ModuleRef>getNonSystemModuleRefs()Get the non-system modules asModuleRefwrappers.java.util.List<ModuleRef>getSystemModuleRefs()Get the system modules asModuleRefwrappers.
-
-
-
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 scanjava.class.path, since there was an anonymous module layer.
-
reflectionUtils
private final ReflectionUtils reflectionUtils
-
-
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 modulesscanSystemModules- whether to scan system moduleslog- The log.
-
-
Method Detail
-
getSystemModuleRefs
public java.util.List<ModuleRef> getSystemModuleRefs()
Get the system modules asModuleRefwrappers.- Returns:
- The system modules as
ModuleRefwrappers, 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 asModuleRefwrappers.- Returns:
- The non-system modules as
ModuleRefwrappers, 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 layerlayerVisited- layer visitedparentLayers- the parent layerslayerOrderOut- 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 layersscanSpec- the scan speclog- 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 frameClass<?>references.- Parameters:
callStack- the call stackscanSpec- the scan specscanNonSystemModules- whether to include unnamed and non-system moduleslog- the log- Returns:
- the list
-
-