-
-
Notifications
You must be signed in to change notification settings - Fork 292
ModuleInfo API
See also the ClassGraph API overview.
Holds information about a module encountered during scanning. Obtained by calling ScanResult#getModuleInfo(moduleName)
or ScanResult#getModuleInfo()
.
-
Properties: (N.B. call
.enableClassInfo()
before.scan()
to enableModuleInfo
, and call.ignoreClassVisibility()
if you want to get modules for non-public classes.)-
.getName()
returns the name of the module as aString
. -
.getLocation()
returns the location of the module as aURI
. -
.getModuleRef()
returns theModuleRef
for the module.
-
-
Classes:
-
.getClassInfo()
returns aClassInfoList
ofClassInfo
objects for all classes found in this module. -
.getClassInfo(String className)
returns theClassInfo
object for the named class in this module, or null if the class was not found in this module. /wiki/PackageInfo-API#packageinfo) object for the named package in this module, or null if the package was not found in this module.
-
-
Annotations: (module annotations are annotations on the
module-info.java
module descriptor)-
.getAnnotationInfo()
returns the annotations on this module as anAnnotationInfoList
. -
.hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass)
returnstrue
if the module has the given annotation. -
.getAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass)
returns theAnnotationInfo
object for the given module annotation, or null if none.
-
-
Packages:
-
.getPackageInfo()
returns aPackageInfoList
ofPackageInfo
objects for all packages found in this module. -
.getPackageInfo(String packageName)
returns thePackageInfo
object for the package of the given name in this module.
-
Extends ArrayList<ModuleInfo>
with the following convenience methods:
-
.asMap()
returns theModuleInfoList
as aMap<String, ModuleInfo>
mapping the module name to the correspondingModuleInfo
object. -
.getNames()
returns a list of the names of the modules in this list as aList<String>
. -
.getAsStrings()
returns a list of the result of calling.toString()
on eachModuleInfo
object in this list, producing aList<string>
ofString
representations of each module, including the module name and the module location URI. -
.containsName(String moduleName)
returnstrue
if a module of the given name is contained in this list. -
.get(String moduleName)
returns theModuleInfo
object in this list with the requested name, if present, otherwise returns null. -
.filter(ModuleInfoFilter filter)
returns aModuleInfoList
that is a subset of the original list, obtained by applying the given filter predicate to eachModuleInfo
object in the list.-
ModuleInfoFilter
is aFunctionalInterface
with the single abstract methodboolean accept(ModuleInfo moduleInfo)
.
-
Provides information on the module path. Note that this will only include module system parameters actually listed in commandline arguments -- in particular this does not include classpath elements from the traditional classpath, or system modules.
Obtained by calling ClassGraph#getModulePathInfo()
or ScanResult#getModulePathInfo
(the ScanResult
version includes any Add-Exports
or Add-Opens
entries found in jar manifest files while scanning). Note that the fields are all ordered sets (LinkedHashSet
), so iterating through a set will return the original order, only deduplicated.
-
.modulePath
contains the module path specified using the--module-path
or-p
commandline switch, as an ordered set of module names, in the order they were listed on the commandline. Note that some modules (such as system modules) will not be in this list, as they are added to the module system automatically by the runtime. CallClassGraph#getModules()
orScanResult#getModules()
get all modules visible at runtime. -
.addModules
contains modules added using the--add-modules
commandline switch, as an ordered set of module names, in the order they were listed on the commandline. Note that valid module names includeALL-DEFAULT
,ALL-SYSTEM
, andALL-MODULE-PATH
(see JEP 261 for info). -
.patchModules
contains module patch directives specified using the--patch-module
commandline switch, as an ordered set of strings in the format<module>=<file>(<pathsep><file>)*
, in the order they were listed on the commandline. -
.addExports
contains moduleexports
directives specified using the--add-exports
commandline switch, as an ordered set of strings in the format<source-module>/<package>=<target-module>(,<target-module>)*
, in the order they were listed on the commandline. Additionally, if thisModulePathInfo
object was obtained fromScanResult#getModulePathInfo()
rather thanClassGraph#getModulePathInfo()
, any additionalAdd-Exports
entries found in manifest files during classpath scanning will be appended to this list, in the format<source-module>/<package>=ALL-UNNAMED
. -
.addOpens
contains moduleopens
directives specified using the--add-opens
commandline switch, as an ordered set of strings in the format<source-module>/<package>=<target-module>(,<target-module>)*
, in the order they were listed on the commandline. Additionally, if thisModulePathInfo
object was obtained fromScanResult#getModulePathInfo()
rather thanClassGraph#getModulePathInfo()
, any additionalAdd-Opens
entries found in manifest files during classpath scanning will be appended to this list, in the format<source-module>/<package>=ALL-UNNAMED
. -
.addReads
contains modulereads
directives specified using the--add-reads
commandline switch, as an ordered set of strings in the format<source-module>=<target-module>
, in the order they were listed on the commandline. -
.toString()
will return all of the above as aString
, in commandline switch format.