ClassLoader.getPackages()
Jesse Glick
jesse.glick at oracle.com
Mon May 21 11:20:20 PDT 2012
On 05/21/2012 01:11 PM, Alan Bateman wrote:
> it's not clear to me that getPackages make sense
It doubt it is used much, but it should be possible to return something sensible for getPackage(String) and getPackages() even in module mode. The packages of a module
class loader would be those it defines (ClassLoader.packages) plus those accessible to it (i.e. exported) from any modules in its "requires" list, including java.base.
FWIW the NetBeans module system implements nearly this behavior [1]. It cannot perfectly implement it without some API changes: Package.getSystemPackages is not public,
and ClassLoader.getPackage is protected, so it is not straightforward to collect packages defined in JRE-supplied parent ClassLoader's. Jigsaw would of course not be
bound by this problem. Also NB does not currently restrict the result according to visibility (*), though it would probably be easy to do so.
(*) As with other nonnative module systems, NB uses visibility - which it can control - as a substitute for accessibility - which it cannot.
[1] http://hg.netbeans.org/main-silver/raw-file/default/o.n.bootstrap/src/org/netbeans/ProxyClassLoader.java
More information about the jigsaw-dev
mailing list