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 is the OpenJDK project that aims to create a new way to do native interop from Java, without the need to manually write glue-code libraries (like needed with JNI), and aims at providing better performance characteristics when compared to JNI.

47 questions
10
votes
1 answer

How to call a C function from Java 17 using JEP 412: Foreign Function & Memory API

Does anybody have a simple example on how to call a C function from Java 17 that includes creating a C library and how to setup a MethodHandle? The JEP description at https://openjdk.java.net/jeps/412 does have an example, but I've been struggling…
9
votes
1 answer

OpenJDK Panama Vector API jdk.incubator.vector not giving improved results for Vector dot product

I am testing OpenJDK Panama Vector API jdk.incubator.vector and I performed tests on amazon c5.4xlarge instance. But in every case simple unrolled vector dot product is out performing the Vector API code. My Question is : Why am I not able to get…
Nitiraj
  • 614
  • 1
  • 4
  • 15
8
votes
1 answer

Java, project panama and how to deal with Hunspell 'suggest' result

I'm experimenting with Hunspell and how to interact with it using Java Project Panama (Build 19-panama+1-13 (2022/1/18)). I was able to get some initial testing done, as in creating a handle to Hunspell and subsequently using that to perform a spell…
ppp ppp
  • 83
  • 3
5
votes
1 answer

Why Java SIMD (Panama) is slower than scalar?

I have followed the intel tutoriel for SIMD in Java with Panama. I want to do some simple operations on arrays: Here the scalar and vector loop from the website : public static void scalarComputation(float[] a, float[] b, float[] c) { for (int…
K.Vu
  • 143
  • 5
5
votes
1 answer

Java 10 Panama Project - port JNI solutions to Panama

I have been reading about the Panama Project recently. I understand that it will be the next generation replacement to JNI - it will allow java developers to code on the native layer using Java (which is amazing IMHO). The usage is simple from what…
Rann Lifshitz
  • 4,040
  • 4
  • 22
  • 42
4
votes
1 answer

Java foreign function interface (FFI) interop with C++?

As of Java 18 the incubating foreign function interface doesn't appear to have a good way to handle C++ code. I am working on a project that requires bindings to C++ and I would like to know how to avoid creating a thunk library in C. One of the C++…
gudenau
  • 500
  • 5
  • 19
4
votes
2 answers

CLinker.toCString replacement in Java 18

Java 16, as part of incubating package jdk.incubator.foreign, used to provide convenient way to convert Java Strings to C strings of arbitrary Charset using MemorySegment CLingker.toCString​(String str, Charset charset, NativeScope scope). That…
czerny
  • 15,090
  • 14
  • 68
  • 96
4
votes
1 answer

Fatal error "'stdlib.h' file not found" when running jextract on the C binding for a Rust project

I want to use Project Panama's jextract tool to build a Java binding to a Rust library. When running the following command, I get an error: jextract -C -x -C c++ -I /Library/Developer/CommandLineTools/usr/include/c++/v1 -t adder -o adder.jar…
junglie85
  • 1,243
  • 10
  • 30
3
votes
1 answer

Can BlockingQueue make MemorySegment visible for multiple threads?

I am using JDK20's FFI, and I need to pass a Object to a BlockingQueue to shared it from one thread to another. The Object contains several MemorySegment field, which belongs to Arena.openShared(). Before passing, I write some bytes into the…
benrush
  • 43
  • 4
3
votes
1 answer

Java: Performance of ByteBuffer versus jdk.incubator.foreign (Panama) Foreign Memory methods (MemoryLayout/Segment)

Background I'm self-studying databases in my spare time, trying to learn by implementing one ground-up. One of the first things you have to implement is the underlying data format and storage mechanisms. In DB's, there is a structure called a…
Gavin Ray
  • 595
  • 1
  • 3
  • 10
3
votes
1 answer

Eclipse Content Assist doesn't suggest jdk.* classes

I configured my project to use a Project Panama EA JDK, I can use jdk.incubator.foreign.* manually but Content Assist and Quick Fix don't suggest/fix anything from this package. Is there a way to configure Content Assist or something? (I looked into…
JBritannia
  • 43
  • 6
3
votes
1 answer

JEP 412: Pass a on-heap byte array to native code, getting UnsupportedOperationException: Not a native address

All this is with the new JDK 17. I'm attempting to turn an on-heap byte array into a MemorySegment and pass that to a native function. I created simple sample code that shows this: final CLinker cLinker = CLinker.getInstance(); …
user2959589
  • 362
  • 1
  • 9
  • 23
3
votes
1 answer

How to store an Object-Array in native Memory using Java Panama

I want to implement a datastructure in native memory using the Foreign Memory Access API of Project Panama. In order to do that I need an underlying Object array (Object[]) for the entries. In all the examples for the Foreign Memory Access API,…
sqlearner
  • 97
  • 5
3
votes
0 answers

Can't use jdk.incubator.vector classes in BigInteger

I'm trying to use the Java Vector API from the Panama project to add some SIMD code to the java.math.BigInteger class. I cloned the Panama repo and built a JDK: hg clone http://hg.openjdk.java.net/panama/dev/ cd dev/ hg checkout vectorIntrinsics hg…
xhunterx
  • 31
  • 3
2
votes
1 answer

Porting JNA code to Foreign Function & Memory API (FFM), fails for String[] returned from C library

Porting JNA code to Foreign Function & Memory API (FFM) (Java 19, JEP 424), fails for String[] returned array from C C API: int nc_get_att_string( int ncid, int varid, const char * name, char…
John Caron
  • 1,367
  • 1
  • 10
  • 15
1
2 3 4