JDK-8308842 : Consolidate exceptions thrown from Class-File API
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-05-25
  • Updated: 2024-01-25
  • Resolved: 2023-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21 b26Fixed
Related Reports
Relates :  
Description
Class-File API actually throws wide variety of exceptions based on the actual situation. Complete error handling code must cover `IndexOutOfBoundsException`, `IllegalStateException` and `IllegalArgumentException`.

Based on previous discussions we decided to consolidate on `IllegalArgumentException` with possible sub-classes.

It allows easy common error handling in majority of use case, however it allows also to distinguish source of the error when needed (for example `javap` needs to know if the exception comes from constant poll or not).

Newly introduced `ConstantPoolException` will extend `IllegalArgumentException` to indicate the source of the problem is in constant pool.

More sub-classes of `IllegalArgumentException` may be introduced later as needed and without disruption of the existing error handlers.

Comments
Changeset: 4b8922f5 Author: Adam Sotona <asotona@openjdk.org> Date: 2023-06-05 18:25:51 +0000 URL: https://git.openjdk.org/jdk/commit/4b8922f57611d06a9bea5c94e2f4493dc42a2053
05-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14143 Date: 2023-05-25 08:29:37 +0000
25-05-2023