On 26/04/2017 15:04, Matej Novotny wrote:

You can spin one module per package, by creating one ModuleLayer per package,
not unlike j.l.r.Proxy does.
Don't know a bit about it, but it sounds like a way worth exploring.
Would you have a pointer towards some code showing how to deal with 
ModuleLayers?
There are advanced examples in the Nashorn code where it is generating code but it might be better to start with something more basic. One example that could be useful to you is the translet code in the java.xml module:

http://hg.openjdk.java.net/jdk9/jdk9/jaxp/file/tip/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java

It creates a ClassLoader to load the generated code (it extends ClassLoader and so gets to call its defineClass method). The code is also in a module that it generates at run-time before the classes are loaded.


Also checking on j.l.r.Proxy, it uses the "good old" Unsafe.defineClass.
Can't really see any module-related magic there.

I'm sure that Proxy and LambdaMetafactory will eventually move to using new forms of Lookup.defineClass.

-Alan

Reply via email to