Skip to content


Browse files Browse the repository at this point in the history
8293659: Improve UnsatisfiedLinkError error message to include dlopen…
… error details

Reviewed-by: mchung
Backport-of: da4fdfbbf4ba72ddaf4f27d95f71e95b7ebf8cc1
  • Loading branch information
MBaesken committed Oct 25, 2022
1 parent 525b9fc commit 491d800
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -385,7 +385,21 @@ boolean open() {
throw new InternalError("Native library " + name + " has been loaded");

return load(this, name, isBuiltin, isJNI, loadLibraryOnlyIfPresent);
return load(this, name, isBuiltin, isJNI, throwExceptionIfFail());

private boolean throwExceptionIfFail() {
if (loadLibraryOnlyIfPresent) return true;

// If the file exists but fails to load, UnsatisfiedLinkException thrown by the VM
// will include the error message from dlopen to provide diagnostic information
return AccessController.doPrivileged(new PrivilegedAction<>() {
public Boolean run() {
File file = new File(name);
return file.exists();

Expand Down

1 comment on commit 491d800

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.