FastClasspathScanner was renamed to ClassGraph for the version 4 release. There are several reasons behind the name change:
The version 4 release is the result of a huge amount of refactoring, code cleanup and API simplification. The resulting API is now much more flexible, powerful and uniform than the Version 3 API. See the docs for the Version 4 API for an overview. Scanning speed has improved through the use of memory-mapped file buffers where possible, and through some optimization work.
If you want to stay on the old FastClasspathScanner v3 API, you should depend specifically on fast-classpath-scanner
version 3.1.13.
Important: All significant development will be continuing in ClassGraph moving forward, and numerous bugs have been fixed between FastClasspathScanner version 3.1.13 and ClassGraph version 4. Therefore, it is highly recommended that you port your code from the FastClasspathScanner version 3 API to the ClassGraph version 4 API.
Porting from the version 3 to the version 4 API:
io.github.lukehutch.fast-classpath-scanner
to io.github.classgraph
, and the artifact id has changed from fast-classpath-scanner
to classgraph
. The Maven dependency rule is now:
<dependency> <groupId>io.github.classgraph</groupId> <artifactId>classgraph</artifactId> <version>LATEST</version> </dependency>
io.github.classgraph
-- you will need to update your requires
statement in the module-info.java
of a modular project to:
requires io.github.classgraph;
new FastClasspathScanner()
to new ClassGraph()
.ClassGraph
constructor doesn't accept any parameters at all now)..acceptPackages()
/ .rejectPackages()
, as opposed to in arguments to the constructor..acceptPackages()
, or .enableClassInfo()
, or .enableAllInfo()
(see the wiki link above). If you don't do this, you can't query the ScanResult
for ClassInfo
objects..ignoreClassVisibility()
or .enableAllInfo()
to scan non-public classes..enableAnnotationInfo()
or .enableAllInfo()
to scan annotations..disableNestedJarScanning()
if you don't care about scanning lib jars within jars.Class<?>
references. They caused too many problems, due to the interactions between classloading and classpath scanning. You will need to convert your MatchProcessors to use the ClassInfo
API (see the wiki).ScanResult
should be assigned in a try-with-resources block so that resources are freed after you have finished with the results of the scan (see code examples in the documentation).ScanResult#getClassNameToClassInfo()
is now replaced with a richer API for fetching ClassInfo
objects from the ScanResult
.
scanResult.getClassNameToClassInfo().get(className)
becomes scanResult.getClassInfo(className)
getNamesOf...()
classes have been removed in favor of methods that return ClassInfoList
lists of ClassInfo
objects. However, you can call ClassInfoList#getNames()
to get a list of the class names. e.g.:
scanResult.getNamesOfAllClasses()
becomes scanResult.getAllClasses().getNames()
scanResult.getNamesOfSubclassesOf(className)
becomes scanResult.getSubclasses(className).getNames()
scanResult.getClassNameToClassInfo().keySet()
becomes scanResult.getAllClasses().getNames()
new ClassGraph(pkg).disableRecursiveScanning()
becomes new ClassGraph().acceptPackagesNonRecursive(pkg)
.getUniqueClasspathElementURLs()
becomes .getClasspathURLs()
, etc.scanResult.getNamesOfAnnotationsWithMetaAnnotation(metaAnnotationName)
becomes scanResult.getAllAnnotations().filter(ci -> ci.hasAnnotation(metaAnnotationName)).getNames()
. To List the names of all meta-annotations, usescanResult.getAllAnnotations().filter(ci -> !ci.getAnnotations().isEmpty()).getNames()
. If you want all direct annotations on a class (without including meta-annotations), you can call scanResult.getAllAnnotations().getDirect().getNames()
.new FastClasspathScanner("!!")
becomes new FastClasspathScanner().enableSystemPackages()
.ClassInfo#getClassName()
becomes ClassInfo#getName()
; MethodInfo#getMethodName()
becomes MethodInfo#getName()
; FieldInfo#getFieldName()
becomes FieldInfo#getFieldName()
; etc.ClassInfo#getClassRef()
becomes ClassInfo#loadClass()
.ClassInfo
results are now returned in a ClassInfoList
, MethodInfo
in a MethodInfoList
, FieldInfo
in a FieldInfoList
, etc.ClassInfoList
, to visualize the result of any filter criteria.
scanResult.generateClassGraphDotFile()
becomes scanResult.getAllClasses().generateClassGraphDotFile(File file)
Resource
and ResourceInfo
system (see the API docs).To view the documentation for the older Version 3 API:
git clone https://github.com/classgraph/classgraph.wiki.git cd classgraph.wiki git checkout v3
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4