RFR: 8294962: java.base jdk.internal.module package uses ASM to modify and write module-info.class
Adam Sotona
asotona at openjdk.org
Thu Mar 9 17:39:20 UTC 2023
On Wed, 1 Mar 2023 01:19:24 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> 8294962: java.base jdk.internal.module package uses ASM to modify and write module-info.class.
>> This patch converts it to use Classfile API.
>>
>> Please review.
>> Thanks,
>> Adam
>
> src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java line 37:
>
>> 35: import jdk.internal.classfile.Classfile;
>> 36: import jdk.internal.classfile.jdktypes.ModuleDesc;
>> 37: import jdk.internal.classfile.jdktypes.PackageDesc;
>
> I'm a bit surprised of `jdk.internal.classfile.jdktypes` package. ClassFile API is JDK-specific. Would `jdk.internal.classfile.constant` be more appropriate?
`jdk.internal.classfile.jdktypes` package has been renamed to `jdk.internal.classfile.java.lang.constant`
thanks for pointing it out
> 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.
-------------
PR: https://git.openjdk.org/jdk/pull/11368
More information about the core-libs-dev
mailing list