Call from native thread is not handled by context class loader
posted 6 years ago
Hello. I have scenario like this:
Call from JAVA->c++ >JAVA
When I call JAVA defined oeprations (kind of call back) from C++ app(called by java) immediately after receiving the call from JAVA, it works fine.
C++ call from JAVA initiates a chain/ stack of subsequent calls (which may spawn a new process/ thread), and finally a call is again made from last spwned process/ thread to JAVA. When we call findClass on env. after attaching current thread to JVM, env is not able to find the class.
As per my understanding this is probably because when we call from native thread to JAVA, it is using system class loader to load the class. And system is not able to find that class, as it is not in classpath probably. This is fine.
In my JAVA application I have used custom class loader to load all my appliction classes. And this is capable of loading class which is actually required when findClass is called.
How to instruct the env/ jvm to find class using my custom class loader, instead of system class loader.