调用DestroyJavaVM后重新调用JNI_CreateJavaVM返回-1

调用DestroyJavaVM后,我试图调用JNI_CreateJavaVM。

我按照以下顺序调用它们:InitJVM – > ReleaseJVM – > InitJVM

初始化时,JNI_CreateJavaVM返回0,并正常工作。 第二次在销毁后初始化时,JNI_CreateJavaVM返回-1而不起作用。

会有什么问题?

这是一个创buildJVM的函数:

#elif __linux HRESULT PWNJava::InitJVM(void) { if(m_bRunning) { Log("Error : JVM is already Running! (PWNJava::Init)"); return PWN_FAIL; } const int kNumOptions = 3; JavaVMOption options[kNumOptions] = { { const_cast<char*> ("-Xmx128m"), NULL}, { const_cast<char*> ("-verbose:gc"), NULL}, { const_cast<char*> ("-Djava.class.path=../../Class"), NULL} }; JavaVMInitArgs vm_args; vm_args.version = JNI_VERSION_1_6; vm_args.options = options; vm_args.nOptions = sizeof (options) / sizeof (JavaVMOption); assert(vm_args.nOptions == kNumOptions); int res = JNI_CreateJavaVM(&jvm, reinterpret_cast<void**> (&env), &vm_args); if (res != JNI_OK) { Log("Error : createJavaVM(&jvm, &env, &vm_args)"); return PWN_FAIL; } m_bRunning = true; Log("Success : PWNJava::Init"); return PWN_OK; } #endif 

这里是一个删除JVM的函数:

 void PWNJava::ReleaseJVM(void) { if (jvm) jvm->DestroyJavaVM(); jvm = NULL; delete jvm; env = NULL; delete env; m_bRunning = false; Log("Success : PWNJava::ReleaseJVM"); } 

Solutions Collecting From Web of "调用DestroyJavaVM后重新调用JNI_CreateJavaVM返回-1"