Already got a fix, just making this issue to have an issue number:
@Test
void test() {
MethodInfoList constructors = new ClassGraph()
.enableAnnotationInfo()
.enableSystemJarsAndModules()
.enableClassInfo()
.enableMethodInfo()
.scan()
.getClassInfo("java.io.ObjectOutputStream")
.getConstructorInfo();
for (MethodInfo constructor : constructors) {
if (constructor.getParameterInfo().length == 0) {
// The no args constructor of ObjectOutputStream is protected
assertEquals(Modifier.PROTECTED, constructor.getModifiers(), "The no-args constructor of ObjectOutputStream should read as `protected`");
}
}
}
Basically, the constructor info returned is for the superclass constructor, but given constructors aren't inherited this seems more misleading than useful.
Also worth noting that the javadoc for getMethodInfo(final String methodName) says:
Returns information on the method(s) or constructor(s) of the given name declared by this class, but not by its interfaces or superclasses.
but currently it will in fact return a public superclass constructor if the subclass one is lower visibility and .ignoreMethodVisibility() isn't set.