Branch: refs/heads/main
  Home:   https://github.com/pmd/pmd
  Commit: 609dd4efed23a93dd076b7aa648529e50569337c
      https://github.com/pmd/pmd/commit/609dd4efed23a93dd076b7aa648529e50569337c
  Author: Niklas Keller <[email protected]>
  Date:   2026-07-16 (Thu, 16 Jul 2026)

  Changed paths:
    M docs/pages/release_notes.md
    M 
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/TypeAnnotationHelper.java
    A 
pmd-java/src/test/java-resources/net/sourceforge/pmd/lang/java/symbols/testdata/innerannot/Ann.java
    A 
pmd-java/src/test/java-resources/net/sourceforge/pmd/lang/java/symbols/testdata/innerannot/Outer.java
    A 
pmd-java/src/test/java-resources/net/sourceforge/pmd/lang/java/symbols/testdata/innerannot/TestClass.java
    A 
pmd-java/src/test/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/TypeAnnotationHelperTest.java

  Log Message:
  -----------
  [java] fix: IndexOutOfBoundsException for type annotations on inner class 
method signatures (#6866)

* [java] fix: IOOBE for type annotations on inner class method signatures

The while-loop in handleEnclosingType() was missing a bounds check on
the TypePath length. ASM's TypePath.getStep(i) does pure array
arithmetic with no bounds check of its own.

When the loop consumed the last valid INNER_TYPE step and called getStep
one past the end, it read the high byte of the following type_index
field (the CP index of the annotation type).

That byte equals 1 (= INNER_TYPE) when the CP index is in [256, 511], so
the loop over-incremented selectionDepth and crashed on
enclosingTypes.get(-1).

The regression test uses TestClass, which has 300 dummy fields to push
the Ann descriptor past CP index 255, reliably reproducing the crash.

Fixes #5041.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* [docs] Update release notes

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Sören Glimm <[email protected]>



To unsubscribe from these emails, change your notification settings at 
https://github.com/pmd/pmd/settings/notifications


_______________________________________________
Pmd-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmd-commits

Reply via email to