reasons to add readability edges when creating layer

Alan Bateman Alan.Bateman at oracle.com
Sun Dec 31 15:54:35 UTC 2017


On 31/12/2017 01:22, Michał Zegan wrote:
> Hi.
>
> Wondering about one thing: What is the example use for addReads method
> of ModuleLayer.Controller?
Code generation or new reflection (java.lang.invoke) would be reasons to 
use addReads.

> Reflection does not require adding readability edges manually.
> Also, if readability edge's target module would not be in a parent layer
> or the same layer, seems that the module class loader will not take into
> account readability edge changes. Not even sure if it would do this in
> case when target module would indeed be in the parent layer.
> So, is the only use case the one when I would have a custom class loader
> loading by different rules?
>
If the container is injecting code into a module m1 with references to 
m2, and if m1 and m2 are mapped to different loaders, then the container 
will need to augment the class loader delegation to support the new read 
edge. There isn't any API support for this so it would require the 
container to support the module layer with its own class loaders (which 
I think is what you are asking).

-Alan






More information about the jigsaw-dev mailing list