RFR: 8315678: Classfile API ConstantPool::entryCount and ConstantPool::entryByIndex methods are confusing

Adam Sotona asotona at openjdk.org
Tue Sep 5 14:25:05 UTC 2023


Classfile API `ConstantPool::entryCount` and `ConstantPool::entryByIndex` methods are confusing and unsafe to use without knowledge of constant pool specification.
This patch renames `ConstantPool::entryCount` to `ConstantPool::size` and adds checks to `ConstantPool::entryByIndex` for invalid or unusable indexes.
`ConstantPool` newly extends `Iterable<PoolEntry>` for simplified user iteration over all pool entries.
Range checks for invalid index have been added also to `ConstantPoo::bootstrapMethodEntry` methods and several `@jvms` javadoc tags have been added to pool entries.

Please review.

Thanks,
Adam

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

Commit messages:
 - 8315678: Classfile API ConstantPool::entryCount and ConstantPool::entryByIndex is confusing

Changes: https://git.openjdk.org/jdk/pull/15567/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15567&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8315678
  Stats: 100 lines in 27 files changed: 68 ins; 6 del; 26 mod
  Patch: https://git.openjdk.org/jdk/pull/15567.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15567/head:pull/15567

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


More information about the core-libs-dev mailing list