> Some core reflection APIs look for methods in classfile format that are > expected to be present from the Java compiler. These APIs are: > `Class.getEnclosingMethod`/`Constructor` and `RecordComponent.getAccessor`. > > Currently, the Class ones throw `InternalError`, and the RecordComponent one > returns null. These are not suitable behaviors as `InternalError` indicates > an unrecoverable VM error, and a null return can propagate the error > downstream and is not informative. > > I propose to make these methods all throw `NoSuchMethodError`, a subtype of > `LinkageError` and `IncompatibleClassChangeError`, which more accurately > reflects the cause of these scenarios. This is also more in line with other > failure modes of APIs like `Class.getDeclaringClass`, which throws > `NoClassDefFoundError`.
Chen Liang has updated the pull request incrementally with one additional commit since the last revision: Make resolution error reporting more concise ------------- Changes: - all: https://git.openjdk.org/jdk/pull/30506/files - new: https://git.openjdk.org/jdk/pull/30506/files/29427874..ea519a01 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=30506&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=30506&range=00-01 Stats: 7 lines in 1 file changed: 5 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/30506.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/30506/head:pull/30506 PR: https://git.openjdk.org/jdk/pull/30506
