RFR: fix normalize method in RuntimeHelper.java.template
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Nov 6 09:12:54 UTC 2023
On Sun, 15 Oct 2023 04:10:02 GMT, Jason Thomas <duke at openjdk.org> wrote:
> This was failing for non-primitive types. Here's an example that demonstrates the behavior.
>
> `jextract --source -t org.unix -I /usr/include /usr/include/stdio.h`
>
>
> import java.lang.foreign.Arena;
> import java.lang.foreign.MemorySegment;
>
> import static org.unix.stdio_h.*;
>
> public class Testing {
> public static void main(String[] args) {
> Arena arena = Arena.ofConfined();
> MemorySegment hello = arena.allocateUtf8String("Hello %s\n");
> MemorySegment world = arena.allocateUtf8String("World");
> printf(hello, world);
> fflush(NULL());
> }
> }
>
> Exception in thread "main" java.lang.AssertionError: should not reach here
> at org.unix.stdio_h.printf(stdio_h.java:1520)
> at org.jt70.panama_article.Testing.main(Testing.java:13)
> Caused by: java.lang.IllegalArgumentException: Invalid type for ABI: jdk.internal.foreign.NativeMemorySegmentImpl
> at org.unix.RuntimeHelper$VarargsInvoker.normalize(RuntimeHelper.java:231)
> at org.unix.RuntimeHelper$VarargsInvoker.invoke(RuntimeHelper.java:166)
> at org.unix.stdio_h.printf(stdio_h.java:1518)
> ... 1 more
Hi, the fix looks good. It would be better to do it in the `panama` branch (which is effectively the "tip" of the repository). Thanks! We will then backport, and make sure it's included in a followup round of binaries snapshot.
-------------
PR Comment: https://git.openjdk.org/jextract/pull/131#issuecomment-1794370774
More information about the jextract-dev
mailing list