[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-core-libs-dev
Subject:    Re: module opens directive and Lookup::defineClass
From:       Kasper Nielsen <kasperni () gmail ! com>
Date:       2023-01-31 23:31:22
Message-ID: CAPs6152dobodsLJ0OyaXuo+cJFO1uPcp_LL6Aario1vtFWTdKQ () mail ! gmail ! com
[Download RAW message or body]

On Tue, 31 Jan 2023 at 21:21, <mandy.chung@oracle.com> wrote:
>
> There is no conflict with JLS 7.2.2 as I can see.

Thanks for getting back to me.

Maybe there isn't a direct conflict. But I still think this is not very
intuitive.

If I have an application with two packages:
    com.acme.foreveryone
    com.acme.secret

And I have the following module descriptor:

module acme {
    opens com.acme.foreveryone to someapp
}

As a user, I would assume that someapp would not have access to classes
in 'com.acme.secret'. While in fact, someapp can just define a class in
com.acme.foreveryone. And then use the generated class to create a lookup
object that can access everything in com.acme.secret.

In practice open only works on the module level now. You cannot restrict open
to only certain packages in a module anymore. But the language gives you that
impression because it allows you to specify which packages to open in a
module descriptor.

I have no problem with that. I do think having to specify every package to
open is maybe a bit too fine-grained in practice. But I just don't see the
point in having the 'opens package to module' construct any more than. Why not
just have 'opens to module' that opens every package in a module to another
module? The same goes for --add-opens why do I need to specify the names of
the packages to open? When one open package allows you to access every other
package in the module. Much easier just to specify the module without packages.

/Kasper


/Kasper
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic