On Tue, 26 Aug 2025 05:37:49 GMT, Jaikiran Pai <j...@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.
>
> Jaikiran Pai has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Alan's review

Hello Chen,

> 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

I had a look at that attribute and what it returns against the java.base module:


final Path moduleInfo = ... // java.base module-info.class
final ClassModel cm = ClassFile.of().parse(moduleInfo);
final List<ModulePackagesAttribute> attrs = 
cm.findAttributes(Attributes.modulePackages());
for (final ModulePackagesAttribute mpa : attrs) {
    for (final PackageEntry e : mpa.packages()) {
...


and it does indeed return all the packages. If not the JVMS text, perhaps the 
API specification of 
`java.lang.classfile.attribute.ModulePackagesAttribute.packages()` method can 
be simplified to say that it returns all packages? Perhaps as a separate issue?

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

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

Reply via email to