RFR: 8294962: java.base jdk.internal.module package uses ASM to modify and write module-info.class

Mandy Chung mchung at openjdk.org
Thu Mar 9 18:02:55 UTC 2023


On Thu, 9 Mar 2023 10:59:25 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java line 146:
>> 
>>> 144: 
>>> 145:                 // packages
>>> 146:                 md.packages().stream().map(PackageDesc::of).toList(),
>> 
>> When writing `module_info.class` via ASM, it only visits the packages if there are packages that aren't exported or open.
>> 
>> Does the ClassFile API add `ModulePackages` attribute only if there are packages that aren't exported or open?
>
> Yes, `Classfile::buildModule` contains logic determining if emission of `ModulePackages` is required or not.

It'd be helpful to add a comment that `ModulePackages` attribute is only emitted if there are packages that aren't exported or open.

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

PR: https://git.openjdk.org/jdk/pull/11368


More information about the core-libs-dev mailing list