On Mon, 13 Mar 2023 14:18:55 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> Or another approach for the specific use cases might be to use 
>> `Classfile::buildModule` with empty list of packages and then provide custom 
>> `ModulePackagesAttribute` to the handler directly.
>
>> `Classfile::buildModule` is a helper method simplifying the major use case - 
>> building valid module with minimal user effort and knowledge. It emits 
>> `ModulePackages` if there are any packages specified and not exported nor 
>> opened. That is the configuration which JVM expects and majority of users 
>> are not aware of. 
> 
> ModulePackages is a performance optimization. When present, the value is the  
> set of packages in the module. If not present, the module contents need to be 
> scanned to discover the set of packages. I think it's just a bit too 
> surprising for Classfile::buildModule to emit the ModulePackages attribute 
> sometimes and not others. 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 see, I'll move the "packages magic" back from Classfile API to the 
`ModuleInfoWriter` and correct the API accordingly.

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

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

Reply via email to