Over recent weeks, there has been a long debate about exporting at runtime, with other discussions about resources. I want to express my view that listing specific packages for export seems to be the wrong approach.
In my last thread [1], I found that just 2.5% of packages in the open source libraries I looked at were suitable for being non-exported. In the Strata library, designed for modules, the number rose to 11.7%. As such, shouldn't we consider that the default for modules should be changed? Instead of specifying the list of packages that are to be exported, the module system should specify the list of packages that are to be restricted: module com.foo.bar { requires org.baz.qux; restricts com.foo.bar.alpha; // package is not exported restricts com.foo.bar.beta to com.foo.baz; // export only to a friend restricts at compiletime com.foo.bar.beta; // export "dynamic" } This does not appear to change the underlying model of modules (reliable configuration and strong encapsulation), but would make it much more practical to use. After all, isn't Java meant to be designed for the 80% use case? (which is clearly that everything is exported in most projects) Stephen [1] http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-July/008823.html