-
-
Notifications
You must be signed in to change notification settings - Fork 309
ModuleInfo API
Luke Hutchison edited this page Aug 11, 2026
·
3 revisions
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, or""for the unnamed module. -
.getLocationURI()returns the location of the module as aURI, or null for modules whose location is unknown. -
.getModuleReference()returns thejava.lang.module.ModuleReferencefor the module, or null if this module was obtained from a classpath element on the traditional classpath that contained amodule-info.classfile.
-
-
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.
-
-
Packages:
-
.getPackageInfo()returns aPackageInfoListofPackageInfoobjects for all packages that are members of this module. -
.getPackageInfo(String packageName)returns thePackageInfoobject for the package of the given name in this module, or null if the package was not found in this module.
-
-
Annotations: (module annotations are the annotations on the
module-info.javamodule descriptor)-
.getAllAnnotationInfo()/.getDirectAnnotationInfo()returns the annotations on this module as anAnnotationInfoList. TheAllform also includes meta-annotations -- the annotations on the module's own annotations, transitively. -
.hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass)returnstrueif the module has the given annotation. -
.getAllAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass)/.getDirectAnnotationInfo(...)returns theAnnotationInfoobject for the given non-@Repeatablemodule annotation, or null if none. -
.getAllAnnotationInfoRepeatable(String annotationName | Class<? extends Annotation> annotationClass)/.getDirectAnnotationInfoRepeatable(...)returns theAnnotationInfoobjects for the given@Repeatablemodule annotation, as anAnnotationInfoList, or the empty list if none.
-
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(Predicate<ModuleInfo> filter)returns aModuleInfoListthat is a subset of the original list, obtained by applying the given predicate to eachModuleInfoobject in the list.
The module path itself -- the --module-path, --add-modules, --patch-module, --add-exports, --add-opens and --add-reads arguments the JVM was launched with -- is described by ModulePathInfo, which lives in the classpath-finding library. See ModulePathInfo.