On Fri, 25 Nov 2022 14:38:55 GMT, Adam Sotona <asot...@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?

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?

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

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

Reply via email to