RFR: 8333812: ClassFile.verify() can throw exceptions instead of returning VerifyErrors

Adam Sotona asotona at openjdk.org
Thu Jul 18 16:29:56 UTC 2024


`ClassFile.verify()` should always return list of verification errors and never throw an exception, even for corrupted classes.
`BoundAttribute` initializations of `LocalVariableTable` and `LocalVariableTypeTable` attributes do not expect invalid possible locations and cause `ClassCastException`.

This patch fixes `BoundAttribute` to throw `IllegalArgumentException` for invalid `LocalVariableTable` and `LocalVariableTypeTable` attributes locations. And makes `VerifierImpl` a bit more resilient to exceptions thrown from the verifier initialization.

Relevant test is added.

Please review.

Thanks,
Adam

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

Commit messages:
 - 8333812: ClassFile.verify() can throw exceptions instead of returning VerifyErrors

Changes: https://git.openjdk.org/jdk/pull/20241/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20241&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8333812
  Stats: 31 lines in 3 files changed: 25 ins; 0 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/20241.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20241/head:pull/20241

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


More information about the core-libs-dev mailing list