I am trying to load a resource into my runtime for a library. But in my current implementation only the very specific instance of the URLClassLoader can see it.
URLClassLoader classLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
classLoader.addFile(super.getResource(urlPath));
classLoader.classLoader.getResourceAsStream(path) //works
URLClassLoader secondClassLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
secondClassLoader.classLoader.getResourceAsStream(path) // doesn't work
Another problem is, that I don't know which ClassLoader the library actually uses as parent. The best solution would be one where every class loader can access the resource.
How to make sure that the dynamically loaded resource is accessible by all the classloaders?