Class ClassGraph
- java.lang.Object
-
- io.github.classgraph.ClassGraph
-
public class ClassGraph extends java.lang.Object
Uber-fast, ultra-lightweight Java classpath and module path scanner. Scans classfiles in the classpath and/or module path by parsing the classfile binary format directly rather than by using reflection.Documentation: https://github.com/classgraph/classgraph/wiki
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ClassGraph.CircumventEncapsulationMethod
Method to use to attempt to circumvent encapsulation in JDK 16+, in order to get access to a classloader's private classpath.static interface
ClassGraph.ClasspathElementFilter
Add a classpath element filter.static interface
ClassGraph.ClasspathElementURLFilter
Add a classpath element URL filter.static interface
ClassGraph.FailureHandler
A callback used to handle failure during an asynchronous scan.static interface
ClassGraph.ScanResultProcessor
A callback used to process the result of a successful asynchronous scan.
-
Field Summary
Fields Modifier and Type Field Description static ClassGraph.CircumventEncapsulationMethod
CIRCUMVENT_ENCAPSULATION
If you are running on JDK 16+, the JDK enforces strong encapsulation, and ClassGraph may be unable to read the classpath from your classloader if the classloader does not make the classpath available via a public method or field.(package private) static int
DEFAULT_NUM_WORKER_THREADS
The default number of worker threads to use while scanning.private ReflectionUtils
reflectionUtils
(package private) ScanSpec
scanSpec
The scanning specification.private LogNode
topLevelLog
If non-null, log while scanning.
-
Constructor Summary
Constructors Constructor Description ClassGraph()
Construct a ClassGraph instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ClassGraph
acceptClasses(java.lang.String... classNames)
Scan one or more specific classes, without scanning other classes in the same package unless the package is itself accepted.ClassGraph
acceptClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Accept classpath elements based on resource paths.ClassGraph
acceptJars(java.lang.String... jarLeafNames)
Accept one or more jars.ClassGraph
acceptLibOrExtJars(java.lang.String... jarLeafNames)
Accept one or more jars in a JRE/JDK "lib/" or "ext/" directory (these directories are not scanned unlessenableSystemJarsAndModules()
is called, by association with the JRE/JDK).ClassGraph
acceptModules(java.lang.String... moduleNames)
Accept one or more modules for scanning.private void
acceptOrRejectLibOrExtJars(boolean accept, java.lang.String... jarLeafNames)
Add lib or ext jars to accept or reject.ClassGraph
acceptPackages(java.lang.String... packageNames)
Scan one or more specific packages and their sub-packages.ClassGraph
acceptPackagesNonRecursive(java.lang.String... packageNames)
Scan one or more specific packages, without recursively scanning sub-packages unless they are themselves accepted.ClassGraph
acceptPaths(java.lang.String... paths)
Scan one or more specific paths, and their sub-directories or nested paths.ClassGraph
acceptPathsNonRecursive(java.lang.String... paths)
Scan one or more specific paths, without recursively scanning sub-directories or nested paths unless they are themselves accepted.ClassGraph
addClassLoader(java.lang.ClassLoader classLoader)
Add a ClassLoader to the list of ClassLoaders to scan.ClassGraph
addModuleLayer(java.lang.Object moduleLayer)
Add a ModuleLayer to the list of ModuleLayers to scan.ClassGraph
blacklistClasses(java.lang.String... classNames)
Deprecated.UserejectClasses(String...)
instead.ClassGraph
blacklistClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Deprecated.ClassGraph
blacklistJars(java.lang.String... jarLeafNames)
Deprecated.UserejectJars(String...)
instead.ClassGraph
blacklistLibOrExtJars(java.lang.String... jarLeafNames)
Deprecated.UserejectLibOrExtJars(String...)
instead.ClassGraph
blacklistModules(java.lang.String... moduleNames)
Deprecated.UserejectModules(String...)
instead.ClassGraph
blacklistPackages(java.lang.String... packageNames)
Deprecated.UserejectPackages(String...)
instead.ClassGraph
blacklistPaths(java.lang.String... paths)
Deprecated.UserejectPaths(String...)
instead.ClassGraph
disableDirScanning()
Disables the scanning of directories.ClassGraph
disableJarScanning()
Disables the scanning of jarfiles.ClassGraph
disableModuleScanning()
Disables the scanning of modules.ClassGraph
disableNestedJarScanning()
Disables the scanning of nested jarfiles (jarfiles within jarfiles).ClassGraph
disableRuntimeInvisibleAnnotations()
Causes only runtime visible annotations to be scanned (causes runtime invisible annotations to be ignored).ClassGraph
enableAllInfo()
Enables the scanning of all classes, fields, methods, annotations, and static final field constant initializer values, and ignores all visibility modifiers, so that both public and non-public classes, fields and methods are all scanned.ClassGraph
enableAnnotationInfo()
Enables the saving of annotation info (for class, field, method and method parameter annotations) during the scan.ClassGraph
enableClassInfo()
Enables the scanning of classfiles, producingClassInfo
objects in theScanResult
.ClassGraph
enableExternalClasses()
Causes ClassGraph to return classes that are not in the accepted packages, but that are directly referred to by classes within accepted packages as a superclass, implemented interface or annotation.ClassGraph
enableFieldInfo()
Enables the saving of field info during the scan.ClassGraph
enableInterClassDependencies()
Enables the determination of inter-class dependencies, which may be read by callingClassInfo.getClassDependencies()
,ScanResult.getClassDependencyMap()
orScanResult.getReverseClassDependencyMap()
.ClassGraph
enableMemoryMapping()
If true, use aMappedByteBuffer
rather than theFileChannel
API to open files, which may be faster for large classpaths consisting of many large jarfiles, but uses up virtual memory space.ClassGraph
enableMethodInfo()
Enables the saving of method info during the scan.ClassGraph
enableMultiReleaseVersions()
If true, provide all versions of a multi-release resource using their multi-release path prefix, instead of just the one the running JVM would select.ClassGraph
enableRealtimeLogging()
Enables logging by callingverbose()
, and then sets the logger to "realtime logging mode", where log entries are written out immediately to stderr, rather than only after the scan has completed.ClassGraph
enableRemoteJarScanning()
Enable classpath elements to be fetched from remote ("http:"/"https:") URLs (or URLs with custom schemes).ClassGraph
enableStaticFinalFieldConstantInitializerValues()
Enables the saving of static final field constant initializer values.ClassGraph
enableSystemJarsAndModules()
Enables the scanning of system packages ("java.*"
,"javax.*"
,"javafx.*"
,"jdk.*"
,"oracle.*"
,"sun.*"
) -- these are not scanned by default for speed.ClassGraph
enableURLScheme(java.lang.String scheme)
Enable classpath elements to be fetched fromURL
connections with the specified URL scheme (also works for any custom URL schemes that have been defined, as long as they have more than two characters, in order to not conflict with Windows drive letters).ClassGraph
filterClasspathElements(ClassGraph.ClasspathElementFilter classpathElementFilter)
Add a classpath element filter.ClassGraph
filterClasspathElementsByURL(ClassGraph.ClasspathElementURLFilter classpathElementURLFilter)
Add a classpath element filter.java.lang.String
getClasspath()
Returns the list of all unique File objects representing directories or zip/jarfiles on the classpath, in classloader resolution order, in the form of a classpath path string.java.util.List<java.io.File>
getClasspathFiles()
Returns the list of all unique File objects representing directories or zip/jarfiles on the classpath, in classloader resolution order.(package private) ScanResult
getClasspathScanResult(AutoCloseableExecutorService executorService)
Get aScanResult
that can be used for determining the classpath.java.util.List<java.net.URI>
getClasspathURIs()
Returns the ordered list of all uniqueURI
objects representing directory/jar classpath elements and modules.java.util.List<java.net.URL>
getClasspathURLs()
Returns the ordered list of all uniqueURL
objects representing directory/jar classpath elements and modules.ModulePathInfo
getModulePathInfo()
Get the module path info provided on the commandline with--module-path
,--add-modules
,--patch-module
,--add-exports
,--add-opens
, and--add-reads
.java.util.List<ModuleRef>
getModules()
ReturnsModuleRef
references for all the visible modules.static java.lang.String
getVersion()
Get the version number of ClassGraph.ClassGraph
ignoreClassVisibility()
Causes class visibility to be ignored, enabling private, package-private and protected classes to be scanned.ClassGraph
ignoreFieldVisibility()
Causes field visibility to be ignored, enabling private, package-private and protected fields to be scanned.ClassGraph
ignoreMethodVisibility()
Causes method visibility to be ignored, enabling private, package-private and protected methods to be scanned.ClassGraph
ignoreParentClassLoaders()
Ignore parent classloaders (i.e.ClassGraph
ignoreParentModuleLayers()
Ignore parent module layers (i.e.ClassGraph
initializeLoadedClasses()
Causes classes loaded usingClassInfo.loadClass()
to be are initialized after class loading (the default is to not initialize classes).ClassGraph
overrideClassLoaders(java.lang.ClassLoader... overrideClassLoaders)
Completely override (and ignore) system ClassLoaders and the java.class.path system property.ClassGraph
overrideClasspath(java.lang.Iterable<?> overrideClasspathElements)
Override the automatically-detected classpath with a custom path.ClassGraph
overrideClasspath(java.lang.Object... overrideClasspathElements)
Override the automatically-detected classpath with a custom path.ClassGraph
overrideClasspath(java.lang.String overrideClasspath)
Override the automatically-detected classpath with a custom path, with path elements separated by File.pathSeparatorChar.ClassGraph
overrideModuleLayers(java.lang.Object... overrideModuleLayers)
Completely override (and ignore) the visible ModuleLayers, and instead scan the requested ModuleLayers.ClassGraph
rejectClasses(java.lang.String... classNames)
Specifically reject one or more specific classes, preventing them from being scanned even if they are in a accepted package.ClassGraph
rejectClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Reject classpath elements based on resource paths.ClassGraph
rejectJars(java.lang.String... jarLeafNames)
Reject one or more jars, preventing them from being scanned.ClassGraph
rejectLibOrExtJars(java.lang.String... jarLeafNames)
Reject one or more jars in a JRE/JDK "lib/" or "ext/" directory, preventing them from being scanned.ClassGraph
rejectModules(java.lang.String... moduleNames)
Reject one or more modules, preventing them from being scanned.ClassGraph
rejectPackages(java.lang.String... packageNames)
Prevent the scanning of one or more specific packages and their sub-packages.ClassGraph
rejectPaths(java.lang.String... paths)
Prevent the scanning of one or more specific paths and their sub-directories / nested paths.ClassGraph
removeTemporaryFilesAfterScan()
Remove temporary files, including nested jarfiles (jarfiles within jarfiles, which have to be extracted during scanning in order to be read) from their temporary directory as soon as the scan has completed.ScanResult
scan()
Scans the classpath, blocking until the scan is complete.ScanResult
scan(int numThreads)
Scans the classpath with the requested number of threads, blocking until the scan is complete.ScanResult
scan(java.util.concurrent.ExecutorService executorService, int numParallelTasks)
Scans the classpath using the requestedExecutorService
and the requested degree of parallelism, blocking until the scan is complete.private java.util.concurrent.Future<ScanResult>
scanAsync(boolean performScan, java.util.concurrent.ExecutorService executorService, int numParallelTasks)
Asynchronously scans the classpath for matching files, returning aFuture<ScanResult>
.java.util.concurrent.Future<ScanResult>
scanAsync(java.util.concurrent.ExecutorService executorService, int numParallelTasks)
Asynchronously scans the classpath for matching files, returning aFuture<ScanResult>
.void
scanAsync(java.util.concurrent.ExecutorService executorService, int numParallelTasks, ClassGraph.ScanResultProcessor scanResultProcessor, ClassGraph.FailureHandler failureHandler)
Asynchronously scans the classpath, calling aClassGraph.ScanResultProcessor
callback on success or aClassGraph.FailureHandler
callback on failure.ClassGraph
setMaxBufferedJarRAMSize(int maxBufferedJarRAMSize)
The maximum size of an inner (nested) jar that has been deflated (i.e.ClassGraph
verbose()
Switches on verbose logging to System.err.ClassGraph
verbose(boolean verbose)
Switches on verbose logging to System.err if verbose is true.ClassGraph
whitelistClasses(java.lang.String... classNames)
Deprecated.UseacceptClasses(String...)
instead.ClassGraph
whitelistClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Deprecated.ClassGraph
whitelistJars(java.lang.String... jarLeafNames)
Deprecated.UseacceptJars(String...)
instead.ClassGraph
whitelistLibOrExtJars(java.lang.String... jarLeafNames)
Deprecated.UseacceptLibOrExtJars(String...)
instead.ClassGraph
whitelistModules(java.lang.String... moduleNames)
Deprecated.UseacceptModules(String...)
instead.ClassGraph
whitelistPackages(java.lang.String... packageNames)
Deprecated.UseacceptPackages(String...)
instead.ClassGraph
whitelistPackagesNonRecursive(java.lang.String... packageNames)
Deprecated.UseacceptPackagesNonRecursive(String...)
instead.ClassGraph
whitelistPaths(java.lang.String... paths)
Deprecated.UseacceptPaths(String...)
instead.ClassGraph
whitelistPathsNonRecursive(java.lang.String... paths)
Deprecated.UseacceptPathsNonRecursive(String...)
instead.
-
-
-
Field Detail
-
scanSpec
ScanSpec scanSpec
The scanning specification.
-
DEFAULT_NUM_WORKER_THREADS
static final int DEFAULT_NUM_WORKER_THREADS
The default number of worker threads to use while scanning. This number gave the best results on a relatively modern laptop with SSD, while scanning a large classpath.
-
CIRCUMVENT_ENCAPSULATION
public static ClassGraph.CircumventEncapsulationMethod CIRCUMVENT_ENCAPSULATION
If you are running on JDK 16+, the JDK enforces strong encapsulation, and ClassGraph may be unable to read the classpath from your classloader if the classloader does not make the classpath available via a public method or field.To enable a workaround to this, set this static field to
ClassGraph.CircumventEncapsulationMethod.NARCISSUS
orClassGraph.CircumventEncapsulationMethod.JVM_DRIVER
before interacting with ClassGraph in any other way, and also include the Narcissus or JVM-Driver library respectively on the classpath or module path.Narcissus uses JNI to circumvent encapsulation and field/method access controls. Narcissus employs a native code library, and is currently only compiled for Linux x86/x64, Windows x86/x64, and Mac OS X x64 bit.
JVM-Driver uses a pure JVM solution to try to circumvent encapsulation and security controls.
-
reflectionUtils
private final ReflectionUtils reflectionUtils
-
topLevelLog
private LogNode topLevelLog
If non-null, log while scanning.
-
-
Method Detail
-
getVersion
public static java.lang.String getVersion()
Get the version number of ClassGraph.- Returns:
- the ClassGraph version, or "unknown" if it could not be determined.
-
verbose
public ClassGraph verbose()
Switches on verbose logging to System.err.- Returns:
- this (for method chaining).
-
verbose
public ClassGraph verbose(boolean verbose)
Switches on verbose logging to System.err if verbose is true.- Parameters:
verbose
- if true, enable verbose logging.- Returns:
- this (for method chaining).
-
enableAllInfo
public ClassGraph enableAllInfo()
Enables the scanning of all classes, fields, methods, annotations, and static final field constant initializer values, and ignores all visibility modifiers, so that both public and non-public classes, fields and methods are all scanned.Calls
enableClassInfo()
,enableFieldInfo()
,enableMethodInfo()
,enableAnnotationInfo()
,enableStaticFinalFieldConstantInitializerValues()
,ignoreClassVisibility()
,ignoreFieldVisibility()
, andignoreMethodVisibility()
.- Returns:
- this (for method chaining).
-
enableClassInfo
public ClassGraph enableClassInfo()
Enables the scanning of classfiles, producingClassInfo
objects in theScanResult
. Implicitly disablesenableMultiReleaseVersions()
.- Returns:
- this (for method chaining).
-
ignoreClassVisibility
public ClassGraph ignoreClassVisibility()
Causes class visibility to be ignored, enabling private, package-private and protected classes to be scanned. By default, only public classes are scanned. (Automatically callsenableClassInfo()
.)- Returns:
- this (for method chaining).
-
enableMethodInfo
public ClassGraph enableMethodInfo()
Enables the saving of method info during the scan. This information can be obtained usingClassInfo.getMethodInfo()
etc. By default, method info is not scanned. (Automatically callsenableClassInfo()
.)- Returns:
- this (for method chaining).
-
ignoreMethodVisibility
public ClassGraph ignoreMethodVisibility()
Causes method visibility to be ignored, enabling private, package-private and protected methods to be scanned. By default, only public methods are scanned. (Automatically callsenableClassInfo()
andenableMethodInfo()
.)- Returns:
- this (for method chaining).
-
enableFieldInfo
public ClassGraph enableFieldInfo()
Enables the saving of field info during the scan. This information can be obtained usingClassInfo.getFieldInfo()
. By default, field info is not scanned. (Automatically callsenableClassInfo()
.)- Returns:
- this (for method chaining).
-
ignoreFieldVisibility
public ClassGraph ignoreFieldVisibility()
Causes field visibility to be ignored, enabling private, package-private and protected fields to be scanned. By default, only public fields are scanned. (Automatically callsenableClassInfo()
andenableFieldInfo()
.)- Returns:
- this (for method chaining).
-
enableStaticFinalFieldConstantInitializerValues
public ClassGraph enableStaticFinalFieldConstantInitializerValues()
Enables the saving of static final field constant initializer values. By default, constant initializer values are not scanned. If this is enabled, you can obtain the constant field initializer values fromFieldInfo.getConstantInitializerValue()
.Note that constant initializer values are usually only of primitive type, or String constants (or values that can be computed and reduced to one of those types at compiletime).
Also note that it is up to the compiler as to whether or not a constant-valued field is assigned as a constant in the field definition itself, or whether it is assigned manually in static class initializer blocks -- so your mileage may vary in being able to extract constant initializer values.
In fact in Kotlin, even constant initializers for non-static / non-final fields are stored in a field attribute in the classfile (and so these values may be picked up by ClassGraph by calling this method), although any field initializers for non-static fields are supposed to be ignored by the JVM according to the classfile spec, so the Kotlin compiler may change in future to stop generating these values, and you probably shouldn't rely on being able to get the initializers for non-static fields in Kotlin. (As far as non-final fields, javac simply does not add constant initializer values to the field attributes list for non-final fields, even if they are static, but the spec doesn't say whether or not the JVM should ignore constant initializers for non-final fields.)
Automatically calls
enableClassInfo()
andenableFieldInfo()
.- Returns:
- this (for method chaining).
-
enableAnnotationInfo
public ClassGraph enableAnnotationInfo()
Enables the saving of annotation info (for class, field, method and method parameter annotations) during the scan. This information can be obtained usingClassInfo.getAnnotationInfo()
,ClassMemberInfo.getAnnotationInfo()
, andMethodParameterInfo.getAnnotationInfo()
. By default, annotation info is not scanned. (Automatically callsenableClassInfo()
.)- Returns:
- this (for method chaining).
-
enableInterClassDependencies
public ClassGraph enableInterClassDependencies()
Enables the determination of inter-class dependencies, which may be read by callingClassInfo.getClassDependencies()
,ScanResult.getClassDependencyMap()
orScanResult.getReverseClassDependencyMap()
. (Automatically callsenableClassInfo()
,enableFieldInfo()
,enableMethodInfo()
,enableAnnotationInfo()
,ignoreClassVisibility()
,ignoreFieldVisibility()
andignoreMethodVisibility()
.)- Returns:
- this (for method chaining).
-
disableRuntimeInvisibleAnnotations
public ClassGraph disableRuntimeInvisibleAnnotations()
Causes only runtime visible annotations to be scanned (causes runtime invisible annotations to be ignored). (Automatically callsenableClassInfo()
.)- Returns:
- this (for method chaining).
-
disableJarScanning
public ClassGraph disableJarScanning()
Disables the scanning of jarfiles.- Returns:
- this (for method chaining).
-
disableNestedJarScanning
public ClassGraph disableNestedJarScanning()
Disables the scanning of nested jarfiles (jarfiles within jarfiles).- Returns:
- this (for method chaining).
-
disableDirScanning
public ClassGraph disableDirScanning()
Disables the scanning of directories.- Returns:
- this (for method chaining).
-
disableModuleScanning
public ClassGraph disableModuleScanning()
Disables the scanning of modules.- Returns:
- this (for method chaining).
-
enableExternalClasses
public ClassGraph enableExternalClasses()
Causes ClassGraph to return classes that are not in the accepted packages, but that are directly referred to by classes within accepted packages as a superclass, implemented interface or annotation. (Automatically callsenableClassInfo()
.)- Returns:
- this (for method chaining).
-
initializeLoadedClasses
public ClassGraph initializeLoadedClasses()
Causes classes loaded usingClassInfo.loadClass()
to be are initialized after class loading (the default is to not initialize classes).- Returns:
- this (for method chaining).
-
removeTemporaryFilesAfterScan
public ClassGraph removeTemporaryFilesAfterScan()
Remove temporary files, including nested jarfiles (jarfiles within jarfiles, which have to be extracted during scanning in order to be read) from their temporary directory as soon as the scan has completed. The default is for temporary files to be removed by theScanResult
finalizer, or on JVM exit.- Returns:
- this (for method chaining).
-
overrideClasspath
public ClassGraph overrideClasspath(java.lang.String overrideClasspath)
Override the automatically-detected classpath with a custom path, with path elements separated by File.pathSeparatorChar. Causes system ClassLoaders and the java.class.path system property to be ignored. Also causes modules not to be scanned.If this method is called, nothing but the provided classpath will be scanned, i.e. this causes ClassLoaders to be ignored, as well as the java.class.path system property.
- Parameters:
overrideClasspath
- The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar.- Returns:
- this (for method chaining).
-
overrideClasspath
public ClassGraph overrideClasspath(java.lang.Iterable<?> overrideClasspathElements)
Override the automatically-detected classpath with a custom path. Causes system ClassLoaders and the java.class.path system property to be ignored. Also causes modules not to be scanned.Works for Iterables of any type whose toString() method resolves to a classpath element string, e.g. String, File or Path.
- Parameters:
overrideClasspathElements
- The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar.- Returns:
- this (for method chaining).
-
overrideClasspath
public ClassGraph overrideClasspath(java.lang.Object... overrideClasspathElements)
Override the automatically-detected classpath with a custom path. Causes system ClassLoaders and the java.class.path system property to be ignored. Also causes modules not to be scanned.Works for arrays of any member type whose toString() method resolves to a classpath element string, e.g. String, File or Path.
- Parameters:
overrideClasspathElements
- The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar.- Returns:
- this (for method chaining).
-
filterClasspathElements
public ClassGraph filterClasspathElements(ClassGraph.ClasspathElementFilter classpathElementFilter)
Add a classpath element filter. The provided ClasspathElementFilter should return true if the path string passed to it is a path you want to scan.- Parameters:
classpathElementFilter
- The filter function to use. This function should return true if the classpath element path should be scanned, and false if not.- Returns:
- this (for method chaining).
-
filterClasspathElementsByURL
public ClassGraph filterClasspathElementsByURL(ClassGraph.ClasspathElementURLFilter classpathElementURLFilter)
Add a classpath element filter. The provided ClasspathElementFilter should return true if theURL
passed to it is a URL you want to scan.- Parameters:
classpathElementURLFilter
- The filter function to use. This function should return true if the classpath elementURL
should be scanned, and false if not.- Returns:
- this (for method chaining).
-
addClassLoader
public ClassGraph addClassLoader(java.lang.ClassLoader classLoader)
Add a ClassLoader to the list of ClassLoaders to scan.This call is ignored if
overrideClasspath(String)
is also called, or if this method is called beforeoverrideClassLoaders(ClassLoader...)
.- Parameters:
classLoader
- The additional ClassLoader to scan.- Returns:
- this (for method chaining).
-
overrideClassLoaders
public ClassGraph overrideClassLoaders(java.lang.ClassLoader... overrideClassLoaders)
Completely override (and ignore) system ClassLoaders and the java.class.path system property. Also causes modules not to be scanned. Note that you may want to use this together withignoreParentClassLoaders()
to extract classpath URLs from only the classloaders you specified in the parameter to `overrideClassLoaders`, and not their parent classloaders.This call is ignored if
overrideClasspath(String)
is called.- Parameters:
overrideClassLoaders
- The ClassLoaders to scan instead of the automatically-detected ClassLoaders.- Returns:
- this (for method chaining).
-
ignoreParentClassLoaders
public ClassGraph ignoreParentClassLoaders()
Ignore parent classloaders (i.e. only obtain paths to scan from classloaders that are not the parent of another classloader).- Returns:
- this (for method chaining).
-
addModuleLayer
public ClassGraph addModuleLayer(java.lang.Object moduleLayer)
Add a ModuleLayer to the list of ModuleLayers to scan. Use this method if you define your own ModuleLayer, but the scanning code is not running within that custom ModuleLayer.This call is ignored if it is called before
overrideModuleLayers(Object...)
.- Parameters:
moduleLayer
- The additional ModuleLayer to scan. (The parameter is of typeObject
for backwards compatibility with JDK 7 and JDK 8, but the argument should be of type ModuleLayer.)- Returns:
- this (for method chaining).
-
overrideModuleLayers
public ClassGraph overrideModuleLayers(java.lang.Object... overrideModuleLayers)
Completely override (and ignore) the visible ModuleLayers, and instead scan the requested ModuleLayers.This call is ignored if overrideClasspath() is called.
- Parameters:
overrideModuleLayers
- The ModuleLayers to scan instead of the automatically-detected ModuleLayers. (The parameter is of typeObject
[] for backwards compatibility with JDK 7 and JDK 8, but the argument should be of type ModuleLayer[].)- Returns:
- this (for method chaining).
-
ignoreParentModuleLayers
public ClassGraph ignoreParentModuleLayers()
Ignore parent module layers (i.e. only scan module layers that are not the parent of another module layer).- Returns:
- this (for method chaining).
-
acceptPackages
public ClassGraph acceptPackages(java.lang.String... packageNames)
Scan one or more specific packages and their sub-packages.N.B. Automatically calls
enableClassInfo()
-- callacceptPaths(String...)
instead if you only need to scan resources.- Parameters:
packageNames
- The fully-qualified names of packages to scan (using '.' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
whitelistPackages
@Deprecated public ClassGraph whitelistPackages(java.lang.String... packageNames)
Deprecated.UseacceptPackages(String...)
instead.UseacceptPackages(String...)
instead.- Parameters:
packageNames
- The fully-qualified names of packages to scan (using '.' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
acceptPaths
public ClassGraph acceptPaths(java.lang.String... paths)
Scan one or more specific paths, and their sub-directories or nested paths.- Parameters:
paths
- The paths to scan, relative to the package root of the classpath element (with '/' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
whitelistPaths
@Deprecated public ClassGraph whitelistPaths(java.lang.String... paths)
Deprecated.UseacceptPaths(String...)
instead.UseacceptPaths(String...)
instead.- Parameters:
paths
- The paths to scan, relative to the package root of the classpath element (with '/' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
acceptPackagesNonRecursive
public ClassGraph acceptPackagesNonRecursive(java.lang.String... packageNames)
Scan one or more specific packages, without recursively scanning sub-packages unless they are themselves accepted.N.B. Automatically calls
enableClassInfo()
-- callacceptPathsNonRecursive(String...)
instead if you only need to scan resources.This may be particularly useful for scanning the package root ("") without recursively scanning everything in the jar, dir or module.
- Parameters:
packageNames
- The fully-qualified names of packages to scan (with '.' as a separator). May not include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
whitelistPackagesNonRecursive
@Deprecated public ClassGraph whitelistPackagesNonRecursive(java.lang.String... packageNames)
Deprecated.UseacceptPackagesNonRecursive(String...)
instead.UseacceptPackagesNonRecursive(String...)
instead.- Parameters:
packageNames
- The fully-qualified names of packages to scan (with '.' as a separator). May not include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
acceptPathsNonRecursive
public ClassGraph acceptPathsNonRecursive(java.lang.String... paths)
Scan one or more specific paths, without recursively scanning sub-directories or nested paths unless they are themselves accepted.This may be particularly useful for scanning the package root ("") without recursively scanning everything in the jar, dir or module.
- Parameters:
paths
- The paths to scan, relative to the package root of the classpath element (with '/' as a separator). May not include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
whitelistPathsNonRecursive
@Deprecated public ClassGraph whitelistPathsNonRecursive(java.lang.String... paths)
Deprecated.UseacceptPathsNonRecursive(String...)
instead.UseacceptPathsNonRecursive(String...)
instead.- Parameters:
paths
- The paths to scan, relative to the package root of the classpath element (with '/' as a separator). May not include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
rejectPackages
public ClassGraph rejectPackages(java.lang.String... packageNames)
Prevent the scanning of one or more specific packages and their sub-packages.N.B. Automatically calls
enableClassInfo()
-- callrejectPaths(String...)
instead if you only need to scan resources.- Parameters:
packageNames
- The fully-qualified names of packages to reject (with '.' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
blacklistPackages
@Deprecated public ClassGraph blacklistPackages(java.lang.String... packageNames)
Deprecated.UserejectPackages(String...)
instead.UserejectPackages(String...)
instead.- Parameters:
packageNames
- The fully-qualified names of packages to reject (with '.' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
rejectPaths
public ClassGraph rejectPaths(java.lang.String... paths)
Prevent the scanning of one or more specific paths and their sub-directories / nested paths.- Parameters:
paths
- The paths to reject (with '/' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
blacklistPaths
@Deprecated public ClassGraph blacklistPaths(java.lang.String... paths)
Deprecated.UserejectPaths(String...)
instead.UserejectPaths(String...)
instead.- Parameters:
paths
- The paths to reject (with '/' as a separator). May include a glob wildcard ('*'
).- Returns:
- this (for method chaining).
-
acceptClasses
public ClassGraph acceptClasses(java.lang.String... classNames)
Scan one or more specific classes, without scanning other classes in the same package unless the package is itself accepted.N.B. Automatically calls
enableClassInfo()
.- Parameters:
classNames
- The fully-qualified names of classes to scan (using '.' as a separator). To match a class name by glob in any package, you must include a package glob too, e.g."*.*Suffix"
.- Returns:
- this (for method chaining).
-
whitelistClasses
@Deprecated public ClassGraph whitelistClasses(java.lang.String... classNames)
Deprecated.UseacceptClasses(String...)
instead.UseacceptClasses(String...)
instead.- Parameters:
classNames
- The fully-qualified names of classes to scan (using '.' as a separator).- Returns:
- this (for method chaining).
-
rejectClasses
public ClassGraph rejectClasses(java.lang.String... classNames)
Specifically reject one or more specific classes, preventing them from being scanned even if they are in a accepted package.N.B. Automatically calls
enableClassInfo()
.- Parameters:
classNames
- The fully-qualified names of classes to reject (using '.' as a separator). To match a class name by glob in any package, you must include a package glob too, e.g."*.*Suffix"
.- Returns:
- this (for method chaining).
-
blacklistClasses
@Deprecated public ClassGraph blacklistClasses(java.lang.String... classNames)
Deprecated.UserejectClasses(String...)
instead.UserejectClasses(String...)
instead.- Parameters:
classNames
- The fully-qualified names of classes to reject (using '.' as a separator).- Returns:
- this (for method chaining).
-
acceptJars
public ClassGraph acceptJars(java.lang.String... jarLeafNames)
Accept one or more jars. This will cause only the accepted jars to be scanned.- Parameters:
jarLeafNames
- The leafnames of the jars that should be scanned (e.g."mylib.jar"
). May contain a wildcard glob ("mylib-*.jar"
).- Returns:
- this (for method chaining).
-
whitelistJars
@Deprecated public ClassGraph whitelistJars(java.lang.String... jarLeafNames)
Deprecated.UseacceptJars(String...)
instead.UseacceptJars(String...)
instead.- Parameters:
jarLeafNames
- The leafnames of the jars that should be scanned (e.g."mylib.jar"
). May contain a wildcard glob ("mylib-*.jar"
).- Returns:
- this (for method chaining).
-
rejectJars
public ClassGraph rejectJars(java.lang.String... jarLeafNames)
Reject one or more jars, preventing them from being scanned.- Parameters:
jarLeafNames
- The leafnames of the jars that should be scanned (e.g."badlib.jar"
). May contain a wildcard glob ("badlib-*.jar"
).- Returns:
- this (for method chaining).
-
blacklistJars
@Deprecated public ClassGraph blacklistJars(java.lang.String... jarLeafNames)
Deprecated.UserejectJars(String...)
instead.UserejectJars(String...)
instead.- Parameters:
jarLeafNames
- The leafnames of the jars that should be scanned (e.g."badlib.jar"
). May contain a wildcard glob ("badlib-*.jar"
).- Returns:
- this (for method chaining).
-
acceptOrRejectLibOrExtJars
private void acceptOrRejectLibOrExtJars(boolean accept, java.lang.String... jarLeafNames)
Add lib or ext jars to accept or reject.- Parameters:
accept
- if true, add to accept, otherwise add to reject.jarLeafNames
- the jar leaf names to accept
-
acceptLibOrExtJars
public ClassGraph acceptLibOrExtJars(java.lang.String... jarLeafNames)
Accept one or more jars in a JRE/JDK "lib/" or "ext/" directory (these directories are not scanned unlessenableSystemJarsAndModules()
is called, by association with the JRE/JDK).- Parameters:
jarLeafNames
- The leafnames of the lib/ext jar(s) that should be scanned (e.g."mylib.jar"
). May contain a wildcard glob ('*'
). Note that if you call this method with no parameters, all JRE/JDK "lib/" or "ext/" jars will be accepted.- Returns:
- this (for method chaining).
-
whitelistLibOrExtJars
@Deprecated public ClassGraph whitelistLibOrExtJars(java.lang.String... jarLeafNames)
Deprecated.UseacceptLibOrExtJars(String...)
instead.UseacceptLibOrExtJars(String...)
instead.- Parameters:
jarLeafNames
- The leafnames of the lib/ext jar(s) that should be scanned (e.g."mylib.jar"
). May contain a wildcard glob ('*'
). Note that if you call this method with no parameters, all JRE/JDK "lib/" or "ext/" jars will be accepted.- Returns:
- this (for method chaining).
-
rejectLibOrExtJars
public ClassGraph rejectLibOrExtJars(java.lang.String... jarLeafNames)
Reject one or more jars in a JRE/JDK "lib/" or "ext/" directory, preventing them from being scanned.- Parameters:
jarLeafNames
- The leafnames of the lib/ext jar(s) that should not be scanned (e.g."jre/lib/badlib.jar"
). May contain a wildcard glob ('*'
). If you call this method with no parameters, all JRE/JDK"lib/"
or"ext/"
jars will be rejected.- Returns:
- this (for method chaining).
-
blacklistLibOrExtJars
@Deprecated public ClassGraph blacklistLibOrExtJars(java.lang.String... jarLeafNames)
Deprecated.UserejectLibOrExtJars(String...)
instead.UserejectLibOrExtJars(String...)
instead.- Parameters:
jarLeafNames
- The leafnames of the lib/ext jar(s) that should not be scanned (e.g."jre/lib/badlib.jar"
). May contain a wildcard glob ('*'
). If you call this method with no parameters, all JRE/JDK"lib/"
or"ext/"
jars will be rejected.- Returns:
- this (for method chaining).
-
acceptModules
public ClassGraph acceptModules(java.lang.String... moduleNames)
Accept one or more modules for scanning.- Parameters:
moduleNames
- The names of the modules that should be scanned. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
whitelistModules
@Deprecated public ClassGraph whitelistModules(java.lang.String... moduleNames)
Deprecated.UseacceptModules(String...)
instead.UseacceptModules(String...)
instead.- Parameters:
moduleNames
- The names of the modules that should be scanned. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
rejectModules
public ClassGraph rejectModules(java.lang.String... moduleNames)
Reject one or more modules, preventing them from being scanned.- Parameters:
moduleNames
- The names of the modules that should not be scanned. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
blacklistModules
@Deprecated public ClassGraph blacklistModules(java.lang.String... moduleNames)
Deprecated.UserejectModules(String...)
instead.UserejectModules(String...)
instead.- Parameters:
moduleNames
- The names of the modules that should not be scanned. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
acceptClasspathElementsContainingResourcePath
public ClassGraph acceptClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Accept classpath elements based on resource paths. Only classpath elements that contain resources with paths matching the accept will be scanned.- Parameters:
resourcePaths
- The resource paths, any of which must be present in a classpath element for the classpath element to be scanned. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
whitelistClasspathElementsContainingResourcePath
@Deprecated public ClassGraph whitelistClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Deprecated.- Parameters:
resourcePaths
- The resource paths, any of which must be present in a classpath element for the classpath element to be scanned. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
rejectClasspathElementsContainingResourcePath
public ClassGraph rejectClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Reject classpath elements based on resource paths. Classpath elements that contain resources with paths matching the reject will not be scanned.- Parameters:
resourcePaths
- The resource paths which cause a classpath not to be scanned if any are present in a classpath element for the classpath element. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
blacklistClasspathElementsContainingResourcePath
@Deprecated public ClassGraph blacklistClasspathElementsContainingResourcePath(java.lang.String... resourcePaths)
Deprecated.- Parameters:
resourcePaths
- The resource paths which cause a classpath not to be scanned if any are present in a classpath element for the classpath element. May contain a wildcard glob ('*'
).- Returns:
- this (for method chaining).
-
enableRemoteJarScanning
public ClassGraph enableRemoteJarScanning()
Enable classpath elements to be fetched from remote ("http:"/"https:") URLs (or URLs with custom schemes). Equivalent to:new ClassGraph().enableURLScheme("http").enableURLScheme("https");
Scanning from http(s) URLs is disabled by default, as this may present a security vulnerability, since classes from downloaded jars can be subsequently loaded using
ClassInfo.loadClass(java.lang.Class<T>, boolean)
.- Returns:
- this (for method chaining).
-
enableURLScheme
public ClassGraph enableURLScheme(java.lang.String scheme)
Enable classpath elements to be fetched fromURL
connections with the specified URL scheme (also works for any custom URL schemes that have been defined, as long as they have more than two characters, in order to not conflict with Windows drive letters).- Parameters:
scheme
- the URL scheme string, e.g. "resource" for a custom "resource:" URL scheme.- Returns:
- this (for method chaining).
-
enableSystemJarsAndModules
public ClassGraph enableSystemJarsAndModules()
Enables the scanning of system packages ("java.*"
,"javax.*"
,"javafx.*"
,"jdk.*"
,"oracle.*"
,"sun.*"
) -- these are not scanned by default for speed.N.B. Automatically calls
enableClassInfo()
.- Returns:
- this (for method chaining).
-
setMaxBufferedJarRAMSize
public ClassGraph setMaxBufferedJarRAMSize(int maxBufferedJarRAMSize)
The maximum size of an inner (nested) jar that has been deflated (i.e. compressed, not stored) within an outer jar, before it has to be spilled to disk rather than stored in a RAM-backedByteBuffer
when it is deflated, in order for the inner jar's entries to be read. (Note that this situation of having to deflate a nested jar to RAM or disk in order to read it is rare, because normally adding a jarfile to another jarfile will store the inner jar, rather than deflate it, because deflating a jarfile does not usually produce any further compression gains. If an inner jar is stored, not deflated, then its zip entries can be read directly using ClassGraph's own zipfile central directory parser, which can use file slicing to extract entries directly from stored nested jars.)This is also the maximum size of a jar downloaded from an
http://
orhttps://
classpathURL
to RAM. Once this many bytes have been read from theURL
'sInputStream
, then the RAM contents are spilled over to a temporary file on disk, and the rest of the content is downloaded to the temporary file. (This is also rare, because normally there are nohttp://
orhttps://
classpath entries.)Default: 64MB (i.e. writing to disk is avoided wherever possible). Setting a lower max RAM size value will decrease ClassGraph's memory usage if either of the above rare situations occurs.
- Parameters:
maxBufferedJarRAMSize
- The max RAM size to use for deflated inner jars or downloaded jars. This is the limit per jar, not for the whole classpath.- Returns:
- this (for method chaining).
-
enableMemoryMapping
public ClassGraph enableMemoryMapping()
If true, use aMappedByteBuffer
rather than theFileChannel
API to open files, which may be faster for large classpaths consisting of many large jarfiles, but uses up virtual memory space.- Returns:
- this (for method chaining).
-
enableMultiReleaseVersions
public ClassGraph enableMultiReleaseVersions()
If true, provide all versions of a multi-release resource using their multi-release path prefix, instead of just the one the running JVM would select. Implicitly disablesenableClassInfo()
and all features depending on it.- Returns:
- this (for method chaining).
-
enableRealtimeLogging
public ClassGraph enableRealtimeLogging()
Enables logging by callingverbose()
, and then sets the logger to "realtime logging mode", where log entries are written out immediately to stderr, rather than only after the scan has completed. Can help to identify problems where scanning is stuck in a loop, or where one scanning step is taking much longer than it should, etc.- Returns:
- this (for method chaining).
-
scanAsync
public void scanAsync(java.util.concurrent.ExecutorService executorService, int numParallelTasks, ClassGraph.ScanResultProcessor scanResultProcessor, ClassGraph.FailureHandler failureHandler)
Asynchronously scans the classpath, calling aClassGraph.ScanResultProcessor
callback on success or aClassGraph.FailureHandler
callback on failure.- Parameters:
executorService
- A customExecutorService
to use for scheduling worker tasks.numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of classpath scanning. Ideally the ExecutorService will have at least this many threads available.scanResultProcessor
- AClassGraph.ScanResultProcessor
callback to run on successful scan.failureHandler
- AClassGraph.FailureHandler
callback to run on failed scan. This is passed anyThrowable
thrown during the scan.
-
scanAsync
private java.util.concurrent.Future<ScanResult> scanAsync(boolean performScan, java.util.concurrent.ExecutorService executorService, int numParallelTasks)
Asynchronously scans the classpath for matching files, returning aFuture<ScanResult>
. You should assign the wrappedScanResult
in a try-with-resources statement, or manually close it when you are finished with it.- Parameters:
performScan
- If true, performing a scan. If false, only fetching the classpath.executorService
- A customExecutorService
to use for scheduling worker tasks.numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of classpath scanning. Ideally the ExecutorService will have at least this many threads available.- Returns:
- a
Future<ScanResult>
, that when resolved using get() yields a newScanResult
object representing the result of the scan.
-
scanAsync
public java.util.concurrent.Future<ScanResult> scanAsync(java.util.concurrent.ExecutorService executorService, int numParallelTasks)
Asynchronously scans the classpath for matching files, returning aFuture<ScanResult>
. You should assign the wrappedScanResult
in a try-with-resources statement, or manually close it when you are finished with it.- Parameters:
executorService
- A customExecutorService
to use for scheduling worker tasks.numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of classpath scanning. Ideally the ExecutorService will have at least this many threads available.- Returns:
- a
Future<ScanResult>
, that when resolved using get() yields a newScanResult
object representing the result of the scan.
-
scan
public ScanResult scan(java.util.concurrent.ExecutorService executorService, int numParallelTasks)
Scans the classpath using the requestedExecutorService
and the requested degree of parallelism, blocking until the scan is complete. You should assign the returnedScanResult
in a try-with-resources statement, or manually close it when you are finished with it.- Parameters:
executorService
- A customExecutorService
to use for scheduling worker tasks. ThisExecutorService
should start tasks in FIFO order to avoid a deadlock during scan, i.e. be sure to construct theExecutorService
with aLinkedBlockingQueue
as its task queue. (This is the default forExecutors.newFixedThreadPool(int)
.)numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of classpath scanning. Ideally the ExecutorService will have at least this many threads available.- Returns:
- a
ScanResult
object representing the result of the scan. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
scan
public ScanResult scan(int numThreads)
Scans the classpath with the requested number of threads, blocking until the scan is complete. You should assign the returnedScanResult
in a try-with-resources statement, or manually close it when you are finished with it.- Parameters:
numThreads
- The number of worker threads to start up.- Returns:
- a
ScanResult
object representing the result of the scan. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
scan
public ScanResult scan()
Scans the classpath, blocking until the scan is complete. You should assign the returnedScanResult
in a try-with-resources statement, or manually close it when you are finished with it.- Returns:
- a
ScanResult
object representing the result of the scan. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getClasspathScanResult
ScanResult getClasspathScanResult(AutoCloseableExecutorService executorService)
Get aScanResult
that can be used for determining the classpath.- Parameters:
executorService
- The executor service.- Returns:
- a
ScanResult
object representing the result of the scan (can only be used for determining classpath). - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getClasspathFiles
public java.util.List<java.io.File> getClasspathFiles()
Returns the list of all unique File objects representing directories or zip/jarfiles on the classpath, in classloader resolution order. Classpath elements that do not exist as a file or directory are not included in the returned list.- Returns:
- a
List<File>
consisting of the unique directories and jarfiles on the classpath, in classpath resolution order. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getClasspath
public java.lang.String getClasspath()
Returns the list of all unique File objects representing directories or zip/jarfiles on the classpath, in classloader resolution order, in the form of a classpath path string. Classpath elements that do not exist as a file or directory are not included in the returned list. Note that the returned string contains only base files, and does not include package roots or nested jars within jars, since the path separator (':') conflicts with the URL scheme separator character (also ':') on Linux and Mac OS X. CallgetClasspathURIs()
to get the full URIs for classpath elements and modules.- Returns:
- a classpath path string consisting of the unique directories and jarfiles on the classpath, in classpath resolution order.
- Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getClasspathURIs
public java.util.List<java.net.URI> getClasspathURIs()
Returns the ordered list of all uniqueURI
objects representing directory/jar classpath elements and modules. Classpath elements representing jarfiles or directories that do not exist are not included in the returned list.- Returns:
- the unique classpath elements and modules, as a list of
URI
objects. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getClasspathURLs
public java.util.List<java.net.URL> getClasspathURLs()
Returns the ordered list of all uniqueURL
objects representing directory/jar classpath elements and modules. Classpath elements representing jarfiles or directories that do not exist, as well as modules with unknown (null) location or withjrt:
location URI scheme, are not included in the returned list.- Returns:
- the unique classpath elements and modules, as a list of
URL
objects. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getModules
public java.util.List<ModuleRef> getModules()
ReturnsModuleRef
references for all the visible modules.- Returns:
- a list of
ModuleRef
references for all the visible modules. - Throws:
ClassGraphException
- if any of the worker threads throws an uncaught exception, or the scan was interrupted.
-
getModulePathInfo
public ModulePathInfo getModulePathInfo()
Get the module path info provided on the commandline with--module-path
,--add-modules
,--patch-module
,--add-exports
,--add-opens
, and--add-reads
.Note that the returned
ModulePathInfo
object does not include classpath entries from the traditional classpath or system modules. UsegetModules()
to get all visible modules, including anonymous, automatic and system modules.Also,
ModulePathInfo.addExports
andModulePathInfo.addOpens
will not containAdd-Exports
orAdd-Opens
entries from jarfile manifest files encountered during scanning, unless you obtain theModulePathInfo
by callingScanResult.getModulePathInfo()
rather than by callinggetModulePathInfo()
beforescan()
.- Returns:
- The
ModulePathInfo
.
-
-