VaList is buggy on Java 17?

Mark Hammons markehammons at gmail.com
Thu Apr 20 07:00:29 UTC 2023


Hi all,

I know that the panama project is pushing forward on java 20 and 21 right
now, and java 17 is probably not a great concern for you all at the moment,
but I was testing VaList support in my library, Slinc, and it seems to be
flaky on Java 17.0.5. The test in question goes like so:

  property("varargs can be embedded in structs"):
      forAll: (ints: Seq[CInt]) =>
        val numTake = 8
        Scope.confined:
          val va = VarArgsBuilder.fromIterable
            (
              ints.map(a => a: Variadic).take(numTake)
            )
            .build

          val x = va.copy()

          val p = Ptr.copy(E(x))

          ints.take(numTake).foreach: value =>
            assertEquals(va.get[CInt], value, "conversion test")

          ints.take(numTake).foreach: value =>
            assertEquals((!p).list.get[CInt], value)
Originally in this test I was testing if I could write a VaList to a struct
and get it back out and pull the values out of it appropriately. What I
noticed is that if the number of integer values in a row passed into VaList
is 8 or greater, my test fails. 7 or less ints and the test passes. On the
Java 19 implementation, this does not happen, nor does this happen when I
pass a great deal more parameters (but more varied in types, some longs,
some pointers, some structs). This test passes if I randomly generate Long
values and pass those into the VaList.

This is not a critical bug by any means. I can sidestep the issue by
encoding all lower integral types into Long in the java 17 runtime for my
library. I just wanted to bring this to your attention because it's a weird
issue that java 17 users of the foreign api may hit.

Thanks for your time,
Mark Hammons
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230420/8176f54e/attachment-0001.htm>


More information about the panama-dev mailing list