ReflectionUtils use Class.forName in order to properly discover classes in Functions Runtime while using DefaultImplementation
Using Class.forName allows Java classes loaded in the Functions Runtime to fully use the Implementation classes loaded from the Pulsar API
using DefaultImplementation
@@ -51,12 +51,12 @@ class ReflectionUtils {
try {
try {
// when the API is loaded in the same classloader as the impl
- return (Class<T>) DefaultImplementation.class.getClassLoader().loadClass(className);
+ return (Class<T>) Class.forName(className, true, DefaultImplementation.class.getClassLoader());
} catch (Exception e) {
// when the API is loaded in a separate classloader as the impl
// the classloader that loaded the impl needs to be a child classloader of the classloader
// that loaded the API
- return (Class<T>) Thread.currentThread().getContextClassLoader().loadClass(className);
+ return (Class<T>) Class.forName(className, true, Thread.currentThread().getContextClassLoader());
}
} catch (ClassNotFoundException | NoClassDefFoundError e) {
throw new RuntimeException(e);
