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

SequenceLayout::toString throws ArithmeticException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 22
    • 22
    • core-libs
    • None

      If a sequence layout contains an element type with `byteSize()` zero, the SequenceLayout::toString method will throw an ArithmeticException (division by zero).

      Reproduce:

          @Test
          public void testSequenceLayoutWithZeroLength() {
              SequenceLayout layout = MemoryLayout.sequenceLayout(0, JAVA_INT);
              assertEquals(layout.toString(), "[0:i4]");

              SequenceLayout nested = MemoryLayout.sequenceLayout(0, layout);
              assertEquals(nested.toString(), "[0:[0:i4]]"); // <- Fails!
          }

            pminborg Per-Ake Minborg
            pminborg Per-Ake Minborg
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: