-
-
Notifications
You must be signed in to change notification settings - Fork 300
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 theModuleReffor the module.
-
-
Classes:
-
.getClassInfo()returns aClassInfoListofClassInfoobjects for all classes found in this module. -
.getClassInfo(String className)returns theClassInfoobject 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.javamodule descriptor)-
.getAnnotationInfo()returns the annotations on this module as anAnnotationInfoList. -
.hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass)returnstrueif the module has the given annotation. -
.getAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass)returns theAnnotationInfoobject for the given module annotation, or null if none.
-
-
Packages:
-
.getPackageInfo()returns aPackageInfoListofPackageInfoobjects for all packages found in this module. -
.getPackageInfo(String packageName)returns thePackageInfoobject for the package of the given name in this module.
-
Extends ArrayList<ModuleInfo> with the following convenience methods:
-
.asMap()returns theModuleInfoListas aMap<String, ModuleInfo>mapping the module name to the correspondingModuleInfoobject. -
.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 eachModuleInfoobject in this list, producing aList<string>ofStringrepresentations of each module, including the module name and the module location URI. -
.containsName(String moduleName)returnstrueif a module of the given name is contained in this list. -
.get(String moduleName)returns theModuleInfoobject in this list with the requested name, if present, otherwise returns null. -
.filter(ModuleInfoFilter filter)returns aModuleInfoListthat is a subset of the original list, obtained by applying the given filter predicate to eachModuleInfoobject in the list.-
ModuleInfoFilteris aFunctionalInterfacewith 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.
-
.modulePathcontains the module path specified using the--module-pathor-pcommandline 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. -
.addModulescontains modules added using the--add-modulescommandline 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). -
.patchModulescontains module patch directives specified using the--patch-modulecommandline switch, as an ordered set of strings in the format<module>=<file>(<pathsep><file>)*, in the order they were listed on the commandline. -
.addExportscontains moduleexportsdirectives specified using the--add-exportscommandline 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 thisModulePathInfoobject was obtained fromScanResult#getModulePathInfo()rather thanClassGraph#getModulePathInfo(), any additionalAdd-Exportsentries found in manifest files during classpath scanning will be appended to this list, in the format<source-module>/<package>=ALL-UNNAMED. -
.addOpenscontains moduleopensdirectives specified using the--add-openscommandline 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 thisModulePathInfoobject was obtained fromScanResult#getModulePathInfo()rather thanClassGraph#getModulePathInfo(), any additionalAdd-Opensentries found in manifest files during classpath scanning will be appended to this list, in the format<source-module>/<package>=ALL-UNNAMED. -
.addReadscontains modulereadsdirectives specified using the--add-readscommandline 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.