JNI_CreateJavaVM:OpenBSD上的“无法为代码缓存保留足够的空间”

时间:2018-11-07 07:58:47

标签: java c java-native-interface openbsd

我尝试在OpenBSD 6.1虚拟机上使用OpenJDK 1.8从C调用Java代码

有我的测试程序源代码:

#include <stdlib.h>
#include <stdio.h>
#include <jni.h>
int main(int argc, char *argv[])
{

    JavaVMInitArgs args;

    JavaVM *jvm;
    JNIEnv *env;
    JavaVMOption options[1];

    args.version = JNI_VERSION_1_6;

    options[0].optionString = "-Djava.class.path=.";
    args.options = options;
    args.nOptions = 1;

    if ( JNI_CreateJavaVM(&jvm, (void **) &env, (void *) &args))
    {
        fprintf(stderr, "Failed to create the JVM\n");
        exit(1);
    }

    (*jvm)->DestroyJavaVM(jvm);
    return 0;
}

编译:

gcc -I/usr/local/jdk-1.8.0/include -I/usr/local/jdk-1.8.0/include/openbsd -L/usr/local/jdk-1.8.0/jre/lib/amd64/server -ljvm main.c

运行:

# LD_LIBRARY_PATH=/usr/local/jdk-1.8.0/jre/lib/amd64/server/ ./a.out
Error occurred during initialization of VM
Could not reserve enough space for code cache

我尝试添加-XX:ReservedCodeCacheSize=200m选项,但结果始终相同

当我在Linux上运行测试代码时,一切正常

0 个答案:

没有答案