RFR: 8306729: Add nominal descriptors of modules and packages to Constants API [v15]

Mandy Chung mchung at openjdk.org
Thu Apr 27 19:06:53 UTC 2023


On Thu, 27 Apr 2023 07:42:29 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> Constants API already provides models for all loadable constants to help programs manipulating class files and modelling bytecode instructions. However no models of module and package constants are provided by Constants API. Every program manipulating class files must implement own models and validation of modules and packages constants.
>> 
>> This pul request adds `java.lang.constant.ModuleDesc` and `java.lang.constant.PackageDesc` to the Constants API. 
>> 
>> Classfile API will follow up and remove its internal implementations of `PackageDesc` and `ModuleDesc`. 
>> 
>> Please review this pull request and attached CSR.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   tests update

Discussed with @briangoetz offline.   We can let `PackageDesc` and `ModuleDesc` model unnamed package/module but the ClassFile API should check to make sure their names are not empty before using them to write to a classfile.

For example, if we had a constructor in `ClassDesc(PackageDesc package, String name)`, it could be tolerant of empty packages and treat it as just `new ClassDesc(name)`.

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

PR Comment: https://git.openjdk.org/jdk/pull/13615#issuecomment-1526167033


More information about the core-libs-dev mailing list