diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 1a82cd7f865..40f160623bf 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -722,7 +722,16 @@ void* os::get_default_process_handle() { } void* os::dll_lookup(void* handle, const char* name) { - return dlsym(handle, name); + ::dlerror(); // Clear any previous error + void* ret = ::dlsym(handle, name); + if (ret == nullptr) { + const char* tmp = ::dlerror(); + // It is possible that we found a NULL symbol, hence no error. + if (tmp != nullptr) { + log_debug(os)("Symbol %s not found in dll: %s", name, tmp); + } + } + return ret; } void os::dll_unload(void *lib) { diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 23024aa60cc..ddc1b1c335d 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -1280,7 +1280,15 @@ void os::dll_unload(void *lib) { } void* os::dll_lookup(void *lib, const char *name) { - return (void*)::GetProcAddress((HMODULE)lib, name); + ::SetLastError(0); // Clear old pending errors + void* ret = ::GetProcAddress((HMODULE)lib, name); + if (ret == nullptr) { + char buf[512]; + if (os::lasterror(buf, sizeof(buf)) > 0) { + log_debug(os)("Symbol %s not found in dll: %s", name, buf); + } + } + return ret; } // Directory routines copied from src/win32/native/java/io/dirent_md.c