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
1
vote
1 answer

JDK-18 Foreign Functions : How to upCall non-static functions?

I've been playing around with the jdk.incubator.foreign stuff in JDK-18. It's pretty nice. WAY faster than JNI. An order of magnitude faster. The foreign memory stuff is better (and maybe slightly faster) than the UNSAFE stuff. Can't wait for this…
West_JR
  • 372
  • 2
  • 11
1
vote
0 answers

Replicating _mm256_shuffle_epi8 Intrinsic With Java Vector API Shuffle?

I am (mostly for fun) attempting to write a SHA-256 digest function using Java's Vector API. I am using the following AVX2 implementation from bitcoin as a…
brcolow
  • 1,042
  • 2
  • 11
  • 33
1
vote
1 answer

How to access a C_POINTER in a MemoryLayout using Java Panama FFI

Using the FFI preview in JDK 16, I have this memory layout: class FfiTest { static GroupLayout layout = MemoryLayout.ofStruct( C_INT.withName("someInt"), MemoryLayout.ofPaddingBits(32), // So the following pointer is aligned at…
caprica
  • 3,902
  • 4
  • 19
  • 39
0
votes
1 answer

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 is that anything that start with * or ** and so…
YShow
  • 3
  • 2
0
votes
1 answer

How do I get jextract to build on a Macbook air M2 with latest OS

I want to. test the Panama project added APIs and the jextract generator for such on a macbook air M2. There don't seem to be any arm64 prebuilt binaries for jextract. I have zulu jdk 20 installed, cmake, python3, xCode, xCode command line tools,…
peterk
  • 5,136
  • 6
  • 33
  • 47
0
votes
2 answers

Java Foreign API: How to get string from C_POINTER?

I want to use libimobiledevice by Java Foreign API, This is my code, written by Kotlin: class Device { private val arena: Arena = Arena.openConfined() private val udidAddress: MemorySegment = arena.allocate(C_POINTER) private val…
purofle
  • 1
  • 1
0
votes
1 answer

Cant use JEP 434: Foreign Function & Memory API (Second Preview) from kotlin

Do I need to wait until kotlin supports Java 20 bytecode before I can call FFM from my kotlin code? I thought that perhaps since FFM doesnt require any new language features, I could compile with language level 19 and run under Java 20. But I havent…
John Caron
  • 1,367
  • 1
  • 10
  • 15
0
votes
1 answer

Project Panama: can't find function

I'm trying Project Panama (foreign function interface) of Java 19 with following code to read the current directory on Windows 10 (as a simple example). This is the begin of my code: final Linker linker = Linker.nativeLinker(); final SymbolLookup…
Thomas S.
  • 5,804
  • 5
  • 37
  • 72
0
votes
0 answers

Callback function's byte parameter has value out of bounds in project Panama function interface

I'm using the new Foreign function & memory API which is part of project Panama and available in preview in JAVA 19. This is the complete callback function public static byte addFive(byte t) { Byte test = (Byte) t; return (byte)…
Tristan
  • 2,000
  • 17
  • 32
0
votes
1 answer

Java Foreign API: how to pass pointers and pointers address?

I am working with the new Java Foreign API and I have to call two C functions (Java bindings generated using the JExtract tool) that take in input a double pointer and a…
1Z10
  • 2,801
  • 7
  • 33
  • 82
0
votes
1 answer

Java19 Foreign Memory - Read Varint from a MemorySegment

I need to read from a large memory mapped file and as we know, ByteBuffer suffer from many limitations, like the 2GB size limit and developers are unable to deallocate a MemoryMapped file. I was investigating MemorySegment which aims to solve all…
0
votes
0 answers

Error while building Jextract from Project Panama

I've tried following this guide step-by-step https://foojay.io/today/building-project-panamas-jextract-tool-by-yourself/ But sadly when I use git bash in the downloaded jextract folder there occur 3 scenarios: If I just run sh ./gradlew I…
Tim Kochetkov
  • 149
  • 1
  • 11
0
votes
1 answer

How to pass over a value pointer via java foreign memory api

I want to call the following method in C (defined here): heif_image_handle* handle; heif_context_get_primary_image_handle(ctx, &handle); The problem I have is that I have no access via the C-API to the struct heif_image_handle. It is defined as a…
lanthale
  • 23
  • 3
0
votes
1 answer

Patterns for efficient reading from Java MemorySegment

I am working on using Java for reading of (potentially) large amounts of data from (potentially) large files - the scenario is uncompressed imagery from a file format like HEIF. Larger than 2G is likely. Writing is a future need, but this question…
BradHards
  • 650
  • 9
  • 27
0
votes
1 answer

Store multiple byte-arrays in native memory

I have a fixed amount of byte-arrays (byte[]) of fixed length that I want to store in native memory (and later retrieve). However, I'm not too sure how I can directly store multiple arrays in a MemorySegment. I know that I could potentially create…
sqlearner
  • 97
  • 5