Skip to content

Commit

Permalink
8293659: Improve UnsatisfiedLinkError error message to include dlopen…
Browse files Browse the repository at this point in the history
… 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

3 comments on commit da4fdfb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on da4fdfb Oct 20, 2022

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport da4fdfbb to openjdk/jdk17u-dev due to conflicts in the following files:

  • src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b MBaesken-backport-da4fdfbb

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk da4fdfbbf4ba72ddaf4f27d95f71e95b7ebf8cc1

# Backport the commit
$ git cherry-pick --no-commit da4fdfbbf4ba72ddaf4f27d95f71e95b7ebf8cc1
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport da4fdfbbf4ba72ddaf4f27d95f71e95b7ebf8cc1'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport da4fdfbbf4ba72ddaf4f27d95f71e95b7ebf8cc1.

Please sign in to comment.