RFR: fix normalize method in RuntimeHelper.java.template

Jason Thomas duke at openjdk.org
Fri Nov 3 23:48:50 UTC 2023


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

-------------

Commit messages:
 - fix normalize method

Changes: https://git.openjdk.org/jextract/pull/131/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=131&range=00
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jextract/pull/131.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/131/head:pull/131

PR: https://git.openjdk.org/jextract/pull/131


More information about the jextract-dev mailing list