For the following:
typedef struct { int x; } (*CB)(void);
Jextract generates this:
static CB ofAddress(MemoryAddress addr, MemorySession session) {
MemorySegment symbol = MemorySegment.ofAddress(addr, 0, session);
return () -> {
try {
return (java.lang.foreign.MemorySegment)constants$0.CB$MH.invokeExact((Addressable)symbol);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
};
}
Which is incorrect, since it doesn't take the leading SegmentAllocator paramert into account.
Invoking apply will result in WrongMethodTypeException:
CB.ofAddress(MemoryAddress.NULL, MemorySession.openImplicit()).apply();
| Exception java.lang.AssertionError: should not reach here
| at CB.lambda$ofAddress$0 (CB.java:22)
| at (#5:1)
| Caused by: java.lang.invoke.WrongMethodTypeException: expected (Addressable,SegmentAllocator)MemorySegment but found (Addressable)MemorySegment
| at Invokers.newWrongMethodTypeException (Invokers.java:523)
| at Invokers.checkExactType (Invokers.java:532)
| at CB.lambda$ofAddress$0 (CB.java:20)
| ...
typedef struct { int x; } (*CB)(void);
Jextract generates this:
static CB ofAddress(MemoryAddress addr, MemorySession session) {
MemorySegment symbol = MemorySegment.ofAddress(addr, 0, session);
return () -> {
try {
return (java.lang.foreign.MemorySegment)constants$0.CB$MH.invokeExact((Addressable)symbol);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
};
}
Which is incorrect, since it doesn't take the leading SegmentAllocator paramert into account.
Invoking apply will result in WrongMethodTypeException:
CB.ofAddress(MemoryAddress.NULL, MemorySession.openImplicit()).apply();
| Exception java.lang.AssertionError: should not reach here
| at CB.lambda$ofAddress$0 (CB.java:22)
| at (#5:1)
| Caused by: java.lang.invoke.WrongMethodTypeException: expected (Addressable,SegmentAllocator)MemorySegment but found (Addressable)MemorySegment
| at Invokers.newWrongMethodTypeException (Invokers.java:523)
| at Invokers.checkExactType (Invokers.java:532)
| at CB.lambda$ofAddress$0 (CB.java:20)
| ...