On 8/21/20 4:42 AM, Florian Weimer wrote:
I see there's a new GetModule entry point, but I can't find anything that interacts directly with it. The challenge I see is that FindClass often cannot find application classes once modules are involved. Technically, I guess that's not a new phenomenon and could have happened before once multiple class loaders are involved. However, modules seem to encourage such setups and expose this functionality to more developers, I suppose. Is the recommended way to use the jclass parameter of native methods with GetModule to obtain the application module, and call getClassLoader() and its loadClass(String) methods to get this to work? Isn't this a tad bit involved? There's also an asymmetry due to the use of source class names, unlike FindClass.
JNI FindClass is equivalent to calling 3-arg Class::forName using the loader of the caller class that invokes FindClass. It can find the classes that are visible to the loader. It will find classes in another module as long as it's exported to the caller's module.
Can you say more about the scenarios what you refer to "FindClass often cannot find application classes once modules are involved"?
Mandy