Qualified exports/opens and services

David Lloyd david.lloyd at redhat.com
Thu Jan 4 14:25:27 UTC 2018


On Thu, Jan 4, 2018 at 8:18 AM, Nicolai Parlog <nipa at codefx.org> wrote:
>  Hi!
>
> First of all, happy new year, everybody.
>
> I got a question regarding qualified exports/opens and services. I
> thought I once read a proposal that a service consumer that some
> packages are exported or opened to could "forward" those privileges to
> the service providers.
>
> As an example, think about JPA and Hibernate (and ignore the ludicrous
> module names):
>
> * app code might `opens com.example.dto to jpa`
> * when app calls `EntityManager`, it locates Hibernate in module
>   `hibernate` as JPA implementation
> * `hibernate` can now reflect over `com.example.dto`
>
> That feature doesn't exist, right?

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".

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...
-- 
- DML


More information about the jigsaw-dev mailing list