Skip to content

Commit

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

Reviewed-by: mchung, lucy
  • Loading branch information
MBaesken committed Sep 21, 2022
1 parent cd1cdcd commit da4fdfb
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -328,7 +328,21 @@ boolean open() {
throw new InternalError("Native library " + name + " has been loaded");
}

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

@SuppressWarnings("removal")
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

0 comments on commit da4fdfb

Please sign in to comment.