Top Description Fields Constructors Methods
nonapi.io.github.classgraph.classpath

public Class ModuleFinder

extends Object
Class Inheritance
Imports
java.util.ArrayDeque, .ArrayList, .Collections, .Deque, .HashSet, .LinkedHashSet, .List, .Set, io.github.classgraph.ModuleRef, nonapi.io.github.classgraph.reflection.ReflectionUtils, nonapi.io.github.classgraph.scanspec.ScanSpec, nonapi.io.github.classgraph.utils.CollectionUtils, .LogNode

A class to find the visible modules.

Field Summary

Modifier and TypeField and Description
private boolean
forceScanJavaClassPath

If true, must forcibly scan java.class.path, since there was an anonymous module layer.

private List<ModuleRef>
nonSystemModuleRefs

The non system module refs.

private final ReflectionUtils
private List<ModuleRef>
systemModuleRefs

The system module refs.

Constructor Summary

AccessConstructor and Description
public
ModuleFinder(final Class<?>[]
the callstack.
callStack
,
final ScanSpec
The scan spec.
scanSpec
,
final boolean
whether to scan unnamed and non-system modules
scanNonSystemModules
,
final boolean
whether to scan system modules
scanSystemModules
,
final ReflectionUtils reflectionUtils, final LogNode
The log.
log
)

A class to find the visible modules.

Method Summary

Modifier and TypeMethod and Description
private void
findLayerOrder(final Object
the layer
layer
,
final Set<Object>
layer visited
layerVisited
,
final Set<Object>
the parent layers
parentLayers
,
final Deque<Object>
the layer order
layerOrderOut
)

Recursively find the topological sort order of ancestral layers.

private List<ModuleRef>

Returns:

the list
findModuleRefs
(final LinkedHashSet<Object>
the layers
layers
,
final ScanSpec
the scan spec
scanSpec
,
final LogNode
the log
log
)

Get all visible ModuleReferences in a list of layers.

private List<ModuleRef>

Returns:

the list
findModuleRefsFromCallstack
(final Class<?>[]
the call stack
callStack
,
final ScanSpec
the scan spec
scanSpec
,
final boolean
whether to include unnamed and non-system modules
scanNonSystemModules
,
final LogNode
the log
log
)

Get all visible ModuleReferences in all layers, given an array of stack frame Class<?

public boolean

Returns:

If true, must forcibly scan java.class.path, since there was an anonymous module layer.
forceScanJavaClassPath
()

Force scan java class path.

public List<ModuleRef>

Returns:

The non-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 as ModuleRef wrappers.

public List<ModuleRef>

Returns:

The system modules as ModuleRef wrappers, or null if no modules were found (e.g. on JDK 7 or 8).
getSystemModuleRefs
()

Get the system modules as ModuleRef wrappers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

forceScanJavaClassPathback to summary
private boolean forceScanJavaClassPath

If true, must forcibly scan java.class.path, since there was an anonymous module layer.

nonSystemModuleRefsback to summary
private List<ModuleRef> nonSystemModuleRefs

The non system module refs.

reflectionUtilsback to summary
private final ReflectionUtils reflectionUtils
systemModuleRefsback to summary
private List<ModuleRef> systemModuleRefs

The system module refs.

Constructor Detail

ModuleFinderback to summary
public ModuleFinder(final Class<?>[] callStack, final ScanSpec scanSpec, final boolean scanNonSystemModules, final boolean scanSystemModules, final ReflectionUtils reflectionUtils, final LogNode log)

A class to find the visible modules.

Parameters
callStack:Class<?>[]

the callstack.

scanSpec:ScanSpec

The scan spec.

scanNonSystemModules:boolean

whether to scan unnamed and non-system modules

scanSystemModules:boolean

whether to scan system modules

log:LogNode

The log.

Method Detail

findLayerOrderback to summary
private void findLayerOrder(final Object layer, final Set<Object> layerVisited, final Set<Object> parentLayers, final 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:Object

the layer

layerVisited:Set<Object>

layer visited

parentLayers:Set<Object>

the parent layers

layerOrderOut:Deque<Object>

the layer order

findModuleRefsback to summary
private List<ModuleRef> findModuleRefs(final LinkedHashSet<Object> layers, final ScanSpec scanSpec, final LogNode log)

Get all visible ModuleReferences in a list of layers.

Parameters
layers:LinkedHashSet<Object>

the layers

scanSpec:ScanSpec

the scan spec

log:LogNode

the log

Returns:List<ModuleRef>

the list

findModuleRefsFromCallstackback to summary
private List<ModuleRef> findModuleRefsFromCallstack(final Class<?>[] callStack, final ScanSpec scanSpec, final boolean scanNonSystemModules, final LogNode log)

Get all visible ModuleReferences in all layers, given an array of stack frame Class<?> references.

Parameters
callStack:Class<?>[]

the call stack

scanSpec:ScanSpec

the scan spec

scanNonSystemModules:boolean

whether to include unnamed and non-system modules

log:LogNode

the log

Returns:List<ModuleRef>

the list

forceScanJavaClassPathback to summary
public boolean forceScanJavaClassPath()

Force scan java class path.

Returns:boolean

If true, must forcibly scan java.class.path, since there was an anonymous module layer.

getNonSystemModuleRefsback to summary
public List<ModuleRef> getNonSystemModuleRefs()

Get the non-system modules as ModuleRef wrappers.

Returns:List<ModuleRef>

The non-system modules as ModuleRef wrappers, or null if no modules were found (e.g. on JDK 7 or 8).

getSystemModuleRefsback to summary
public List<ModuleRef> getSystemModuleRefs()

Get the system modules as ModuleRef wrappers.

Returns:List<ModuleRef>

The system modules as ModuleRef wrappers, or null if no modules were found (e.g. on JDK 7 or 8).