Questions tagged [project-panama]
Project panama is the OpenJDK project that aims to create a new way to do native interop from Java.
project-panama
60
questions
0
votes
1
answer
140
views
Java Foreign Function & Memory API, problems with Locale
Long short story, I've been calling the native Lammps using the latest Foreign Function & Memory API (Project Panama) in JDK 22.
I have problems with the locale.
atof will parse 2.2598258677677969 ...
0
votes
0
answers
32
views
Why does a binary produced by graalvm's native-image try to load libc.so.6 on macOS?
Does anyone have a clue why a binary produced by native-image on macOS would try to load libc.so.6 when ran... and not, say, libc.dylib or something similar...? Might someone have ideas on how to fix ...
0
votes
1
answer
83
views
Java FFM: how to manually release a MemorySegment?
I'm reading the documentation for JDK 22 and I cannot find a way to release a native MemorySegment. According to the documentation the only way to create a MemorySegment is to use an Arena, unlike ...
1
vote
1
answer
56
views
Gradle Java include native library (Project Panama)
I've a rust library that I want to call from Java.
I've managed to create the corresponding .h-file and extract from that the Java bindings.
As long as my project structure looks like the following, I ...
3
votes
1
answer
95
views
Java 22 Foreign Function & Memory API: traversing structs
I'm trying to use the Foreign Function & Memory API in Java 22 to call into FFmpeg's libavformat. First, I used jextract to generate a binding:
jextract --target-package org.ffmpeg.avformat \
-...
1
vote
1
answer
108
views
Java Panama / Foreign Function & Memory API: Reading byte arrays of unknown length
Consider a header file defining this method:
ErrorCode_t GetBlob(Handle_const_t hHandle, uint8_t* const pValue, size_t* const pnSize);
This method writes n bytes into the array starting at the ...
-1
votes
1
answer
117
views
Jextract WinUser.h
I am trying to use Jextract of project panama jdk22-ea
When I run
jextract WinUser.h
Then I get the following error:
ERROR: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winnt.h:173:...
4
votes
1
answer
147
views
Java Project Panama result from reading from MemorySegment differs from ByteBuffer
I'm currently investigating switching from memory mapped files using the ByteBuffer/DoubleBuffer API to the newly introduced project Panama API.
Since MemorySegment has the .asByteBuffer method, I ...
0
votes
0
answers
88
views
Java Panama executes the MessageBoxW function of Windows system with garbled characters
now I use the panama interface to call the MessageBoxW function and the code is garbled. The performance is as follows:
enter image description here
normal
enter image description here
err1
enter ...
1
vote
0
answers
103
views
How to use jextract to work with MacOS Framework header files?
I am looking at exploring Java's project Panama for use with some MacOS native programming. I got jextract built and running (thanks to this Q&A).
There is a good doc site at https://foojay.io/...
2
votes
1
answer
180
views
How to access a native byte array via Java java.lang.foreign API
I want to access a PKCS11 library from Java via FFI/Panama. Let's say we have the following packed group layout under Windows x64:
GroupLayout groupLayout = MemoryLayout.structLayout(
MemoryLayout....
1
vote
1
answer
145
views
MemoryLayout::varHandle Problems with structuring via mutable arrays
When constructing a varHandle using MemoryLayout::varHandle, I passed in a self-assembled Object array to implement the public method for constructing the MemorySegment. However, I find that it seems ...
4
votes
1
answer
457
views
How to get a C++ struct return value from Java using the Foreign Function & Memory API
When I try to get the struct return value in C++, I cannot resolve the value in the struct.
This is my structure.
struct Point {
int x;
int y;
};
This is my C++ method
Point test_point(Point ...
4
votes
1
answer
362
views
'IndexOutOfBoundsException: Out of bound access on segment ...' when accessing pointer read from MemorySegment
I am attempting to test the Foreign Function and Memory features of Java 21. Here is my code :
public static void main(String[] args) {
// 1. Find foreign function on the C library path
...
1
vote
1
answer
330
views
Java panama FFI, read (char **) from SDL_Vulkan_GetInstanceExtensions
This is the sample code that im trying to run, both SDL.h and SDL_Vulkan.h extracted with JExtract
The problem im having is getting the pNames which is declared as char**, my understanding of java FFI ...