I'm attempting to create a custom implementation of
Код: Выделить всё
java.nio.FileSystemThe implementation itself seems to work correctly within its context.
However, the parent Application doesn't load my implementation via regular ClassPath but via an additional URLClassLoader.
Therefore, the implementation is currently only availabel via
Код: Выделить всё
ServiceLoader.load(FileSystemProvider.class, specificClassLoaderOfMyCode)Код: Выделить всё
java.nio.FilesI can modify the parent application but cannot remove the intermediate ClassLoader.
I do have access to the parent ServiceLoader and the child's ServiceLoader.
My goal is to get all implementations from the child and put them into the parent's ServiceLoader.
The Application itself is written in Spring, and the parent's ClassLoader is, therefore, the default Spring ClassLoader.
The only way I can see is to use reflection in order to modify the internal cache and force the implementation into it, but
Код: Выделить всё
java.baseTherefore, I'm not allowed to access the private fields of ServiceLoader.
I could add the relevant flags, but I'd like to avoid this approach.
Is there any alternative to dynamically add an implementation to a ServiceLoader, that is not known to the ClassLoader (not present in
Код: Выделить всё
META-INF/servicesИсточник: https://stackoverflow.com/questions/732 ... at-runtime
Мобильная версия