Class ModuleFinder
java.lang.Object
nonapi.io.github.classgraph.classpath.ModuleFinder
A class to find the visible modules.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
If true, must forcibly scanjava.class.path
, since there was an anonymous module layer.The non system module refs.private final ReflectionUtils
The system module refs. -
Constructor Summary
ConstructorsConstructorDescriptionModuleFinder
(Class<?>[] callStack, ScanSpec scanSpec, boolean scanNonSystemModules, boolean scanSystemModules, ReflectionUtils reflectionUtils, LogNode log) A class to find the visible modules. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
findLayerOrder
(Object layer, Set<Object> layerVisited, Set<Object> parentLayers, Deque<Object> layerOrderOut) Recursively find the topological sort order of ancestral layers.findModuleRefs
(LinkedHashSet<Object> layers, ScanSpec scanSpec, LogNode log) Get all visible ModuleReferences in a list of layers.findModuleRefsFromCallstack
(Class<?>[] callStack, ScanSpec scanSpec, boolean scanNonSystemModules, LogNode log) Get all visible ModuleReferences in all layers, given an array of stack frameClass<?>
references.boolean
Force scan java class path.Get the non-system modules asModuleRef
wrappers.Get the system modules asModuleRef
wrappers.
-
Field Details
-
systemModuleRefs
The system module refs. -
nonSystemModuleRefs
The non system module refs. -
forceScanJavaClassPath
private boolean forceScanJavaClassPathIf true, must forcibly scanjava.class.path
, since there was an anonymous module layer. -
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 modulesscanSystemModules
- whether to scan system moduleslog
- The log.
-
-
Method Details
-
getSystemModuleRefs
Get the system modules asModuleRef
wrappers.- Returns:
- The system modules as
ModuleRef
wrappers, or null if no modules were found (e.g. on JDK 7 or 8).
-
getNonSystemModuleRefs
Get the non-system modules asModuleRef
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 layerlayerVisited
- layer visitedparentLayers
- the parent layerslayerOrderOut
- 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 layersscanSpec
- the scan speclog
- 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 frameClass<?>
references.- Parameters:
callStack
- the call stackscanSpec
- the scan specscanNonSystemModules
- whether to include unnamed and non-system moduleslog
- the log- Returns:
- the list
-