RFR: 8320360: ClassFile.parse: Some defect class files cause unexpected exceptions to be thrown [v2]

Adam Sotona asotona at openjdk.org
Thu Dec 7 07:53:58 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

Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:

 - Merge branch 'master' into JDK-8320360-bounds
   
   # Conflicts:
   #	test/jdk/jdk/classfile/LimitsTest.java
 - 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=01
  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