Good day,
I have the following setup:
- a maven dependency
dep1, it contains an abstract classA - another maven dependency
dep2, which usesdep1as dependency, and has a classDep2Classwith constructorDep2Class(A a) - maven plugin
mvn-pluginthat usesdep2as dependency - project
projthat hasdep1as dependency, usesmvn-pluginas plugin and defines a classB extends A
My objective at this point is that mvn-plugin loads class B from proj and feeds it to Dep2Class.
As you might already expect I am getting ClassCastException because proj is loaded with a different class loader than mvn-plugin. I have tried with URIClassLoader and Guava and got the same issue. Reflections appear to be working but the code becomes a mess because I have several Methods from A to call in mvn-plugin. I wanted to try ClassGraph but as far as I understood it does not work easily with GraalVM and I need to use GraalVM.
It sounds strange to me that few people encountered this issue, so I wanted to ask whether anyone has some explanations they can provide. Is there any change I should do in the design? or is there any way to solve the class loader problem?
Thanks a lot, cheers.