I would like to create shared library(.dll) form java code with graalVM. When I use the shared library which is created from java code by native-image, the execution result has succeeded or failed depending on the execution environment. When the execution result fails, graal_create_isolate fuction return 23. I would like to know how to look up the meaning of this 23 meaning.
The generated header(graal_isolate.h) by native-image command says "a non-zero value on failure.", but the meaning of each value is not written in that header. Please could someone help me? thanks a lot.
[excecution environment and result]
[execution result]
[build process] javac Sample.java native-image -o Sample --shared cl /I .\ .\main.c Sample.lib
[code]
import org.graalvm.nativeimage.IsolateThread;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;
public class Sample {
@CEntryPoint(name = "getCount")
private static int get_count(IsolateThread thread) {
return 1234;
}
}
#include <stdio.h>
#include <stdlib.h>
#include "Sample.h"
int main(void) {
graal_isolate_t *isolate = NULL;
graal_isolatethread_t *thread = NULL;
int ret = graal_create_isolate(NULL, &isolate, &thread);
if (ret != 0) {
fprintf(stderr, "initialization error(ret = %d)\n", ret);
return -1;
}
printf("count = %d\n", getCount(thread));
if (graal_tear_down_isolate(thread) != 0) {
fprintf(stderr, "shutdown error(ret = %d)\n", ret);
return -1;
}
return 0;
}
[build environment]
My expectation is that it will work in any environment.
After making the following changes, the error no longer occurs.
Before:
javac Sample.java
native-image -o Sample --shared
cl /I .\ .\main.c Sample.lib
After:
javac Sample.java
native-image -o Sample --shared -march=compatibility
cl /I .\ .\main.c Sample.lib