SequenceLayout::toString throws ArithmeticException

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 22
    • Affects Version/s: 22
    • Component/s: 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!
          }

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

              Created:
              Updated:
              Resolved: