RFR: 8320360: ClassFile.parse: Some defect class files cause unexpected exceptions to be thrown
Adam Sotona
asotona at openjdk.org
Tue Nov 21 14:06:18 UTC 2023
ClassFile API throws `IndexOutOfBoundsException` when classfile structure is corrupted so the parser attempts to read beyond the classfile bounds.
General contract is that only `IllegalArgumentException` or its subclasses is expected when parser fails.
This patch wraps `IndexOutOfBoundsExceptions` thrown from all `ClassReaderImpl.buffer` manipulations into an `IllegalArgumentException("Reading beyond classfile bounds", iOOBECause)`.
Relevant tests are added.
Please review.
Thanks,
Adam
-------------
Commit messages:
- added bug # to the test
- 8320360: ClassFile.parse: Some defect class files cause unexpected exceptions to be thrown
Changes: https://git.openjdk.org/jdk/pull/16762/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16762&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8320360
Stats: 69 lines in 2 files changed: 47 ins; 0 del; 22 mod
Patch: https://git.openjdk.org/jdk/pull/16762.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16762/head:pull/16762
PR: https://git.openjdk.org/jdk/pull/16762
More information about the core-libs-dev
mailing list