8278753: Runtime crashes with access violation during JNI_CreateJavaVM call

Reviewed-by: dholmes, stuefe
This commit is contained in:
Yumin Qi 2022-02-03 18:02:40 +00:00
parent 86c24b319e
commit cda9c3011b
6 changed files with 35 additions and 31 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,6 +30,7 @@
*/
#include "jni.h"
#include "jvm.h"
#include "imageDecompressor.hpp"
#include "endian.hpp"
#ifdef WIN32
@ -57,24 +58,14 @@ static ZipInflateFully_t ZipInflateFully = NULL;
* @return the address of the entry point or NULL
*/
static void* findEntry(const char* name) {
void *addr = NULL;
#ifdef WIN32
HMODULE handle = GetModuleHandle("zip.dll");
if (handle == NULL) {
handle = LoadLibrary("zip.dll");
}
if (handle == NULL) {
return NULL;
}
addr = (void*) GetProcAddress(handle, name);
return addr;
#else
addr = dlopen(JNI_LIB_PREFIX "zip" JNI_LIB_SUFFIX, RTLD_GLOBAL|RTLD_LAZY);
void *addr = JVM_LoadZipLibrary();
if (addr == NULL) {
return NULL;
}
addr = dlsym(addr, name);
return addr;
#ifdef WIN32
return (void*) GetProcAddress(static_cast<HMODULE>(addr), name);
#else
return dlsym(addr, name);
#endif
}