8293659: Improve UnsatisfiedLinkError error message to include dlopen error details
Reviewed-by: mchung, lucy
This commit is contained in:
parent
cd1cdcdb0d
commit
da4fdfbbf4
@ -328,7 +328,21 @@ public final class NativeLibraries {
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user