question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scanning for locally compiled classes (exlude child classes)

See original GitHub issue

I am trying to figure out how to accomplish this, but so far from reading the documentation I have not been able to figure it out.

Basically, I want to scan for all classes that have been compiled locally by Maven or Gradle or something. I sort of figured out how to do it by doing this:

		List<String> classnames = new ClassGraph()
			.acceptPackages("")
			.disableJarScanning()
			.rejectClasses(Closure.class.getName())
			.scan()
			.getAllClasses()
			.getNames();

Since I’m doing this on Groovy classes, I am getting a ton of extra classes that represent the Groovy closures in many of the classes. For example (the highlighted classes in this list of variables in IntelliJ are closure classes):

image

What I want to do is exclude classes that have groovy.lang.Closure as their super class (or at any other arbitrary location below the class in the class hierarchy).

I tried using rejectClasses, but closures are compiled into anonymous classes that extend groovy.lang.Closure instead of being an instance of a Closure, and it seems that rejectClasses only works the provided class itself.

Is there a way to do this that I am overlooking?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lukehutchcommented, Dec 9, 2020

I just made another change that returns true from extendsSuperclass("java.lang.Object") only for standard classes, not for interfaces or annotations, since these do not extend Object. This will be in 4.8.95.

0reactions
lukehutchcommented, Dec 10, 2020

Just as a heads-up – Sonatype has issues with publishing artifacts right now, so I can’t push to Maven Central until that is resolved. Feel free to use a locally-built snapshot until that is fixed. Also since I couldn’t push 4.8.94, I’ll just combine that change from the previous comment and release the final version as 4.8.94 with all changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven Jacoco Configuration - Exclude classes/packages from ...
This will exclude every class in some.package , as well as any children. For example, some.package.child wouldn't be included in the reports either....
Read more >
How to scan Java precompiled classes - HCL support
In AppScan Source Edition, how do you configure a Java project to scan the precompiled class files instead of compiling and scanning the...
Read more >
DAST API - GitLab Docs
The API to be scanned should be excluded from changes for the duration of a DAST API scan. The only changes to the...
Read more >
Java - SonarQube Documentation
Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions ...
Read more >
Maven Surefire Plugin – surefire:test - Apache Maven
<dependenciesToScan>, String[], 2.15, List of dependencies to scan for test classes to include in the test run. The child elements of this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found