Add reads to open module

Remi Forax forax at univ-mlv.fr
Mon May 17 16:10:01 UTC 2021


----- Mail original -----
> De: "Christian Beikov" <christian.beikov at gmail.com>
> À: "jigsaw-dev" <jigsaw-dev at openjdk.java.net>
> Envoyé: Lundi 17 Mai 2021 17:43:15
> Objet: Fwd: Add reads to open module

> Hi,
> 
> I have a use case where I generate some code and that code refers to
> classes of some module B.
> 
> When the module A (an open module), into which I define that class, has
> no read-edges to the module B, this fails saying that A does not read B.
> 
> That's fine and totally understandable, so I tried to add the following
> code:
> 
> moduleA.addReads("moduleB.pkg", moduleB)
> 
> but this is not allowed as `addReads` only works if `this == callerModule`.
> 
> My workaround is to define a class into module A that can then call this
> method.
> 
> Is there a reason to this limitation? I mean the module is open anyway,
> so anyone can just define a class into it, so why not also allow calling
> addReads?

It's basic security [1], you can not see something you do not ask for.
By example, if your module as a security issue, you don't want an attacker to be able to see all other open modules from your module.

> 
> 
> Regards,
> 
> Christian

regards,
Rémi

[1] https://en.wikipedia.org/wiki/Defense_in_depth_(computing)


More information about the jigsaw-dev mailing list