Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8361617

CodeBuilder::parameterSlot throws undocumented IOOBE

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25, 26
    • core-libs
    • None
    • behavioral
    • minimal
    • This is the existing behavior of this API.
    • Java API
    • SE

      Summary

      Document that java.lang.classfile.CodeBuilder::parameterSlot(int) method throws an IndexOutOfBoundsException when the input argument is not a valid parameter slot.

      Problem

      In an inspection for all int-accepting methods in ClassFile API, I found this method validates its argument via an ArrayIndexOutOfBoundsException, which is good, but does not document this behavior.

      Solution

      Include this exceptional behavior in the assertions about this method in the specification; specify IOOBE instead of AIOOBE to allow for implementation freedom.

      Specification

      --- a/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java
      +++ b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java
      @@ -132,6 +132,7 @@ public sealed interface CodeBuilder
            * values require two slots.
            *
            * @param paramNo the index of the parameter
      +     * @throws IndexOutOfBoundsException if the parameter index is out of bounds
            */
           int parameterSlot(int paramNo);
      

            liach Chen Liang
            liach Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: