Patterns for libraries to access private state of user modules

Alan Bateman Alan.Bateman at oracle.com
Tue Nov 14 18:29:57 UTC 2017


On 14/11/2017 17:07, Gunnar Morling wrote:
>
>
> :
>
>     JAXB is one example doing this already and it would be good to
>     exercise it with other libraries to ensure that it is feasible.
>
>
> Is this happening in the JAXB reference implementation? Would you 
> perhaps have any pointers to specifics so I could take a look?
Yes, in javax.xml.bind.ContextFinder where it uses its 
delegateAddOpensToImplModule method to open the packages to the 
implementation module.


>
> Yes, what I like about it is that it makes the need for private access 
> more apparent to the user, if e.g. the library bootstrap is designed 
> in a way that a Lookup object is mandatory (as opposed to the 
> requirement for opening up the user's module/packages, which 
> essentially can only be documented or things will fail at runtime). 
> Although in reality it'd likely have to be multiple Lookup objects, 
> one for each module of the user containing entities or similar. It'll 
> be interesting how to collect those Lookups so they can be passed to 
> the library without making them available to other modules, too.
If the library needs to reflect into several non-open modules then it 
would minimally need a Lookup with MODULE access for each one.

>
> But in respect to my initial question you seem to suggest indeed that 
> the user would have to pass a literal Lookup object which they'd have 
> obtained themselves. So indeed the user code would have to deal with 
> the specifics of Lookup objects.
Right, either explicitly or oerced by some means.

-Alan


More information about the jigsaw-dev mailing list