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

Chen Liang liach at openjdk.org
Tue Feb 11 02:31:53 UTC 2025


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.

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

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

Changes: https://git.openjdk.org/jdk/pull/23548/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23548&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8342206
  Stats: 413 lines in 9 files changed: 396 ins; 8 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/23548.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23548/head:pull/23548

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


More information about the core-libs-dev mailing list