Exporting - the wrong default?

David Holmes david.holmes at oracle.com
Tue Aug 2 01:26:09 UTC 2016


On 2/08/2016 1:58 AM, Stephane Epardaud wrote:
> I don't think public ever meant "public to the world". In Java 1->8 it
> means "visible to those who can see the containing scope". If you
> declare a public inner class in a private (or package-private) class,
> then those who cannot access the outer type also cannot access the
> public inner class.
>
> So no, "public" never meant "visible to everyone", it was always about
> scope.
>
> On the other hand, for toplevel types, the scope had always been the
> package, and packages were public by default. Now that default changes
> to private, but notice that even here, a package is only private outside
> its scope (the module). Other packages in the same scope (module) will
> be able to access it.
>
> So for me it's always been about exporting from the current scope.

That is my take on this exactly. Modules introduce a new scoping layer. 
If you want packages to now appear to users of a module, you have to 
export them.

David H.


> On 01/08/16 17:38, Paul Benedict wrote:
>> To echo David, there is a complaint by me in these archives how I still
>> find it difficult to remember that "public" is no longer being public. I
>> feel the same way today still. The word "public" means "for everyone" so
>> it's always jarring to have it no longer mean what it should mean in
>> normal
>> English. Also, I find it less than appealing to do double-duty to make my
>> classes public. I now have to remind myself to export my package but it's
>> still something I forget. I find this step to be a nuisance. That's my
>> real
>> world feedback.
>>
>


More information about the jigsaw-dev mailing list