Skip to content

How to resolve the class object of method parameters and return type? #845

Answered by lukehutch
helpermethod asked this question in Q&A
Discussion options

You must be logged in to vote

You can resolve the class names using ClassGraph, but it intentionally does not load the classes unless you ask it to by calling ClassInfo.loadClass. (That's the whole point of ClassGraph existing. Classloading is time consuming, and can have side effects, when classes are initialized.)

It is impossible to have a class reference without first loading the class. If your API requires class references, then you have to load the class.

ClassGraph does at least disable class initialization when it loads classes, if I remember right. Then classes are only initialized the first time a method is called or a field is accessed within the class.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by helpermethod
Comment options

You must be logged in to vote
1 reply
@lukehutch
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants