Qualified exports/opens and services
Alan Bateman
Alan.Bateman at oracle.com
Thu Jan 4 15:06:32 UTC 2018
On 04/01/2018 14:25, David Lloyd wrote:
> :
> Hi Nicolai,
>
> You may want to refer to the thread here:
> http://mail.openjdk.java.net/pipermail/jigsaw-dev//2017-November/013315.html
>
> Essentially a module may delegate a private Lookup to itself, or a
> module may do so on behalf of another module. To use your example,
> the module called "jpa" would have to internally create a private
> Lookup on "com.example.dto" and hand it over to the "hibernate"
> module, which would then be able to use it to reflect on private
> members of "com.example.dto".
I suspect Nicolai is looking for Module addOpens:
"API Note: This method can be used for cases where a consumer module
uses a qualified opens to open a package to an API module but where the
reflective access to the members of classes in the consumer module is
delegated to code in another module. Code in the API module can use this
method to open the package in the consumer module to the other module."
but you are right that using Lookup objects would work well here. No
need to open any package, instead have the consumer module pass a Lookup
object as a capability to the framework, the framework passes to the
trusted service provider.
>
> That said, the java.lang.invoke.MethodHandles#privateLookupIn() method
> leaves a little to be desired as it requires a class from the target
> module; it would be nice if there was a variant which accepted a
> Module...
There wouldn't be a lookup class in that case so it would be a different
kinda of lookup object.
-Alan
More information about the jigsaw-dev
mailing list