I have a project that uses
Java 9 and generates some code during runtime based on data that is supplied to it for event handling. I would like to be able to put this generated code in it's own module that requires what it needs and only exports to what is allowed to call into it. I have been digging around in the sources with my
IDE but I can not seem to find a way to create a module that is not blocked by some sort of non-public or non-exported method or class. For example, this could be the class that is generated:
With this being loaded by a ClassLoader that goes something like this:
How would I modify the class loading to load it into a module called "testmodule" that requires "java.base"(even though it is assumed, example) and exports to "moduleloader"?
I am well aware that hard coding the bytecode into the class like that is not a good idea, I will be using ASM for the actual project of mine.
(Sorry if the Java is not perfect, made it up for this post)