On Tue, 28 Aug 2018 at 20:43, Peter Levart <peter.lev...@gmail.com> wrote: > Do you think this functionality is really needed in programs? It seems useful > just for testing.
Why do people add classes at runtime? Might they not reasonably want to also add resources for those classes? The key point here is that this all worked before Java 9 modules. But since resources are now encapsulated, adding a new ClassLoader is no longer sufficient to inject a resource, as it doesn't get the right module encapsulation that way. My experience more generally has been that encapsulating resources in Java 9 modules has broken key assumptions in almost every library I maintain. Remember that library maintainers now have to to develop and test code like this for three different environments, Java 8, Java 9 classpath and Java 9 modulepath - its very painful. > So is there a way to achieve what you want for your test with existing API? Probably. I could have a separate maven module creating a separate modular jar file with the testing resource in it, and run the test using both the classpath mode and modulepath. I'm not going to be doing that as the benefits are too low compared to the cost. Stephen