我正在使用以下C++代码初始化Java VM.JNI_CreateJavaVM抛出一个0xC0000005异常,但如果忽略它就会成功.
'Jni.exe'(Win32):加载'C:\ Tools\Java\Jdk8.77x86\jre\bin\zip.dll'.无法找到或打开PDB文件.
Jni.exe中0x02900282处抛出异常:0xC0000005:访问冲突读取位置0x00000000.
'Jni.exe'(Win32):加载'C:\ Windows\SysWOW64\shell32.dll'.无法找到或打开PDB文件.
我忘了设置或做某事还是这种"正常"行为?
#include <array>
#include "jni.h"
int main( int argc, char const* args[])
{
JavaVM* jvm;
JNIEnv* env;
std::array<JavaVMOption,1> options;
options[0].optionString = "-Djava.class.path=C:/Users/Thomas/Documents/Visual Studio 2015/Projects/Jni/x64/Debug";
options[0].extraInfo = nullptr;
JavaVMInitArgs vm_args;
vm_args.version = JNI_VERSION_1_8;
vm_args.options = options.data();
vm_args.nOptions = options.size();
vm_args.ignoreUnrecognized = false;
auto rc = JNI_CreateJavaVM( &jvm, reinterpret_cast<void**>(&env), &vm_args );
if( rc == JNI_OK )
{
jvm->DestroyJavaVM();
}
}
Run Code Online (Sandbox Code Playgroud)
发布和调试以及x86和x64版本都会发生这种情况.