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

Spec Clarification - ByteBuffer::alignmentOffset Spec

    Details

    • Subcomponent:
    • Introduced In Build:
      b32
    • Resolved In Build:
      b35

      Backports

        Description

        As per the updated spec:
        https://download.java.net/java/early_access/jdk14/docs/api/java.base/java/nio/ByteBuffer.html#alignmentOffset(int,int)

        "Specifically, the index should either be decremented by the return value, or incremented by the unit size minus the return value. Therefore given

         int value = alignmentOffset(index, unitSize)
        then the identities
         alignmentOffset(index - value, unitSize) == 0
        and
         alignmentOffset(index + (unitSize - value), unitSize) == 0
        must hold."

        I see it' s a normative spec.

        But the mentioned statement is not valid for some values of index and unitSize.

        Please see the attached code snippet.
        It will pass some times and throws IllegalArgumentException sometimes.

        Can you please clarify this.

          Attachments

          1. AlignOffTest.java
            0.5 kB
            Krushnareddy Ganapureddy

            Issue Links

              Activity

                People

                • Assignee:
                  bpb Brian Burkhalter
                  Reporter:
                  kganapureddy Krushnareddy Ganapureddy
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: