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.

Scan not performed on saved ClassGraph object

See original GitHub issue

Hi. I don’t understand why the scanning is not performed if I store the ClassGraph instance in a variable before calling the scan() method.

For example:

class MyMavenRunner{
    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            val parsedArgs = parseCommandArgs(args)
            val classGraph =
                    ClassGraph()
                            .verbose()
                            .enableClassInfo()
                            .enableMethodInfo()
                            .disableJarScanning()
                            .disableNestedJarScanning()
                            .whitelistPackages(BASE_PACKAGE)
                            .overrideClasspath(parsedArgs.projectBuildPath.toString())

            val data= generateData(classGraph)
            print(data)
        }
    }
}

(where generateData(ClassGraph), declared in another class as static, calls inside classGraph.scan().use {...}) doesn’t work (I get 2020-02-04T11:35:35.667+0100 ClassGraph Only returning classpath elements (not performing a scan) from the verbose(), which causes then an NPE when I call getClassesImplementing(MyClass.class.canonicalName)), but if I do

ClassGraph()
                            .verbose()
                            .enableClassInfo()
                            .enableMethodInfo()
                            .disableJarScanning()
                            .disableNestedJarScanning()
                            .whitelistPackages(BASE_PACKAGE)
                            .overrideClasspath(parsedArgs.projectBuildPath.toString())
                            .scan()
                            .use { scanResult -> ... }

inside the generateData directly it works fine.

The main(args) is called from the Maven Exec Plugin.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cdpretecommented, Feb 5, 2020

but please open a new bug for the other issue you alluded to, if it’s still present.

It’s this one: https://github.com/classgraph/classgraph/issues/399

0reactions
lukehutchcommented, Feb 5, 2020

Makes sense, I thought you were using it with it in use { ... }.

Please let me know if the fix worked for you (it should do).

Read more comments on GitHub >

github_iconTop Results From Across the Web

ClassGraph (ClassGraph 4.6.2 API) - javadoc.io
Enables the saving of method info during the scan. This information can be obtained using ClassInfo.getMethodInfo() etc. By default, method info is not...
Read more >
io.github.classgraph.ClassGraph.enableClassInfo java code ...
Enables the saving of field info during the scan. This information can be obtained using * {@link ClassInfo#getFieldInfo()}. By default, field info is...
Read more >
Scanning Java annotations at runtime - Stack Overflow
I mean that the BeanDefinition object does not provide a way to get the class directly. The closest thing seems to be getBeanClassName...
Read more >
ModelSim User's Manual - Microsemi
Menu Item. Description. Breakpoints. Manage breakpoints. Trace. Perform signal trace actions. Dataset Snapshot. Enable periodic saving of simulation data to ...
Read more >
io.github.classgraph.ClassGraph Maven / Gradle / Ivy
By default, method info is not scanned. (Automatically calls * {@link #enableClassInfo()}.) * * @return this (for method chaining). */ public ClassGraph ......
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