RFR: 8365898: Specification of java.lang.module.ModuleDescriptor.packages() method can be improved

Chen Liang liach at openjdk.org
Mon Aug 25 17:14:40 UTC 2025


On Mon, 25 Aug 2025 13:19:29 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review of this trivial change to the `ModuleDescriptor.packages()` method's specification?
> 
> The change here clarifies that this method returns all packages that belong to the module and not just those that are exported or open. This clarification should help avoid any confusion that may have been caused by the second paragraph in that method's specification which talks about exported and open packages.
> 
> This updated specification matches the existing implementation of this method.
> 
> I believe this will require a CSR, which I'll create shortly.

There is a parallel structure `ModulePackagesAttribute` in the Class-File API that has the same problem. I checked the [JVMS](https://docs.oracle.com/javase/specs/jvms/se24/html/jvms-4.html#jvms-4.7.26) and it seems that attribute does not mention "all packages" too, but instead says:

> The `ModulePackages` attribute may also indicate packages in the module that are neither exported nor opened nor contain service implementations.

Maybe JVMS can be improved too.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26928#issuecomment-3221079457


More information about the core-libs-dev mailing list