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

Spec Clarification - ByteBuffer::alignmentOffset Spec

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 14
    • 14
    • core-libs
    • b32
    • 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

          Issue Links

            Activity

              People

                bpb Brian Burkhalter
                kganapureddy Krushnareddy Ganapureddy
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: