Skip to content

NPE thrown during scanning  #758

@ronshemerws

Description

@ronshemerws

Scanning artifact org.plumelib:plume-util:1.6.5 with latest classgraph release (4.8.156) throws an NPE. This is happening with both java 11 & 17.
It looks like it is happening when processing the method

public @org.checkerframework.checker.formatter.qual.UnknownFormat boolean removeAll(java.util.Collection<?>)

which is defined in org.plumelib.util.IdentityArraySet
Unfortunately, I could not come up with a solution yet.

This is a short program that reproduces the issue, assuming the plume-util jar file is placed in the resources folder:

package org.example;

import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;

import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Set<String> classpath = new HashSet<>();
        classpath.add(Main.class.getClassLoader().getResource("plume-util-1.6.5.jar").getPath());
        try (ScanResult scanResult =
                     new ClassGraph()
                             .verbose()
                             .enableInterClassDependencies()
                             .overrideClasspath(classpath)
                             .scan()) {
            System.out.println("success");
        }
    }
}

This is the output of this program:

Exception in thread "main" io.github.classgraph.ClassGraphException: Uncaught exception during scan
	at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1610)
	at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1627)
	at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1640)
	at org.example.Main.main(Main.java:18)
Caused by: java.lang.NullPointerException: Cannot invoke "io.github.classgraph.ReferenceTypeSignature.addTypeAnnotation(java.util.List, io.github.classgraph.AnnotationInfo)" because "this.typeSignature" is null
	at io.github.classgraph.TypeArgument.addTypeAnnotation(TypeArgument.java:107)
	at io.github.classgraph.ClassRefTypeSignature.addTypeAnnotation(ClassRefTypeSignature.java:234)
	at io.github.classgraph.Classfile$2.decorate(Classfile.java:1649)
	at io.github.classgraph.MethodInfo.getTypeSignature(MethodInfo.java:259)
	at io.github.classgraph.MethodInfo.findReferencedClassInfo(MethodInfo.java:799)
	at io.github.classgraph.MethodInfoList.findReferencedClassInfo(MethodInfoList.java:99)
	at io.github.classgraph.ClassInfo.findReferencedClassInfo(ClassInfo.java:3224)
	at io.github.classgraph.ScanResultObject.findReferencedClassInfo(ScanResultObject.java:72)
	at io.github.classgraph.ScanResult.indexResourcesAndClassInfo(ScanResult.java:327)
	at io.github.classgraph.ScanResult.<init>(ScanResult.java:269)
	at io.github.classgraph.Scanner.performScan(Scanner.java:1012)
	at io.github.classgraph.Scanner.openClasspathElementsThenScan(Scanner.java:1114)
	at io.github.classgraph.Scanner.call(Scanner.java:1148)
	at io.github.classgraph.Scanner.call(Scanner.java:82)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Adding also the full project:
plume-util-scanner.zip
Once extracted, running the following should reproduce the issue:
mvn package
java -jar target/bug_report-1.0-SNAPSHOT-shaded.jar

And here is the full verbose log:
verbose_log.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions