I have a veeeery strange NPE in my project related to ClassGraph. The issue is that I receive an NPE from the MethodInfo class right after constructing the new object MethodParameterInfo object.
The environment is JDK 22 (temurin) build on linux, but I had similar issues with the Oracle JDK 22 and also with JDK versions 19 and 21 in the past. I have tested with version 4.8.175 of ClassGraph, as that seems to be the latest available version now.
The relevant part of the stack trace is:
Caused by: java.lang.NullPointerException: Cannot invoke "io.github.classgraph.MethodParameterInfo.setScanResult(io.github.classgra
ph.ScanResult)" because "this.parameterInfo[i]" is null
at io.github.classgraph.MethodInfo.getParameterInfo(MethodInfo.java:579)
at io.github.classgraph.MethodInfo.loadParameterClasses(MethodInfo.java:623)
at io.github.classgraph.MethodInfo.loadClassAndGetMethod(MethodInfo.java:672)
at com.dawnspill.data.helper.Reflections.lambda$getMethodsAnnotatedWith$3(Reflections.java:117)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
What I do is (in various parts of my code, but in this order):
final var scan = new ClassGraph()
//.verbose()
.enableAllInfo()
.ignoreClassVisibility()
.ignoreFieldVisibility()
.ignoreMethodVisibility()
.scan();
[...]
final var classname = annotationClass.getName();
final var classList = scan.getClassesWithMethodAnnotation( classname );
if ( classList.isEmpty() )
{ return Collections.emptyList(); }
final List<Method> methods = new Vector<>();
for( final ClassInfo classInfo : classList ) {
classInfo.getMethodAndConstructorInfo()
.filter( mi -> mi.hasAnnotation( classname ) )
.forEach( mi -> { methods.add( mi.loadClassAndGetMethod() ); } );
}
return methods;
I have checked the ClassGraph source code at MethodInfo.java:579 and right before this method call, the instance is just assigned a newly constructed MethodParameterInfo object.
How can that be possible???
:(
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