Re: RFR: 8331655: ClassFile API ClassCastException with verbose output of certain class files [v2]
On Fri, 3 May 2024 17:13:04 GMT, Adam Sotona wrote: >> Specifically corrupted constant pool of a class file can cause >> ClassCastException, when the entries are accessed by Class-File API in exact >> order. >> >> This fix avoids the ClassCastException and throws ConstantPoolException >> instead. >> Test is attached. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional > commit since the last revision: > > applied suggested changes Nice! - Marked as reviewed by psandoz (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/19088#pullrequestreview-2038729421
Re: RFR: 8331655: ClassFile API ClassCastException with verbose output of certain class files [v2]
> Specifically corrupted constant pool of a class file can cause > ClassCastException, when the entries are accessed by Class-File API in exact > order. > > This fix avoids the ClassCastException and throws ConstantPoolException > instead. > Test is attached. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: applied suggested changes - Changes: - all: https://git.openjdk.org/jdk/pull/19088/files - new: https://git.openjdk.org/jdk/pull/19088/files/59191c6f..2e94a1b0 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk=19088=01 - incr: https://webrevs.openjdk.org/?repo=jdk=19088=00-01 Stats: 15 lines in 1 file changed: 0 ins; 14 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/19088.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/19088/head:pull/19088 PR: https://git.openjdk.org/jdk/pull/19088
Re: RFR: 8331655: ClassFile API ClassCastException with verbose output of certain class files [v2]
On Fri, 3 May 2024 16:25:30 GMT, Paul Sandoz wrote: >> Adam Sotona has updated the pull request incrementally with one additional >> commit since the last revision: >> >> applied suggested changes > > src/java.base/share/classes/jdk/internal/classfile/impl/ClassReaderImpl.java > line 402: > >> 400: int tag = readU1(offset); >> 401: final int q = offset + 1; >> 402: if (tag == TAG_UTF8) { > > Can we call into the tag accepting entryByIndex? e.g., > > if (entryByIndex(index, TAG_UTF8) instanceof AbstractPoolEntry.Utf8EntryImpl > utf8) { > return ... > } > throw new ... > > ? Yes, it is a good opportunity to reduce the code a bit. Thanks! - PR Review Comment: https://git.openjdk.org/jdk/pull/19088#discussion_r1589483133
Re: RFR: 8331655: ClassFile API ClassCastException with verbose output of certain class files
On Fri, 3 May 2024 15:28:05 GMT, Adam Sotona wrote: > Specifically corrupted constant pool of a class file can cause > ClassCastException, when the entries are accessed by Class-File API in exact > order. > > This fix avoids the ClassCastException and throws ConstantPoolException > instead. > Test is attached. > > Please review. > > Thanks, > Adam src/java.base/share/classes/jdk/internal/classfile/impl/ClassReaderImpl.java line 402: > 400: int tag = readU1(offset); > 401: final int q = offset + 1; > 402: if (tag == TAG_UTF8) { Can we call into the tag accepting entryByIndex? e.g., if (entryByIndex(index, TAG_UTF8) instanceof AbstractPoolEntry.Utf8EntryImpl utf8) { return ... } throw new ... ? - PR Review Comment: https://git.openjdk.org/jdk/pull/19088#discussion_r1589423345
RFR: 8331655: ClassFile API ClassCastException with verbose output of certain class files
Specifically corrupted constant pool of a class file can cause ClassCastException, when the entries are accessed by Class-File API in exact order. This fix avoids the ClassCastException and throws ConstantPoolException instead. Test is attached. Please review. Thanks, Adam - Commit messages: - 8331655: ClassFile API ClassCastException with verbose output of certain class files Changes: https://git.openjdk.org/jdk/pull/19088/files Webrev: https://webrevs.openjdk.org/?repo=jdk=19088=00 Issue: https://bugs.openjdk.org/browse/JDK-8331655 Stats: 19 lines in 2 files changed: 12 ins; 0 del; 7 mod Patch: https://git.openjdk.org/jdk/pull/19088.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/19088/head:pull/19088 PR: https://git.openjdk.org/jdk/pull/19088