According to the ClassInfo wiki, ClassGraph is capable of inspecting the method implementation to find dependencies.
ClassInfo#getClassDependencies() returns a ClassInfoList for all the classes a given class depends upon, by looking for class references in superclasses, interfaces, methods, fields, annotations, local variables, intermediate values within a method's code, concrete type parameters, etc.
However, getClassDependencies doesn't do that.
I turned on verbose and noticed that temp.Source is recognized at one point.
2020-04-03T17:52:34.548-0500 ClassGraph ------------ Found class temp.RegressionTarget
2020-04-03T17:52:34.548-0500 ClassGraph -------------- Superclass: java.lang.Object
2020-04-03T17:52:34.548-0500 ClassGraph -------------- Method: ()
2020-04-03T17:52:34.549-0500 ClassGraph -------------- Method: public static void doSomething()
2020-04-03T17:52:34.549-0500 ClassGraph -------------- Referenced class names: java.lang.Object, temp.RegressionTarget, temp.Source
I further debugged and noticed that ClassInfo has 2 fields that are semantically tightly coupled but programmatically unrelated.
/**
* Names of classes referenced by this class in class refs and type signatures in the constant pool of the
* classfile.
*/
private Set<String> referencedClassNames;
/** A list of ClassInfo objects for classes referenced by this class. */
private ClassInfoList referencedClasses;
referencedClasses is generated from scratch even if referencedClassNames is already populated.
referencedClasses doesn't have temp.Source, but referencedClassNames does.
I think io.github.classgraph.ScanResult.indexResourcesAndClassInfo() should utilize referencedClassNames.
I attached a full log from verbose() and a failing JUnit 5 test case because of this bug.
log.txt
ReferencedClassTestCase.txt
According to the ClassInfo wiki, ClassGraph is capable of inspecting the method implementation to find dependencies.
However,
getClassDependenciesdoesn't do that.I turned on verbose and noticed that temp.Source is recognized at one point.
I further debugged and noticed that ClassInfo has 2 fields that are semantically tightly coupled but programmatically unrelated.
referencedClassesis generated from scratch even ifreferencedClassNamesis already populated.referencedClassesdoesn't havetemp.Source, butreferencedClassNamesdoes.I think
io.github.classgraph.ScanResult.indexResourcesAndClassInfo()should utilizereferencedClassNames.I attached a full log from
verbose()and a failing JUnit 5 test case because of this bug.log.txt
ReferencedClassTestCase.txt