Accessing JVM functions from a GraalVM Shared JNI library.
It'd be helpful if someone could help me with this stackoverflow question, https://stackoverflow.com/questions/76406274/access-java-functions-jni-jna-from-a-graalvm-native-image-shared-library.
Stack Overflow
Access Java functions (JNI/JNA) from a GraalVM Native Image shared ...
I'm here to show you my concern about the difficulty to access java functions from a GraalVM Shared library. Let's say,
My java code is loading a GraalVM Shared library,
public class Main {
sta...
36 Replies
⌛
This post has been reserved for your question.
Hey @daysling! 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 you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Not solved yet...
Did you really ask a question there?
It seems like "I'm having some problem" but I don't really see what exactly the problem is
So, I'm currently loading a shared library built with GraalVM Native-Image, to a JVM with
System.loadLibrary()
; I'm completely able to achieve my goal of executing native-code functions aka the functions from the GraalVM native image from the JVM completely. However, I am stuck at executing/invoking methods/functions inside the Java runtime from The GraalVM Native compiled code.
I'm trying to use JNI/JNA from the native code to execute code at the java runtime
If that makes sense.yeah but I didn't see what the actual problem is. Do you receive an error? What happens? How is that different from what you expect to happen?
Not just explain what you want to do, also explain what the problem is
(in your SO question)
also editing helps with getting people to find your question
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Like my problem is i'm unable to think of a solution
a solution of what?
To access the Runtime JVM functions from the Native-Image DLL
I'm more confused now :/
What do you mean with runtime JVM functions?
And is your question really related to native-image?
and what exactly happens with your current code?
are you talking about upcalls (calling Java code from native code) or about some native code provided by the Java installation?
if you want to call Java code from JNI, maybe https://stackoverflow.com/questions/28042285/calling-a-java-method-from-the-native-code-using-jni helps you?
Stack Overflow
Calling a Java Method from the native code using jni
I am new at using JNI. I successfully write a few programs that call native methods written in c.
Now I need my java code to be called by the native code side after it is initialized. Is it possib...
Let's say this,
Is
HelloLib
Java code which is compiled to a native library with native-image
?Yes
what is the reflection helper for?
because I don't really see how that's related
I'm trying to create a GraalVM wrapper for that class.
What does the
ReflectionHelper
do? And why do you need the wrapper?It's a reflection utility class in the runtime JVM
I need to access it with the GraalVM created dll
So this isn't code written by you?
No it is
So why do you need it?
Like I need it for reflections?
Like I want to use reflections from the GraalVM Native code
to access the JVM runtime
Didn't you say you just wanted to call
printedFromGraal
?
Why do you need reflection for that?Yes that's just an example that I provided..
and what happens when using your current code?
If I could invoke printedFromGraal(), I can do the rest
do it like that?
I get that but I don't want to use C or C++
I want to implement it with Native Image and it's libraries
What happens when using reflection?
It doesn't resolve the class
Include that in your question
ideally the complete error message
GitHub
Native Image Shared Library Java Function with String Parameters co...
Describe the issue When a java function is used to define a CE Graal Native Image shared library (--shared), whose parameters and return value are java String type, and the calling program is likew...
that one seems like it is exactly what you need
Let me check
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.