native <-> java question
guys is the technique that game engines use to talk with c# similar to JNI
22 Replies
⌛
This post has been reserved for your question.
Hey @kys! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
I am not sure what you mean with what game engines use to talk with C# but if you want to call native code from a Java application, you can use the foreign function and memory API
game engines use c# for scriptting
they use mono
or smthg idk
what is memory api
so what do you want to interact with in Java there?
The "Foreign Function and Memory API" is part of the standard libraries you can use in Java programs and it allows you to call non-Java code and access program memory that isn't managed by the JVM
im making a game engine
but instead of c# for scripting
i use java
core in cpp btw
Then you can use the Foreign function and memory API to call the C++ code from Java
hmm
but note that requires JDK 22 or later: https://openjdk.org/jeps/454
what about call java from cpp
You can use the foreign function and memory API as well
essentially you can create an upcall handle from Java code (which is essentially a reference to a Java method) and give that to C++ code
does it only can call function or it can be variable accessable too
that's the memory part of the foreign function and memory API
damn
you can use an
Arena
to allocate foreign memory from Java and then pass that memory to native code essentiallyis the 'memory API' thing in java.lang.foreign or smthg else
yes, that package is the foreign function and memory API
You might also want to read https://dev.java/learn/ffm/
Dev.java: The Destination for Java Developers
The Foreign Function and Memory API - Dev.java
The Foreign Function and Memory (FFM) API facilitates Java programs to interoperate with code and data outside the Java runtime without the brittleness and danger of JNI.
ok thank you
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Invoke a C Library Functionthat should also work with your C++ code
i though that i have to use getter and setter with JNI for my game engines
Post Closed
This post has been closed by <@1352291760360914964>.