Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassGraph does not scan java.lang.Object #703

Open
sebthom opened this issue Aug 22, 2022 · 1 comment
Open

ClassGraph does not scan java.lang.Object #703

sebthom opened this issue Aug 22, 2022 · 1 comment

Comments

@sebthom
Copy link
Contributor

sebthom commented Aug 22, 2022

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.

@lukehutch
Copy link
Member

@sebthom Thanks for the report -- sorry for the delay.

This is actually intentional, since it was kind of a pain seeing java.lang.Object as the superclass of every toplevel class. I made this (rather arbitrary) decision to suppress Object early on in ClassGraph's history, and I'm a bit worried that if I put it back into the return values of all methods that filter it out, it would break some people's code. Maybe though at least if you specifically enable system jars and modules, this class should be scanned.

This is probably a good candidate for the next major version of ClassGraph (5.0), since that will have breaking changes, but I don't have a timeline for when that will be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants