public class ScanSpec
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ScanSpec.ScanSpecPathMatch
Whether a path is a descendant of a rejected path, or an ancestor or descendant of an accepted path.
|
| Modifier and Type | Field and Description |
|---|---|
java.util.List<java.lang.ClassLoader> |
addedClassLoaders
If non-null, specifies manually-added classloaders that should be searched after the context classloader(s).
|
java.util.List<java.lang.Object> |
addedModuleLayers
If non-null, specifies manually-added ModuleLayers that should be searched after the visible ModuleLayers.
|
java.util.Set<java.lang.String> |
allowedURLSchemes
URL schemes that are allowed in classpath elements (not counting the optional "jar:" prefix and/or "file:",
which are automatically allowed).
|
AcceptReject.AcceptRejectWholeString |
classAcceptReject
Class accept/reject criteria (fully-qualified class names, with separator '.').
|
AcceptReject.AcceptRejectWholeString |
classfilePathAcceptReject
Classfile accept/reject criteria (path to classfiles, with separator '/', ending in ".class").
|
AcceptReject.AcceptRejectWholeString |
classPackageAcceptReject
Package containing accept/reject criteriaed classes (with separator '.').
|
AcceptReject.AcceptRejectWholeString |
classPackagePathAcceptReject
Path to accept/reject criteriaed classes (with separator '/').
|
java.util.List<java.lang.Object> |
classpathElementFilters
If non-null, a list of filter operations to apply to classpath elements.
|
AcceptReject.AcceptRejectWholeString |
classpathElementResourcePathAcceptReject
Classpath element resource path accept/reject criteria.
|
boolean |
disableRuntimeInvisibleAnnotations
If true, don't scan runtime-invisible annotations (only scan annotations with RetentionPolicy.RUNTIME).
|
boolean |
enableAnnotationInfo
If true, enables the saving of annotation info (for class, field, method or method parameter annotations)
during the scan.
|
boolean |
enableClassInfo
If true, scan classfile bytecodes, producing
ClassInfo objects. |
boolean |
enableExternalClasses
If true, allow external classes (classes outside of accepted packages) to be returned in the ScanResult, if
they are directly referred to by an accepted class, as a superclass, implemented interface or annotation.
|
boolean |
enableFieldInfo
If true, enables the saving of field info during the scan.
|
boolean |
enableInterClassDependencies
If true, enables the determination of inter-class dependencies.
|
boolean |
enableMemoryMapping
If true, use a
MappedByteBuffer rather than the FileChannel API to access file content. |
boolean |
enableMethodInfo
If true, enables the saving of method info during the scan.
|
boolean |
enableStaticFinalFieldConstantInitializerValues
Enable the storing of constant initializer values for static final fields in ClassInfo objects.
|
boolean |
enableSystemJarsAndModules
If true, system jarfiles (rt.jar) and system packages and modules (java.*, jre.*, etc.) should be scanned .
|
boolean |
extendScanningUpwardsToExternalClasses
If true, when classes have superclasses, implemented interfaces or annotations that are external classes,
those classes are also scanned.
|
boolean |
ignoreClassVisibility
If true, ignore class visibility.
|
boolean |
ignoreFieldVisibility
If true, ignore field visibility.
|
boolean |
ignoreMethodVisibility
If true, ignore method visibility.
|
boolean |
ignoreParentClassLoaders
If true, do not fetch paths from parent classloaders.
|
boolean |
ignoreParentModuleLayers
If true, do not scan module layers that are the parent of other module layers.
|
boolean |
initializeLoadedClasses
Whether to initialize classes when loading them.
|
AcceptReject.AcceptRejectLeafname |
jarAcceptReject
Jar accept/reject criteria (leafname only, ending in ".jar").
|
AcceptReject.AcceptRejectLeafname |
libOrExtJarAcceptReject
lib/ext jar accept/reject criteria (leafname only, ending in ".jar").
|
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-backed
ByteBuffer when it
is deflated, in order for the inner jar's entries to be read. |
AcceptReject.AcceptRejectWholeString |
moduleAcceptReject
Module accept/reject criteria (with separator '.').
|
ModulePathInfo |
modulePathInfo
Commandline module path parameters.
|
java.util.List<java.lang.ClassLoader> |
overrideClassLoaders
If non-null, this list of ClassLoaders will be searched instead of the visible/context ClassLoader(s).
|
java.util.List<java.lang.Object> |
overrideClasspath
If non-null, specifies a list of classpath elements (String,
URL or URI to use to override
the default classpath. |
java.util.List<java.lang.Object> |
overrideModuleLayers
If non-null, this list of ModuleLayers will be searched instead of the visible ModuleLayers.
|
AcceptReject.AcceptRejectWholeString |
packageAcceptReject
Package accept/reject criteria (with separator '.').
|
AcceptReject.AcceptRejectPrefix |
packagePrefixAcceptReject
Package prefix accept/reject criteria, for recursive scanning (with separator '
|
AcceptReject.AcceptRejectWholeString |
pathAcceptReject
Path accept/reject criteria (with separator '/').
|
AcceptReject.AcceptRejectPrefix |
pathPrefixAcceptReject
Path prefix accept/reject criteria, for recursive scanning (with separator '/', ending in '/').
|
boolean |
removeTemporaryFilesAfterScan
If true, nested jarfiles (jarfiles within jarfiles) that are extracted during scanning are removed from their
temporary directory (e.g.
|
boolean |
scanDirs
If true, scan directories.
|
boolean |
scanJars
If true, scan jarfiles.
|
boolean |
scanModules
If true, scan modules.
|
boolean |
scanNestedJars
If true, scan nested jarfiles (jarfiles within jarfiles).
|
| Constructor and Description |
|---|
ScanSpec()
Constructor for deserialization.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClassLoader(java.lang.ClassLoader classLoader)
Add a ClassLoader to the list of ClassLoaders to scan.
|
void |
addClasspathOverride(java.lang.Object overrideClasspathElement)
Override the automatically-detected classpath with a custom path.
|
void |
addModuleLayer(java.lang.Object moduleLayer)
Add a ModuleLayer to the list of ModuleLayers to scan.
|
boolean |
classfileIsSpecificallyAccepted(java.lang.String relativePath)
Returns true if the given relative path (for a classfile name, including ".class") matches a
specifically-accepted (and non-rejected) classfile's relative path.
|
boolean |
classOrPackageIsRejected(java.lang.String className)
Returns true if the class is specifically rejected, or is within a rejected package.
|
ScanSpec.ScanSpecPathMatch |
dirAcceptMatchStatus(java.lang.String relativePath)
Returns true if the given directory path is a descendant of a rejected path, or an ancestor or descendant of
an accepted path.
|
void |
enableURLScheme(java.lang.String scheme)
Allow a specified URL scheme in classpath elements.
|
void |
filterClasspathElements(java.lang.Object filterLambda)
Add a classpath element filter.
|
void |
log(LogNode log)
Write to log.
|
void |
overrideClassLoaders(java.lang.ClassLoader... overrideClassLoaders)
Completely override the list of ClassLoaders to scan.
|
void |
overrideModuleLayers(java.lang.Object... overrideModuleLayers)
Completely override (and ignore) the visible ModuleLayers, and instead scan the requested ModuleLayers.
|
void |
sortPrefixes()
Sort prefixes to ensure correct accept/reject evaluation (see Issue #167).
|
public AcceptReject.AcceptRejectWholeString packageAcceptReject
public AcceptReject.AcceptRejectPrefix packagePrefixAcceptReject
public AcceptReject.AcceptRejectWholeString pathAcceptReject
public AcceptReject.AcceptRejectPrefix pathPrefixAcceptReject
public AcceptReject.AcceptRejectWholeString classAcceptReject
public AcceptReject.AcceptRejectWholeString classfilePathAcceptReject
public AcceptReject.AcceptRejectWholeString classPackageAcceptReject
public AcceptReject.AcceptRejectWholeString classPackagePathAcceptReject
public AcceptReject.AcceptRejectWholeString moduleAcceptReject
public AcceptReject.AcceptRejectLeafname jarAcceptReject
public AcceptReject.AcceptRejectWholeString classpathElementResourcePathAcceptReject
public AcceptReject.AcceptRejectLeafname libOrExtJarAcceptReject
public boolean scanJars
public boolean scanNestedJars
public boolean scanDirs
public boolean scanModules
public boolean enableClassInfo
ClassInfo objects.public boolean enableFieldInfo
ClassInfo.getFieldInfo(). By default, field info is not scanned, for efficiency.public boolean enableMethodInfo
ClassInfo.getMethodInfo(). By default, method info is not scanned, for efficiency.public boolean enableAnnotationInfo
ClassInfo.getAnnotationInfo() etc. By
default, annotation info is not scanned, for efficiency.public boolean enableStaticFinalFieldConstantInitializerValues
public boolean enableInterClassDependencies
public boolean enableExternalClasses
public boolean enableSystemJarsAndModules
public boolean ignoreClassVisibility
public boolean ignoreFieldVisibility
public boolean ignoreMethodVisibility
public boolean disableRuntimeInvisibleAnnotations
public boolean extendScanningUpwardsToExternalClasses
public java.util.Set<java.lang.String> allowedURLSchemes
public transient java.util.List<java.lang.ClassLoader> addedClassLoaders
public transient java.util.List<java.lang.ClassLoader> overrideClassLoaders
public transient java.util.List<java.lang.Object> addedModuleLayers
public transient java.util.List<java.lang.Object> overrideModuleLayers
public java.util.List<java.lang.Object> overrideClasspath
URL or URI to use to override
the default classpath.public transient java.util.List<java.lang.Object> classpathElementFilters
public boolean initializeLoadedClasses
public boolean removeTemporaryFilesAfterScan
ScanResult finalizer, or on JVM exit.public boolean ignoreParentClassLoaders
public boolean ignoreParentModuleLayers
public ModulePathInfo modulePathInfo
public int maxBufferedJarRAMSize
ByteBuffer 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:// or https:// classpath
URL to RAM. Once this many bytes have been read from the URL's InputStream, 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 no http:// or https://
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.
public boolean enableMemoryMapping
MappedByteBuffer rather than the FileChannel API to access file content.public void sortPrefixes()
public void addClasspathOverride(java.lang.Object overrideClasspathElement)
overrideClasspathElement - The classpath element to add as an override to the default classpath.public void filterClasspathElements(java.lang.Object filterLambda)
ClassGraph.ClasspathElementFilter or
ClassGraph.ClasspathElementURLFilter should return true if the path string or URL passed to it is a path
that should be scanned.filterLambda - The classpath element filter to apply to all discovered classpath elements, to decide which should
be scanned.public void addClassLoader(java.lang.ClassLoader classLoader)
classLoader - The classloader to add.public void enableURLScheme(java.lang.String scheme)
scheme - the scheme, e.g. "http".public void overrideClassLoaders(java.lang.ClassLoader... overrideClassLoaders)
overrideClassLoaders - The classloaders to override the default context classloaders with.public void addModuleLayer(java.lang.Object moduleLayer)
This call is ignored if it is called before overrideModuleLayers(Object...).
moduleLayer - The additional ModuleLayer to scan. (The parameter is of type Object for backwards
compatibility with JDK 7 and JDK 8, but the argument should be of type ModuleLayer.)public void overrideModuleLayers(java.lang.Object... overrideModuleLayers)
This call is ignored if overrideClasspath() is called.
overrideModuleLayers - The ModuleLayers to scan instead of the automatically-detected ModuleLayers. (The parameter is of
type Object[] for backwards compatibility with JDK 7 and JDK 8, but the argument should be
of type ModuleLayer[].)public ScanSpec.ScanSpecPathMatch dirAcceptMatchStatus(java.lang.String relativePath)
relativePath - the relative pathScanSpec.ScanSpecPathMatchpublic boolean classfileIsSpecificallyAccepted(java.lang.String relativePath)
relativePath - the relative pathpublic boolean classOrPackageIsRejected(java.lang.String className)
className - the class name