An uber-fast parallelized Java classpath scanner and module scanner.

Overview

ClassGraph

ClassGraph Logo       Duke Award Logo

ClassGraph is an uber-fast parallelized classpath scanner and module scanner for Java, Scala, Kotlin and other JVM languages.

ClassGraph won a Duke's Choice Award (a recognition of the most useful and/or innovative software in the Java ecosystem) at Oracle Code One 2018. Thanks to all the users who have reported bugs, requested features, offered suggestions, and submitted pull requests to help get ClassGraph to where it is today.

Platforms: Windows, Mac OS X, Linux, Android (build-time) Languages: Java, Scala, Kotlin, etc. JDK compatibility: 7, 8, 9+ (JPMS)
Build Status GitHub issues lgtm alerts lgtm code quality Codacy Badge
Dependencies: none Dependents GitHub stars chart
Maven Central Javadocs
Gitter chat
License: MIT

ClassGraph is now fully stable. This project adheres to the Zero Bugs Commitment.

ClassGraph vs. Java Introspection

ClassGraph has the ability to "invert" the Java class and/or reflection API, or has the ability to index classes and resources. For example, the Java class and reflection API can tell you the superclass of a given class, or the interfaces implemented by a given class, or can give you the list of annotations on a class; ClassGraph can find all classes that extend a given class (all subclasses of a given class), or all classes that implement a given interface, or all classes that are annotated with a given annotation. The Java API can load the content of a resource file with a specific path in a specific ClassLoader, but ClassGraph can find and load all resources in all classloaders with paths matching a given pattern.

Examples

The following code prints the name of all classes in the package com.xyz or its subpackages, anywhere on the classpath or module path, that are annotated with an annotation of the form @com.xyz.Route("/pages/home.html"), along with the annotation parameter value. This is accomplished without loading or initializing any of the scanned classes.

String pkg = "com.xyz";
String routeAnnotation = pkg + ".Route";
try (ScanResult scanResult =
        new ClassGraph()
            .verbose()               // Log to stderr
            .enableAllInfo()         // Scan classes, methods, fields, annotations
            .acceptPackages(pkg)     // Scan com.xyz and subpackages (omit to scan all packages)
            .scan()) {               // Start the scan
    for (ClassInfo routeClassInfo : scanResult.getClassesWithAnnotation(routeAnnotation)) {
        AnnotationInfo routeAnnotationInfo = routeClassInfo.getAnnotationInfo(routeAnnotation);
        List<AnnotationParameterValue> routeParamVals = routeAnnotationInfo.getParameterValues();
        // @com.xyz.Route has one required parameter
        String route = (String) routeParamVals.get(0).getValue();
        System.out.println(routeClassInfo.getName() + " is annotated with route " + route);
    }
}

The following code finds all JSON files in META-INF/config in all ClassLoaders or modules, and calls the method readJson(String path, String content) with the path and content of each file.

try (ScanResult scanResult = new ClassGraph().acceptPathsNonRecursive("META-INF/config").scan()) {
    scanResult.getResourcesWithExtension("json")
              .forEachByteArray((Resource res, byte[] content) -> {
                  readJson(res.getPath(), new String(content, StandardCharsets.UTF_8));
              });
}

See the code examples page for more examples of how to use the ClassGraph API.

Capabilities

ClassGraph provides a number of important capabilities to the JVM ecosystem:

  • ClassGraph has the ability to build a model in memory of the entire relatedness graph of all classes, annotations, interfaces, methods and fields that are visible to the JVM, and can even read type annotations. This graph of class metadata can be queried in a wide range of ways, enabling some degree of metaprogramming in JVM languages -- the ability to write code that analyzes or responds to the properties of other code.
  • ClassGraph reads the classfile bytecode format directly, so it can read all information about classes without loading or initializing them.
  • ClassGraph is fully compatible with the new JPMS module system (Project Jigsaw / JDK 9+), i.e. it can scan both the traditional classpath and the module path. However, the code is also fully backwards compatible with JDK 7 and JDK 8 (i.e. the code is compiled in Java 7 compatibility mode, and all interaction with the module system is implemented via reflection for backwards compatibility).
  • ClassGraph scans the classpath or module path using carefully optimized multithreaded code for the shortest possible scan times, and it runs as close as possible to I/O bandwidth limits, even on a fast SSD.
  • ClassGraph handles more classpath specification mechanisms found in the wild than any other classpath scanner, making code that depends upon ClassGraph maximally portable.
  • ClassGraph can scan the classpath and module path either at runtime or at build time (e.g. to implement annotation processing for Android).
  • ClassGraph can find classes that are duplicated or defined more than once in the classpath or module path, which can help find the cause of strange class resolution behaviors.
  • ClassGraph can create GraphViz visualizations of the class graph structure, which can help with code understanding: (click to enlarge; see graph legend here)

Class graph visualization

Downloading

Maven dependency

Replace X.Y.Z below with the latest release number. (Alternatively, you could use LATEST in place of X.Y.Z instead if you just want to grab the latest version -- although be aware that that may lead to non-reproducible builds, since the ClassGraph version number could increase at any time. You could use dependency locking to address this.)

<dependency>
    <groupId>io.github.classgraph</groupId>
    <artifactId>classgraph</artifactId>
    <version>X.Y.Z</version>
</dependency>

See instructions for use as a module.

Pre-built JARs

You can get pre-built JARs (usable on JRE 7 or newer) from Sonatype.

Building from source

ClassGraph must be built on JDK 8 or newer (due to the presence of @FunctionalInterface annotations on some interfaces), but is built using -target 1.7 for backwards compatibility with JRE 7.

The following commands will build the most recent version of ClassGraph from git master. The compiled package will then be in the "classgraph/target" directory.

git clone https://github.com/classgraph/classgraph.git
cd classgraph
export JAVA_HOME=/usr/java/default   # Or similar -- Maven needs JAVA_HOME
./mvnw -Dmaven.test.skip=true package

This will allow you to build a local SNAPSHOT jar in target/. Alternatively, use ./mvnw -Dmaven.test.skip=true install to build a SNAPSHOT jar and then copy it into your local repository, so that you can use it in your Maven projects. Note that may need to do ./mvnw dependency:resolve in your project if you overwrite an older snapshot with a newer one.

./mvnw -U updates from remote repositories an may overwrite your local artifact. But you can always change the artifactId or the groupId of your local ClassGraph build to place your local build artifact in another location within your local repository.

Documentation

See the wiki for complete documentation and usage information.

ClassGraph was known as FastClasspathScanner prior to version 4. See the porting notes for information on porting from the older FastClasspathScanner API.

Mailing List

  • Feel free to subscribe to the ClassGraph-Users email list for updates, or to ask questions.
  • There is also a Gitter room for discussion of ClassGraph.

Sponsorship

ClassGraph was written by Luke Hutchison (@LH on Twitter).

If ClassGraph is critical to your work, you can help fund further development through the GitHub Sponsors Program.

Acknowledgments

ClassGraph would not be possible without contributions from numerous users, including in the form of bug reports, feature requests, code contributions, and assistance with testing.

Alternatives

Some other classpath scanning mechanisms include:

License

The MIT License (MIT)

Copyright (c) 2020 Luke Hutchison

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Scanning on LinuxKit doesn't work when scan root is not root directory of a jarfile

    Scanning on LinuxKit doesn't work when scan root is not root directory of a jarfile

    https://github.com/lukehutch/fast-classpath-scanner/blob/c07698e2b7dea93b102b35f04f369bf5e911b789/src/main/java/io/github/lukehutch/fastclasspathscanner/scanner/RelativePath.java#L224

    The line indicated is getting null from nestedJarHandler, when then is wrapped and throw as an IOException. This is preventing matching classes from being processed for a jar.

    2018-01-23T18:52:34.862+0000    FastClasspathScanner    -- Searching for "Class-Path:" entries within manifest files
    2018-01-23T18:52:34.874+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/localedata.jar
    2018-01-23T18:52:34.874+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/cldrdata.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/zipfs.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/sunec.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/jfxrt.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/nashorn.jar
    2018-01-23T18:52:34.877+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/jaccess.jar
    2018-01-23T18:52:34.878+0000    FastClasspathScanner    ---- Ignoring JRE jar: /usr/java/jdk1.8.0_131/jre/lib/ext/dnsns.jar
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ---- Could not canonicalize path: /acceptance-1.22-SNAPSHOT.jar!/BOOT-INF/classes
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------ java.io.IOException: Exception while getting jarfile jar:file:/acceptance-1.22-SNAPSHOT.jar!/BOOT-INF/classes
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.scanner.RelativePath.getFile(RelativePath.java:223)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.scanner.RelativePath.exists(RelativePath.java:290)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.scanner.RelativePath.isValidClasspathElement(RelativePath.java:313)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.scanner.Scanner$1.processWorkUnit(Scanner.java:235)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.scanner.Scanner$1.processWorkUnit(Scanner.java:224)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.utils.WorkQueue.runWorkLoop(WorkQueue.java:182)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.utils.WorkQueue$1.call(WorkQueue.java:147)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.utils.WorkQueue$1.call(WorkQueue.java:144)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at java.lang.Thread.run(Thread.java:748)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------ Caused by: java.lang.NullPointerException
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  at io.github.lukehutch.fastclasspathscanner.scanner.RelativePath.getFile(RelativePath.java:208)
    2018-01-23T18:52:34.880+0000    FastClasspathScanner    ------  ... 11 more
    

    This has been seen using 2.9.5 or later releases. 2.9.4 is a version that does not have this problem.

    opened by ncoe 59
  • OOM while loading classpath with large JAR files

    OOM while loading classpath with large JAR files

    Hi team, thank you for making this awesome lib!

    So I'm working on a project to generate a graph for dependencies downloaded by a specific Gradle build.

    I managed to write a plugin for Gradle and get all JARs associated with a project once build is finished, and then call ClassGraph's scan function within the plugin, and using overrideClasspath to point classpath to all JARs.

    While these JARs are being necessary to generate a complete graph, the entire size of those JARs could be extremely large (2GB+). Which leads to Gradle to raise OOM exception since the heap is exhausted.

    I'm wondering what's the best practice to deal with this kind of situation where the JARs are very large? Is that possible for ClassGraph to process chunk by chunk?

    Thanks in advance!

    opened by JBrVJxsc 57
  • Incompatible types

    Incompatible types

    I have the following code:

    ScanResult result = new ClassGraph().verbose().enableAllInfo().scan(); ClassInfoList infolist = result.getSubclasses("org.codehaus.groovy.runtime.m12n.ExtensionModule").directOnly(); ClassInfo info = infolist.get("VertxExtensionModule");
    ExtensionModule module = info.loadClass().newInstance();

    The last line complains abou incompatible types when compiling...

    "incompatible types: capture#1 of ? cannot be converted to org.codehaus.groovy.runtime.m12n.ExtensionModule"

    Is this a normal behaviour?

    opened by aaloise 55
  • It seems that the API cannot work well in Eclipse PDE

    It seems that the API cannot work well in Eclipse PDE

    Thank you for the API. When I used it in a main method, it worked well, but I cannot use it to access my Eclipse plug-in's packages when the plug-in running in an Eclipse PDE. May you tell me how to solve this problem, please? The code is shown below List classNames = new FastClasspathScanner(this.pakageName).verbose().scan().getNamesOfAllClasses();

    List classNames = new FastClasspathScanner(this.pakageName).scan().getNamesOfAllClasses();

    opened by binder6 55
  • ConcurrentModificationException while getting ScanResult output

    ConcurrentModificationException while getting ScanResult output

    Sometimes this happens:

    java.util.ConcurrentModificationException
     	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:937)
     	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:891)
     	at io.github.classgraph.ScanResult.getResourcesMatchingPattern(ScanResult.java:383)
    

    My call looks innocent enough:

    val configUrls = new ClassGraph().scan()
        .getResourcesMatchingPattern(configRegex.r.pattern)
        .asScala
        .map(_.getURL)
    

    Is it possible to fix it?

    opened by pshirshov 45
  • FD leak causes invalid ScanResults when run on large classpath

    FD leak causes invalid ScanResults when run on large classpath

    After upgrading Atomix to ClassGraph i'm seeing that it fails to load public inner classes yet I haven't changed anything wrt class loaders..

    java.lang.IllegalArgumentException: Could not load class io.atomix.protocols.backup.MultiPrimaryProtocol$Type
    
    	at io.github.classgraph.ScanResult.loadClass(ScanResult.java:720)
    	at io.github.classgraph.ScanResultObject.loadClass(ScanResultObject.java:145)
    	at io.github.classgraph.ClassInfo.loadClass(ClassInfo.java:1691)
    	at io.atomix.core.impl.ClasspathScanningAtomixRegistry.lambda$new$0(ClasspathScanningAtomixRegistry.java:56)
    	at java.util.ArrayList.forEach(ArrayList.java:1249)
    	at io.atomix.core.impl.ClasspathScanningAtomixRegistry.<init>(ClasspathScanningAtomixRegistry.java:52)
    	at io.atomix.core.impl.ClasspathScanningAtomixRegistry.<init>(ClasspathScanningAtomixRegistry.java:41)
    	at io.atomix.core.AtomixRegistry.registry(AtomixRegistry.java:49)
    	at io.atomix.core.Atomix.builder(Atomix.java:288)
    	at io.atomix.core.Atomix.builder(Atomix.java:275)
    	at io.atomix.core.AbstractAtomixTest.buildAtomix(AbstractAtomixTest.java:76)
    	at io.atomix.core.AbstractAtomixTest.createAtomix(AbstractAtomixTest.java:110)
    	at io.atomix.core.AbstractAtomixTest.createAtomix(AbstractAtomixTest.java:103)
    	at io.atomix.core.AbstractPrimitiveTest.setupCluster(AbstractPrimitiveTest.java:82)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    Caused by: java.lang.IllegalArgumentException: No classloader was able to load class io.atomix.protocols.backup.MultiPrimaryProtocol$Type
    	at io.github.classgraph.ScanResult.loadClass(ScanResult.java:682)
    	at io.github.classgraph.ScanResult.loadClass(ScanResult.java:715)
    	... 28 more
    
    opened by johnou 40
  • Kotlin type parsing fixes

    Kotlin type parsing fixes

    I have another issue after the latest update. I'm getting "Parameter number mismatch" when trying to parse a class file generated by Kotlin for an enum.

    It looks like the method has two parameters which are marked as synthetic, but when trying to generate the method signature it is failing here because there don't seem to be any param types.

    I've created a test using the dodgy class file here.

    Log file (with some additional debugging output) log2.txt

    Let me know if you need any more info.

    opened by anthonykeenan 39
  • ClassPath detection incomplete/non-deterministic when using parallel scans

    ClassPath detection incomplete/non-deterministic when using parallel scans

    On version 4.8.138

    If I construct a ClassGraph instance and have it scan the current classloader, eg:

    new ClassGraph()
      .addClassLoader(classLoader)
      .scan()
      .getClasspathFiles()
    

    The results change each time I run it and are generally incomplete (missing many entries). For example, I frequently will only get <50 entries back from a classpath of 800+ items.

    If I simply change scan() to scan(1), the results are correct and deterministic. I do have logs for the incorrect and correct runs, but need to work on trying to sanitize them before I upload them here.

    I suspect the problem might be that the root/only direct classpath entry is a classpath manifest jar. That then expands to a large (800+) jar classpath.

    Any ideas what might be going on here?

    opened by steveniemitz 37
  • module-info.java should contain

    module-info.java should contain "requires java.logging"

    Version 4.6.32

    When I run new ClassGraph().verbose().scan() under IntellJ IDEA I get:

    Exception in thread "main" java.lang.IllegalAccessError: class nonapi.io.github.classgraph.utils.LogNode (in module io.github.classgraph) cannot access class java.util.logging.Logger (in module java.logging) because module io.github.classgraph does not read module java.logging
    	at [email protected]/nonapi.io.github.classgraph.utils.LogNode.<clinit>(LogNode.java:51)
    	at [email protected]/io.github.classgraph.ClassGraph.verbose(ClassGraph.java:103)
    

    I believe adding requires java.logging to your module-info.java file will fix this problem.

    opened by cowwoc 37
  • Classgraph holds lock on file

    Classgraph holds lock on file

    On windows i'm facing the issue, that ClassGraph seems to hold a lock on the scanned ressources. After the scanning i'm not able to delete files in the scanned directory.

    I could not find any api, which would prevent this behavior. Maybe this is a bug?

    public static void main(String[] args) throws IOException {
        ClassGraph classGraph = new ClassGraph()
                .overrideClasspath(new File("C:\\temp"))
                .verbose()
                .enableAllInfo();
    
        ClassInfoList info = getAllClasses(classGraph);
        System.out.println(info.size());
        
        File f = new File("C:\\temp\\org\\apache\\commons\\io\\comparator\\SizeFileComparator.class");
        Files.delete(f.toPath());
    }
    
    private static ClassInfoList getAllClasses(ClassGraph classGraph) {
        try (ScanResult result = classGraph.scan())
        {
          return result.getAllClasses();
        }
    }
    

    In this case Files.delete(f.toPath()) throws the following exception:

    Exception in thread "main" java.nio.file.FileSystemException: C:\temp\org\apache\commons\io\comparator\ReverseComparator.class: The process cannot access the file because it is being used by another process.
    	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
    	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    	at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
    	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
    	at java.nio.file.Files.delete(Files.java:1126)
    	at ch.ivyteam.ivy.java.restricted.AnnotatedTypes.main(AnnotatedTypes.java:74)
    

    verbose.log

    opened by alexsuter 33
  • Feedback on Version 4 beta

    Feedback on Version 4 beta

    @GedMarc @HybridHB @miho @ahamana @johnou @seanf @hepin1989 @davidmoshal @johnfg10 @anthonykeenan @danthegoodman @sbespalov @sergey-morenets @dantesun @PascalSchumacher @mrlambeth @Wafflemon @andrebrait:

    You all reported bugs recently for FastClasspathScanner. I just pushed out the biggest update to date for this project, as version 4.0.0-beta-1, with a signifcantly revamped API. I would really appreciate it if you could please test out porting your existing code to this new API. Please let me know about any porting difficulties you run into, as well as any performance regressions.

    Release notes and porting tips are here:

    https://github.com/lukehutch/fast-classpath-scanner/releases/tag/fast-classpath-scanner-4.0.0-beta-1

    The new API docs are here:

    https://github.com/lukehutch/fast-classpath-scanner/wiki

    Thanks!

    opened by lukehutch 32
  • Add API for resolving return type, field type, parameter type with replacement of the actual type arguments

    Add API for resolving return type, field type, parameter type with replacement of the actual type arguments

    Here's a sample case:

    interface Base<T> {
        T getT();
    }
    
    abstract class Derived implements Base<String> {
    }
    

    I want a runtime API to resolve the type of getT in Derived class as String.

    In other words, something like TypeParameterResolver#resolveReturnType from mybatis https://github.com/mybatis/mybatis-3/blob/4b72ae4ffbf1029162233d3eb77c2f0b891c24fa/src/main/java/org/apache/ibatis/reflection/TypeParameterResolver.java#L50-L59, however, mybatis does not consider TypeParameterResolver its API.

    WDYT?

    opened by vlsi 17
  • Incorrect base path for relative paths

    Incorrect base path for relative paths

    I'm trying to troubleshoot a problem with ClassGraph in a proprietary project. I'm not 100% sure this is a bug, it's very possible that I'm just not using ClassGraph correctly.

    The problem is that certain classes are skipped from scanning during some tests. This happens in an OSGi environment, and I see similar problems when running in Eclipse via "Run As ▶︎ JUnit Plug-in Test" or in Maven via tycho-surefire-plugin. However, the problem does not happen when running outside of an OSGi container. In both cases, the problematic classes are loaded from a local directory rather than from a packaged JAR file.

    In the verbose output I see the following for the skipped classes:

    2022-11-20T17:34:27.376-0800	ClassGraph	------------ Scanning directory: /Users/mirko/git/fxx/fxx.api/target/classes (took 0.005631 sec)
    2022-11-20T17:34:27.376-0800	ClassGraph	-------------- Scanning directory: /Users/mirko/git/fxx/fxx.api/target/classes/fxx (took 0.005489 sec)
    2022-11-20T17:34:27.376-0800	ClassGraph	---------------- Scanning directory: /Users/mirko/git/fxx/fxx.api/target/classes/fxx/annotation (took 0.001166 sec)
    2022-11-20T17:34:27.379-0800	ClassGraph	------------------ Found classfile within subpackage of accepted package: fxx/fxx.api/target/classes/fxx/lang/String.class
    2022-11-20T17:34:40.495-0800	ClassGraph	-------------------- Parsing classfile (took 0.000126 sec)
    2022-11-20T17:34:40.495-0800	ClassGraph	---------------------- Skipping classfile: Relative path fxx/fxx.api/target/classes/fxx/lang/String.class does not match class name fxx.lang.String
    

    As indicated by the verbose output, the fxx.lang.String class is not scanned for annotations, and neither are any of the other classes in the same bundle.

    What strikes me as odd in this output are the relative paths shown in the skip messages. For example, if fxx/fxx.api/target/classes/fxx/lang/String.class is the relative path for the fxx.lang.String class, this would seem to indicate that this path is relative to my local git folder (/Users/mirko/git), which seems completely random. It might make a little more sense to me if the paths were relative to my home folder (/Users/mirko) or to the current directory where the build is executed (/Users/mirko/git/fxx in this case). In my mind, the correct base path for relative path names should be /Users/mirko/git/fxx/fxx.api/target/classes, in which case the derived relative paths would end up correctly (I believe).

    The scanning code itself is also fairly standard (using Xtend syntax):

      Supplier<Map<Double, String>> bindings = Suppliers.memoize
      [
        val ClassGraph classGraph = new ClassGraph()
          . enableClassInfo
          . enableAnnotationInfo
          . rejectPackages(skippedPackages)
          . verbose
        newImmutableMap
        (
          try (val ScanResult scan = classGraph.scan)
          {
            scan.getClassesWithAnnotation(integrationPointAnnotation).loadClasses.map
            [
              integrationPoint -> it
            ]
            . filter[key !== null]
            . flatMap
            [
              #[key.annotationValue -> value.name] + value.declaredMethods
              . map[integrationPoint -> name]
              . filter[key !== null]
              . map[key.annotationValue -> value]
            ]
          }
        )
      ]
    

    Am I missing some configuration here or could this be a bug in ClassGraph? I'm using (the slightly outdated) version 4.8.138, and upgrading is a bit involved with the way the build is set up.

    opened by raner 6
  • Duplicate resources found with Maven / Surefire patching test resources into the module path.

    Duplicate resources found with Maven / Surefire patching test resources into the module path.

    Find a simple reproducer attached (mpcg.zip): Maven / IntelliJ and friends will patch test classes and test resources into the main module when there's a module-info.java in the project (--patch-module mpcg=/Users/msimons/Projects/misc/mpcg/target/test-classes -).

    When this happens, classgraph will discover resources multiple times.

    I don't repeat the code from the reproducer here,

    .
    ├── pom.xml
    └── src
        ├── main
        │   ├── java
        │   │   ├── foo
        │   │   │   └── App.java
        │   │   └── module-info.java
        │   └── resources
        └── test
            ├── java
            │   └── foo
            │       └── AppTest.java
            └── resources
                └── stuff
                    └── whatever.cypher
    
    10 directories, 5 files
    

    In this scenario,

    ScanResult scanResult = new ClassGraph().acceptPaths("stuff").scan();
    ResourceList allResources = scanResult.getAllResources().nonClassFilesOnly()
    

    will give me whatever.cypher twice

    [file:/Users/msimons/Projects/misc/mpcg/target/classes/stuff/whatever.cypher,
        file:/Users/msimons/Projects/misc/mpcg/target/test-classes/stuff/whatever.cypher]
    

    This can be fixed by

    <plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-surefire-plugin</artifactId>
    				<version>3.0.0-M7</version>
    				<configuration combine.self="append">
    					<!-- Add this and the test works… -->
    					<useModulePath>false</useModulePath>
    				</configuration>
    			</plugin>
    

    but this is maybe not desired to skip the module path completely.

    I am unsure if its an Maven issue or Classpath issue, though.

    cc @sbrannen you expressed interest in this on twitter.

    opened by michael-simons 1
  • ClassGraph does not scan java.lang.Object

    ClassGraph does not scan java.lang.Object

    I am using this code to get all classes of the java.lang package, however java.lang.Object is missing in the result of scanResult.getClasses();

    try (ScanResult scanResult = new ClassGraph() //
       .enableAllInfo() //
       .enableSystemJarsAndModules() //
       .acceptPackages("java.lang") //
       .scan() //
    ) {
       final var classes = scanResult.getAllClasses();
       for (final ClassInfo classInfo : classes) {
          System.out.println(classInfo.getName());
       }
    }
    

    I am using OpenJKD 11 with the latest classgraph release.

    opened by sebthom 1
  • When using wildfly 21, the jar under WEB-INF/lib will not be displayed.

    When using wildfly 21, the jar under WEB-INF/lib will not be displayed.

    Hello, I have a project deployed with wildfly21. I upgraded classgraph from 4.8.129 to 4.8.149 and put a test jar in the same directory as ant-1.10.11.jar in WEB-INF/lib.

    It is found that classgraph will no longer display the jars under WEB-INF/lib, leaving only the jar packages under standalone/tmp/vfs/deployment, which is not an expected result.

    for (Entry<String, ResourceList> dup :
            new ClassGraph().verbose().scan()
                .getAllResources()
                .classFilesOnly()
                .findDuplicatePaths()) {
        System.out.println(dup.getKey());
        for (Resource res : dup.getValue()) {
            System.out.println(" -> " + res.getURI());
        }
    }
    

    Here is the output under version 4.8.129, which has jars in both WEB-INF/lib and standalone/tmp/vfs/deployment directories.(The standalone/tmp/vfs/deployment directory will be generated when wildfly starts, and the duplicate classes in this directory are not what I need. I will remove it manually in later code.)

    2022-08-11 15:55:30,651 INFO [stdout] (default task-1) org/apache/tools/ant/AntClassLoader.class
    2022-08-11 15:55:30,651 INFO [stdout] (default task-1) -> jar:file:/E:/wildfly-21.0.2.Final/standalone/deployments/project.ear/project.war/WEB-INF/lib/ant-test.jar!/org/apache/tools/ant/AntClassLoader.class 
    2022-08-11 15:55:30,651 INFO [stdout] (default task-1) -> jar:file:/E:/wildfly-21.0.2.Final/standalone/deployments/project.ear/project.war/WEB-INF/lib/ant-1.10.11.jar!/org/apache/tools/ant/AntClassLoader.class 
    2022-08-11 15:55:30,651 INFO [stdout] (default task-1) -> jar:file:/E:/wildfly-21.0.2.Final/standalone/tmp/vfs/deployment/deployment3c10fbd71b13340a/ant-1.10.11.jar-3a7bfe1548c3a3e/ant-1.10.11.jar!/org/apache/tools/ant/AntClassLoader.class 
    2022-08-11 15:55:30,652 INFO [stdout] (default task-1) -> jar:file:/E:/wildfly-21.0.2.Final/standalone/tmp/vfs/deployment/deployment3c10fbd71b13340a/ant-test.jar-55a4bb8fdf420ca2/ant-test.jar!/org/apache/tools/ant/AntClassLoader.class 
    

    This is the output under version 4.8.149, it only has the jars under standalone/tmp/vfs/deployment.

    2022-08-11 15:40:48,028 INFO [stdout] (default task-1) org/apache/tools/ant/AntClassLoader.class
    2022-08-11 15:40:48,028 INFO [stdout] (default task-1) -> jar:file:/E:/wildfly-21.0.2.Final/standalone/tmp/vfs/deployment/deployment190ae1711ba8c466/ant-1.10.11.jar-edacd854758a48eb/ant-1.10.11.jar!/org/apache/tools/ant/AntClassLoader.class 
    2022-08-11 15:40:48,028 INFO [stdout] (default task-1) -> jar:file:/E:/wildfly-21.0.2.Final/standalone/tmp/vfs/deployment/deployment190ae1711ba8c466/ant-test.jar-be18d95f67ae544c/ant-test.jar!/org/apache/tools/ant/AntClassLoader.class
    

    My project needs to display duplicate classes in jar under WEB-INF/lib.

    Is this an issue? If not, is there any way to display the duplicate classes in the WEB-INF/lib directory?

    P.S. I called ClassGraph#verbose(), but the project outputs 20,000 classgraph logs, so if there is a need, tell me the part you need, and I will intercept it and upload it.

    opened by LanlingCL 1
  • [bug]: Parameter annotations in dynamic nested classes are parsed with a shift

    [bug]: Parameter annotations in dynamic nested classes are parsed with a shift

    Description

    I was trying to parse parameter annotations in the dynamic class constructor and found that ClassGraph applies annotations with a shift to the left. So the annotation for the first parameter goes to the implicit parameter with an instance of the parent class. The annotation for the second parameter comes to the first one.

    Here is my original code:

    public class BrokenAnnotation {
        class Dynamic {
            Dynamic(@Foo String param1, @Bar String param2) {}
        }
    }
    

    And ClassGraph parses it the following way:

    public class BrokenAnnotation {
        class Dynamic {
            Dynamic(@Foo BrokenAnnotation this$0, @Bar String param1, String param2) {}
        }
    }
    

    Expected behavior

    I expect ClassGraph to apply annotations as specified in the source code.

    Repro

    I have created a small reproduction example.

    ClassGraph#verbose()

    Jul 08, 2022 4:48:47 PM nonapi.io.github.classgraph.utils.LogNode flush
    INFO: 2022-07-08T16:48:46.960+0300	ClassGraph	ClassGraph version 4.8.149
    2022-07-08T16:48:46.963+0300	ClassGraph	Operating system: Windows 10 10.0 amd64
    2022-07-08T16:48:46.964+0300	ClassGraph	Java version: 11.0.2 / 11.0.2+9 (Oracle Corporation)
    2022-07-08T16:48:46.964+0300	ClassGraph	Java home: <...>\OpenJDK\jdk-11.0.2
    2022-07-08T16:48:47.009+0300	ClassGraph	ScanSpec:
    2022-07-08T16:48:47.009+0300	ClassGraph	-- packageAcceptReject:
    2022-07-08T16:48:47.010+0300	ClassGraph	-- packagePrefixAcceptReject:
    2022-07-08T16:48:47.010+0300	ClassGraph	-- pathAcceptReject:
    2022-07-08T16:48:47.011+0300	ClassGraph	-- pathPrefixAcceptReject:
    2022-07-08T16:48:47.011+0300	ClassGraph	-- classAcceptReject:
    2022-07-08T16:48:47.011+0300	ClassGraph	-- classfilePathAcceptReject:
    2022-07-08T16:48:47.011+0300	ClassGraph	-- classPackageAcceptReject:
    2022-07-08T16:48:47.011+0300	ClassGraph	-- classPackagePathAcceptReject:
    2022-07-08T16:48:47.011+0300	ClassGraph	-- moduleAcceptReject:
    2022-07-08T16:48:47.012+0300	ClassGraph	-- jarAcceptReject:
    2022-07-08T16:48:47.012+0300	ClassGraph	-- classpathElementResourcePathAcceptReject:
    2022-07-08T16:48:47.012+0300	ClassGraph	-- libOrExtJarAcceptReject:
    2022-07-08T16:48:47.013+0300	ClassGraph	-- scanJars: true
    2022-07-08T16:48:47.013+0300	ClassGraph	-- scanNestedJars: true
    2022-07-08T16:48:47.013+0300	ClassGraph	-- scanDirs: true
    2022-07-08T16:48:47.013+0300	ClassGraph	-- scanModules: true
    2022-07-08T16:48:47.013+0300	ClassGraph	-- enableClassInfo: true
    2022-07-08T16:48:47.013+0300	ClassGraph	-- enableFieldInfo: true
    2022-07-08T16:48:47.013+0300	ClassGraph	-- enableMethodInfo: true
    2022-07-08T16:48:47.014+0300	ClassGraph	-- enableAnnotationInfo: true
    2022-07-08T16:48:47.014+0300	ClassGraph	-- enableStaticFinalFieldConstantInitializerValues: true
    2022-07-08T16:48:47.014+0300	ClassGraph	-- enableInterClassDependencies: false
    2022-07-08T16:48:47.014+0300	ClassGraph	-- enableExternalClasses: false
    2022-07-08T16:48:47.014+0300	ClassGraph	-- enableSystemJarsAndModules: false
    2022-07-08T16:48:47.014+0300	ClassGraph	-- ignoreClassVisibility: true
    2022-07-08T16:48:47.014+0300	ClassGraph	-- ignoreFieldVisibility: true
    2022-07-08T16:48:47.015+0300	ClassGraph	-- ignoreMethodVisibility: true
    2022-07-08T16:48:47.015+0300	ClassGraph	-- disableRuntimeInvisibleAnnotations: false
    2022-07-08T16:48:47.015+0300	ClassGraph	-- extendScanningUpwardsToExternalClasses: true
    2022-07-08T16:48:47.015+0300	ClassGraph	-- allowedURLSchemes: null
    2022-07-08T16:48:47.015+0300	ClassGraph	-- addedClassLoaders: null
    2022-07-08T16:48:47.015+0300	ClassGraph	-- overrideClassLoaders: null
    2022-07-08T16:48:47.016+0300	ClassGraph	-- addedModuleLayers: null
    2022-07-08T16:48:47.016+0300	ClassGraph	-- overrideModuleLayers: null
    2022-07-08T16:48:47.016+0300	ClassGraph	-- overrideClasspath: [<...>\brokenanno\target\classes]
    2022-07-08T16:48:47.016+0300	ClassGraph	-- classpathElementFilters: null
    2022-07-08T16:48:47.016+0300	ClassGraph	-- initializeLoadedClasses: false
    2022-07-08T16:48:47.016+0300	ClassGraph	-- removeTemporaryFilesAfterScan: false
    2022-07-08T16:48:47.016+0300	ClassGraph	-- ignoreParentClassLoaders: false
    2022-07-08T16:48:47.017+0300	ClassGraph	-- ignoreParentModuleLayers: false
    2022-07-08T16:48:47.017+0300	ClassGraph	-- modulePathInfo:
    2022-07-08T16:48:47.017+0300	ClassGraph	-- maxBufferedJarRAMSize: 67108864
    2022-07-08T16:48:47.017+0300	ClassGraph	-- enableMemoryMapping: false
    2022-07-08T16:48:47.018+0300	ClassGraph	Number of worker threads: 8
    2022-07-08T16:48:47.027+0300	ClassGraph	Finding classpath
    2022-07-08T16:48:47.029+0300	ClassGraph	-- Finding classpath and modules
    2022-07-08T16:48:47.057+0300	ClassGraph	---- Overriding classpath with: [<...>\brokenanno\target\classes]
    2022-07-08T16:48:47.059+0300	ClassGraph	------ Found classpath element: <...>/brokenanno/target/classes
    2022-07-08T16:48:47.060+0300	ClassGraph	------ WARNING: when the classpath is overridden, there is no guarantee that the classes found by classpath scanning will be the same as the classes loaded by the context classloader
    2022-07-08T16:48:47.066+0300	ClassGraph	Opening classpath elements (took 0,028377 sec)
    2022-07-08T16:48:47.090+0300	ClassGraph	-- Opening classpath element file:///<...>/brokenanno/target/classes/
    2022-07-08T16:48:47.096+0300	ClassGraph	Finding nested classpath elements
    2022-07-08T16:48:47.097+0300	ClassGraph	Final classpath element order:
    2022-07-08T16:48:47.098+0300	ClassGraph	-- file:///<...>/brokenanno/target/classes/
    2022-07-08T16:48:47.098+0300	ClassGraph	Scanning classpath elements (took 0,018478 sec)
    2022-07-08T16:48:47.099+0300	ClassGraph	-- Scanning Path classpath element file:///<...>/brokenanno/target/classes/ (took 0,016358 sec)
    2022-07-08T16:48:47.101+0300	ClassGraph	---- Scanning Path: <...>/brokenanno/target/classes (took 0,013924 sec)
    2022-07-08T16:48:47.104+0300	ClassGraph	------ Scanning Path: <...>/brokenanno/target/classes/io (took 0,011224 sec)
    2022-07-08T16:48:47.105+0300	ClassGraph	-------- Scanning Path: <...>/brokenanno/target/classes/io/github (took 0,009690 sec)
    2022-07-08T16:48:47.107+0300	ClassGraph	---------- Scanning Path: <...>/brokenanno/target/classes/io/github/brokenanno (took 0,008200 sec)
    2022-07-08T16:48:47.110+0300	ClassGraph	------------ Found classfile within subpackage of accepted package: io/github/brokenanno/BrokenAnnotation$Bar.class
    2022-07-08T16:48:47.121+0300	ClassGraph	-------------- Parsing classfile (took 0,036136 sec)
    2022-07-08T16:48:47.151+0300	ClassGraph	---------------- Found annotation class io.github.brokenanno.BrokenAnnotation$Bar
    2022-07-08T16:48:47.152+0300	ClassGraph	------------------ Superclass: java.lang.Object
    2022-07-08T16:48:47.152+0300	ClassGraph	------------------ Interfaces: java.lang.annotation.Annotation
    2022-07-08T16:48:47.153+0300	ClassGraph	------------------ Class annotations: @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME), @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE_USE})
    2022-07-08T16:48:47.154+0300	ClassGraph	------------------ External interface java.lang.annotation.Annotation was not found in non-rejected packages -- cannot extend scanning to this class
    2022-07-08T16:48:47.155+0300	ClassGraph	------------------ External class annotation java.lang.annotation.Retention was not found in non-rejected packages -- cannot extend scanning to this class
    2022-07-08T16:48:47.155+0300	ClassGraph	------------------ External enum class java.lang.annotation.RetentionPolicy was not found in non-rejected packages -- cannot extend scanning to this class
    2022-07-08T16:48:47.157+0300	ClassGraph	------------------ External enum class java.lang.annotation.ElementType was not found in non-rejected packages -- cannot extend scanning to this class
    2022-07-08T16:48:47.113+0300	ClassGraph	------------ Found classfile within subpackage of accepted package: io/github/brokenanno/BrokenAnnotation$Dynamic.class
    2022-07-08T16:48:47.121+0300	ClassGraph	-------------- Parsing classfile (took 0,036768 sec)
    2022-07-08T16:48:47.154+0300	ClassGraph	---------------- Found class io.github.brokenanno.BrokenAnnotation$Dynamic
    2022-07-08T16:48:47.154+0300	ClassGraph	------------------ Superclass: java.lang.Object
    2022-07-08T16:48:47.157+0300	ClassGraph	------------------ Field: final synthetic this$0
    2022-07-08T16:48:47.157+0300	ClassGraph	------------------ Method: <init>
    2022-07-08T16:48:47.114+0300	ClassGraph	------------ Found classfile within subpackage of accepted package: io/github/brokenanno/BrokenAnnotation$Foo.class
    2022-07-08T16:48:47.121+0300	ClassGraph	-------------- Parsing classfile (took 0,036093 sec)
    2022-07-08T16:48:47.153+0300	ClassGraph	---------------- Found annotation class io.github.brokenanno.BrokenAnnotation$Foo
    2022-07-08T16:48:47.153+0300	ClassGraph	------------------ Superclass: java.lang.Object
    2022-07-08T16:48:47.153+0300	ClassGraph	------------------ Interfaces: java.lang.annotation.Annotation
    2022-07-08T16:48:47.155+0300	ClassGraph	------------------ Class annotations: @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME), @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE_USE})
    2022-07-08T16:48:47.156+0300	ClassGraph	------------------ External class annotation java.lang.annotation.Target was not found in non-rejected packages -- cannot extend scanning to this class
    2022-07-08T16:48:47.115+0300	ClassGraph	------------ Found classfile within subpackage of accepted package: io/github/brokenanno/BrokenAnnotation.class
    2022-07-08T16:48:47.121+0300	ClassGraph	-------------- Parsing classfile (took 0,034929 sec)
    2022-07-08T16:48:47.151+0300	ClassGraph	---------------- Found class io.github.brokenanno.BrokenAnnotation
    2022-07-08T16:48:47.151+0300	ClassGraph	------------------ Superclass: java.lang.Object
    2022-07-08T16:48:47.156+0300	ClassGraph	------------------ Method: public <init>
    2022-07-08T16:48:47.116+0300	ClassGraph	Masking classfiles (took 0,000581 sec)
    2022-07-08T16:48:47.120+0300	ClassGraph	Scanning classfiles (took 0,037636 sec)
    2022-07-08T16:48:47.158+0300	ClassGraph	Linking related classfiles (took 0,009834 sec)
    2022-07-08T16:48:47.174+0300	ClassGraph	Total time: 0,105 sec
    
    opened by Lodin 1
Releases(classgraph-4.8.154)
  • classgraph-4.8.154(Jan 2, 2023)

    • Add getTypeAnnotationInfo() to all type signature classes (#741, thanks to @platosha for the suggestion).
    • Fix "Wildcarded classpath entries not working any more" (#739, thanks to @vashaefer for the report).
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.153(Dec 21, 2022)

    • Added ClassInfo#getSourceFile() (thanks to @freya022 for pull request #740 with the complete implementation).
    • Added getTypeAnnotationInfo() to TypeParameter and TypeArgument (#741, thanks to @platosha for pull request #742 with the complete implementation).
    • Fixed a ClassCastException introduced in the previous release (#705, thanks to @devlauer for reporting this).
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.152(Dec 10, 2022)

  • classgraph-4.8.151(Nov 17, 2022)

  • classgraph-4.8.150(Nov 15, 2022)

    • Fix "TypeVariableSignature.resolve() throws "Class name is not set" for generic superclass signature arguments" (#706, thanks to @platosha for the bug report).
    • Add ClassInfo#isPackageVisible() (#702, thanks to @sebthom for doing the work and submitting a pull request)
    • Fix Windows UNC path scanning (#705, thanks to @jdeppe-pivotal for the bug report).
    • Fix an error whereby hierarchical scanning of directories would stop when the first unreadable file/directory was reached.
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.149(Jul 6, 2022)

    Extract line number ranges for methods (#695, thanks to @freya022 for suggesting).

    See MethodInfo#getMinLineNum() and MethodInfo#getMaxLineNum(), which return the line number of the first and last non-blank line in a method body, if available, otherwise zero.

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.148(Jul 4, 2022)

    Fixes a bug where MethodInfo#loadClassAndGetMethod would not work if the method type signature contained a type variable for a parameter type (#694, thanks to @freya022 for the report).

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.147(May 24, 2022)

  • classgraph-4.8.146(Apr 15, 2022)

  • classgraph-4.8.145(Apr 15, 2022)

    Fixed an issue that could cause some classpath elements to be skipped if Class-Path: was used in the manifest files of multiple jars on the classpath to include other jars that were also explicitly included on the classpath. The issue was classpath-order-dependent. Thanks to @steveniemitz and @sherter (https://github.com/classgraph/classgraph/issues/614) and also @jdeppe-pivotal (https://github.com/classgraph/classgraph/issues/673) for finding and reporting this bug.

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.144(Apr 15, 2022)

  • classgraph-4.8.143(Mar 26, 2022)

    Fix exception typeSignatureParamTypes.size() > typeDescriptorParamTypes.size() when dealing with broken compiler output (where the type descriptor of a method has a different number of entries in it than the type signature for the same method) (#660, thanks to @colin-young for reporting).

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.142(Mar 26, 2022)

    Bugs fixed:

    • Added method ClassInfo#getTypeSignatureOrTypeDescriptor() so that type annotations can be read for non-generic class definitions (#662, thanks to @raner for the request).
    • Fixed Illegal reflective access warning on some obsolete and buggy JVM versions (#663, thanks to @MR6996 for the report).

    Two behavioral changes, which may result in breakage for some users:

    • The list of interfaces implemented by a class, as returned by ClassInfo#getInterfaces(), is no longer sorted by name, but is returned in the order in which the interfaces were specified in the class definition (this order is significant, so the old behavior of sorting by name was incorrect).
    • The result of toString() for several of the TypeSignature subclasses has changed to use $ as a separator of inner classes, rather than ., to bring the toString() behavior closer to the result of Class#getName().
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.141(Feb 26, 2022)

    • Fixed handling of URLs like jar:file:jarname.jar!/ (these were being skipped -- #625, thanks to @edeso for reporting this.)
    • Improved logging of FileNotFoundException for missing jars.
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.140(Feb 24, 2022)

  • classgraph-4.8.139(Feb 13, 2022)

    Bugfixes:

    • Fix to work with newer Quarkus classloader (#641, thanks to @michael-simons for the fix in #642!).
    • If an override classloader is an AppClassLoader, also scan the traditional classpath (#639, thanks to @limbic-derek for the report).
    • Fix for parsing error if Kotlin function names contain parentheses (#645). Also fixes a potential stack overflow in this case.

    New feature:

    • Added support for getting the exceptions thrown by a method (#633, thank you to @jkschneider for submitting the complete implementation of this feature, in #637!)
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.138(Dec 12, 2021)

    • Added two methods (thanks to @FranGomezVenegas for requesting these, #608):

      • FieldInfoList ClassInfo#getEnumConstants(): returns all the enum constants of an enum class as FieldInfo objects (without loading the enum class).
      • List<Object> ClassInfo#getEnumConstantObjects(): returns all the enum constants of an enum class as objects of the same type as the enum (after loading the enum class and initializing enum constants).
    • Mitigate log4j2 vulnerability CVE-2021-44228: ClassGraph does not use log4j2, but does use the built-in Java logging framework, which may be redirected to the log4j2 framework by the calling environment. To be safe, ClassGraph now builds in a protection against this critical vulnerability.

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.137(Nov 26, 2021)

  • classgraph-4.8.136(Nov 26, 2021)

    Contribution by @tkrautinger (#604):

    • ClassInfo: Added isPrivate(), isProtected()
    • MethodInfo: Added isPrivate(), isProtected(), isAbstract(), isStrict()
    • FieldInfo: Added isPrivate(), isProtected(), isSynthetic(), isEnum()
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.135(Nov 22, 2021)

    • Fixed issue with resources remaining marked as open after close() was called on an InputStream opened on a module resource (#600 and #602, thanks to @chrisr3)
    • Added Resource#readCloseable() that returns a CloseableByteBuffer that calls Resource#close() when CloseableByteBuffer#close() is called. (#600)
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.134(Nov 20, 2021)

    Fixes a resource leak (ClassfileReader#close() wasn't closing the underlying resource). Thanks to @chrisr3 for isolating the problem, and for providing a pull request complete with unit test! (#600)

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.133(Nov 16, 2021)

    Fix a regression for in the OSGi manifest entries introduced in the previous version, 4.8.132 (#598, thanks to @Roman-Skripka for the pull request).

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.132(Nov 12, 2021)

  • classgraph-4.8.131(Nov 9, 2021)

    Catch unchecked exceptions and errors SecurityException, IllegalArgumentException and IOError in more places when dealing with Path and URI objects, to prevent issues when running with a security manager. Thanks to @elkman for the pull request. (#594).

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.130(Nov 8, 2021)

    Allow enableSystemJarsAndModules() to be used in conjunction with overrideClasspath() or overrideClassLoaders() (#592, thanks to @roxspring for this contribution!).

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.129(Oct 28, 2021)

    Add the ability to find resources by path glob by calling ScanResult#getResourcesMatchingWildcard(String wildcardString) (#588, thanks to @jjlin for the request):

    • ** matches zero or more characters
    • * matches zero or more characters other than /
    • ? matches any one character
    • Any other valid Java regexp syntax is supported, such as character ranges in square brackets ([a-c]), with the exception of ., which is interpreted as a literal dot character (the single-character wildcard syntax is replaced with ?, as shown above).
    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.128(Oct 14, 2021)

  • classgraph-4.8.127(Oct 14, 2021)

  • classgraph-4.8.126(Oct 11, 2021)

    Remove -parameters flag from javac parameters of non-test build, introduced in 4.8.121, because it introduced issues with -Xlint:classfile or -Xlint:all combined with -Werror (#577, thanks to @Stephan202 for reporting)

    Source code(tar.gz)
    Source code(zip)
  • classgraph-4.8.125(Oct 7, 2021)

Owner
classgraph
The ClassGraph classpath and module path scanner
classgraph
High performance Java reflection

Please use the ReflectASM discussion group for support. Overview ReflectASM is a very small Java library that provides high performance reflection by

Esoteric Software 1.4k Dec 31, 2022
Java runtime metadata analysis

Released org.reflections:reflections:0.9.12 - with support for Java 8 Reflections library has over 2.5 million downloads per month from Maven Central,

null 4.4k Dec 29, 2022
Netflix, Inc. 809 Dec 28, 2022
[WIP] Springram is uber library for working with Telegram using Spring Framework and Spring Boot.

Springram Springram is a library for working with telegram using the spring framework and spring boot. This library gives you the ability to use contr

Max 6 Nov 1, 2022
Uber-project for (some) standard Jackson textual format backends: csv, properties, yaml (xml to be added in future)

Overview This is a multi-module umbrella project for Jackson standard text-format dataformat backends. Dataformat backends are used to support format

FasterXML, LLC 351 Dec 22, 2022
MVP de Sistema de delivery de comida (como Uber eats ou Ifood)

Repositório para acompanhar a minha evolução no curso Especialista Spring REST da Algaworks ??️ Sobre o Projeto: MVP de Sistema de delivery de comida

Rayane Maciel 18 Dec 29, 2022
The fast scanner generator for Java™ with full Unicode support

JFlex JFlex is a lexical analyzer generator (also known as scanner generator) for Java. JFlex takes as input a specification with a set of regular exp

JFlex 500 Dec 18, 2022
Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper

Simple Flat Mapper Release Notes Getting Started Docs Building it The build is using Maven. git clone https://github.com/arnaudroger/SimpleFlatMapper.

Arnaud Roger 418 Dec 17, 2022
React 0.68+ Turbo Module starter using codegen with typescript for Objective-C and Java/Kotlin with C++ shared library. 🚀🚀🚀

React 0.68+ Turbo Module starter using codegen with typescript for Objective-C and Java/Kotlin with C++ shared library. ?? ?? ?? Features React Native

Nagish Inc. 358 Jan 3, 2023
Word wrapping program created using Java and Scanner imports.

WordWrap Word wrapping program created using Java and Scanner imports. The program begins by asking the user to input a number for line width. This re

Nikhil Khanna 1 Jan 31, 2022
This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practical coding example and required JAR dependencies

SpringMVC-Database-Integration This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practic

GowthamRaj K 3 Nov 2, 2021
Nginx module for embedding Clojure or Java or Groovy programs, typically those Ring based handlers.

Nginx-Clojure Nginx-Clojure is a Nginx module for embedding Clojure or Java or Groovy programs, typically those Ring based handlers. Core Features The

nginx-clojure 1k Dec 22, 2022
Pw0 Framewrok - magical android pentest app 🔮! Pixie Dust, Handshakes, Deauth, Nmap, Port scanner and more!

Pw0 Framework Pw0 Framewrok - magical android pentest app ?? ! Features: Pixie Dust Handshakes Deauth Nmap Port scanner and more! Version: 0.2 Beta Au

Huntmix 17 Sep 27, 2021
Document scanner with border detection, perspective correction and custom crop/resize

react-native-document-scanner Preview iOS Android Both Platform Use version >=1.4.1 if you are using react-native 0.48+ $ yarn add https://github.com/

Augusto Pinheiro 53 Nov 10, 2022
Extension module to properly support datatypes of javax.money

Jackson Datatype Money Jackson Datatype Money is a Jackson module to support JSON serialization and deserialization of JavaMoney data types. It fills

Zalando SE 217 Jan 2, 2023
Spring Boot starter module for gRPC framework.

Spring Boot starter module for gRPC framework.

Michael Zhang 2.8k Jan 4, 2023
Spring Boot starter module for gRPC framework.

Spring Boot starter module for gRPC framework.

Michael Zhang 1.8k Mar 17, 2021