Integrated: 8342206: Convenience method to check if a constant pool entry matches nominal descriptors

Chen Liang liach at openjdk.org
Tue Apr 29 03:08:53 UTC 2025


On Tue, 11 Feb 2025 02:26:57 GMT, Chen Liang <liach at openjdk.org> wrote:

> The ClassFile API promotes usage of constant nominal descriptors over literal strings. However, for `class` file parsing, currently the efficient way to check if a constant pool entry matches a desired descriptor is via unrolling them back to strings. However, string unrolling is ugly, and often times confusing, such as internal names versus field descriptors.
> 
> As a result, I propose to provide new methods that compare constant pool entries with the potential symbolic descriptors they represent. This is no less efficient as checking raw string equality, avoids exceptional failure behaviors of conversion to symbolic descriptors, and avoids potential programmer errors stemming from raw string handling. See the CSR for a full story.

This pull request has now been integrated.

Changeset: e4cb49fc
Author:    Chen Liang <liach at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e4cb49fc8531ee7cdc66ed16f5f5e2ec94d1244b
Stats:     440 lines in 9 files changed: 422 ins; 8 del; 10 mod

8342206: Convenience method to check if a constant pool entry matches nominal descriptors

Reviewed-by: asotona

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

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


More information about the core-libs-dev mailing list