RFR: 8331940: ClassFile API ArrayIndexOutOfBoundsException with certain class files

Paul Sandoz psandoz at openjdk.org
Tue May 14 16:02:02 UTC 2024


On Tue, 14 May 2024 13:18:51 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> Class file with `LineNumberTable` attribute element pointing behind the bytecode array throws `ArrayIndexOutOfBoundsException`.
> This patch performs the check and throws  expected `IllegalArgumentException` instead.
> Relevant test is added.
> 
> Please review.
> 
> Thanks,
> Adam

src/java.base/share/classes/jdk/internal/classfile/impl/CodeImpl.java line 241:

> 239:                     int startPc = classReader.readU2(p);
> 240:                     if (startPc > codeLength) {
> 241:                         throw new IllegalArgumentException(String.format("Line number out of range; start_pc=%d, codeLength=%d",

It's the byte code index that is out of range, not the line number associated with it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19230#discussion_r1600292689


More information about the core-libs-dev mailing list