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]
- Windows Server 2022(version: 21H2, OS build: 20348.197)
result: error - Windows Server 2022(version: 21H2, OS build: 20348.469)
result: success - Windows Server 2022(version: 21H2, OS build: 20348.2227)
result: error - Windows 10 Enterprise(version: 22H2, OS build: 19045.4412)
result: success
[execution result]
- success
main.exe
count = 1234 - error
main.exe
initialization error(ret = 23)
[build process]
javac Sample.java
native-image -o Sample –shared
cl /I . .main.c Sample.lib
[code]
- Sample.java
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;
}
}
- main.c
#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 = %dn", getCount(thread));
if (graal_tear_down_isolate(thread) != 0) {
fprintf(stderr, "shutdown error(ret = %d)n", ret);
return -1;
}
return 0;
}
[build environment]
- GraalVM
graalvm-jdk-17.0.11+7.1 - Vidual Studio
Visual Studio 2022
cl –version
Microsoft(R) C/C++ Optimizing Compiler Version 19.36.32535 for x64
My expectation is that it will work in any environment.
Kazumoto Shinoda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.