Skip to content
Luke Hutchison edited this page Aug 11, 2026 · 3 revisions

See also the ClassGraph API overview.

Contents

ModuleInfo

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 enable ModuleInfo, and call .ignoreClassVisibility() if you want to get modules for non-public classes.)
    • .getName() returns the name of the module as a String, or "" for the unnamed module.
    • .getLocationURI() returns the location of the module as a URI, or null for modules whose location is unknown.
    • .getModuleReference() returns the java.lang.module.ModuleReference for the module, or null if this module was obtained from a classpath element on the traditional classpath that contained a module-info.class file.
  • Classes:
    • .getClassInfo() returns a ClassInfoList of ClassInfo objects for all classes found in this module.
    • .getClassInfo(String className) returns the ClassInfo object for the named class in this module, or null if the class was not found in this module.
  • Packages:
    • .getPackageInfo() returns a PackageInfoList of PackageInfo objects for all packages that are members of this module.
    • .getPackageInfo(String packageName) returns the PackageInfo object 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.java module descriptor)
    • .getAllAnnotationInfo() / .getDirectAnnotationInfo() returns the annotations on this module as an AnnotationInfoList. The All form also includes meta-annotations -- the annotations on the module's own annotations, transitively.
    • .hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass) returns true if the module has the given annotation.
    • .getAllAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass) / .getDirectAnnotationInfo(...) returns the AnnotationInfo object for the given non-@Repeatable module annotation, or null if none.
    • .getAllAnnotationInfoRepeatable(String annotationName | Class<? extends Annotation> annotationClass) / .getDirectAnnotationInfoRepeatable(...) returns the AnnotationInfo objects for the given @Repeatable module annotation, as an AnnotationInfoList, or the empty list if none.

ModuleInfoList

Extends ArrayList<ModuleInfo> with the following convenience methods:

  • .asMap() returns the ModuleInfoList as a Map<String, ModuleInfo> mapping the module name to the corresponding ModuleInfo object.
  • .getNames() returns a list of the names of the modules in this list as a List<String>.
  • .getAsStrings() returns a list of the result of calling .toString() on each ModuleInfo object in this list, producing a List<String> of String representations of each module, including the module name and the module location URI.
  • .containsName(String moduleName) returns true if a module of the given name is contained in this list.
  • .get(String moduleName) returns the ModuleInfo object in this list with the requested name, if present, otherwise returns null.
  • .filter(Predicate<ModuleInfo> filter) returns a ModuleInfoList that is a subset of the original list, obtained by applying the given predicate to each ModuleInfo object in the list.

See also

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.

Clone this wiki locally