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

Chen Liang liach at openjdk.org
Mon Apr 24 12:32:53 UTC 2023


On Mon, 24 Apr 2023 11:59:03 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

src/java.base/share/classes/java/lang/constant/PackageDesc.java line 34:

> 32:  * <p>To create a {@linkplain PackageDesc} for a package, use {@link #of} or
> 33:  * {@link #ofInternalName(String)}.
> 34:  *

Needs a link to jvms 4.4.12. Same for ModuleDesc (4.4.11)

src/java.base/share/classes/java/lang/constant/PackageDescImpl.java line 37:

> 35:      * @throws IllegalArgumentException if the package name is invalid
> 36:      */
> 37:     public static String validateBinaryPackageName(String name) {

All these utility methods should be moved to ConstantUtils.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13615#discussion_r1175212686
PR Review Comment: https://git.openjdk.org/jdk/pull/13615#discussion_r1175209163


More information about the core-libs-dev mailing list