On Mon, 13 Mar 2023 19:59:18 GMT, Adam Sotona <asot...@openjdk.org> wrote:
>>> I think it would be better to change is so that calling it with >>> ModuleAttribute will emit a Module attribute. The overloads that take a >>> Module plus a set of packages can emit a Module + ModulePackage >>> unconditionally. >> >> I'm fine with this. >> >> `buildModule(ModuleAttribute moduleAttribute, List<PackageDesc> packages, >> Consumer handler)` would emit `ModulePackages` unconditionally. It means >> that it would need another `buildModule` variant that takes ModuleAttribute >> and handler only if no `ModulePackages` is generated. > > `buildModule` argument `List<PackageDesc> packages` was explicitly added only > for the purpose of this conditional packages calculation. If the > `ModulePackages` attribute is optional and its content is not calculated, > there is no more reason for this argument. > I would propose to reduce the method to `buildModule(ModuleAttribute > moduleAttribute, Consumer handler)`. `ModulePackages` should be then built > using regular approach inside the handler: > `classBuilder.with(ModulePackagesAttribute.of(...));`. Taking out the variant with `<List<PackageDesc> packages` is a simplification. Adding `ModulePackagesAttribute` is straight-forward. ------------- PR: https://git.openjdk.org/jdk/pull/11368