8319265: TestLoadLibraryDeadlock.java fails on windows-x64 "Unable to load b.jar"

Reviewed-by: jpai, rriggs
This commit is contained in:
Mandy Chung 2023-11-02 16:38:30 +00:00
parent e6f46a4326
commit 6ad093ef12
2 changed files with 16 additions and 5 deletions

View File

@ -33,6 +33,7 @@
* triggered from JNI.
*/
import java.lang.*;
import java.net.URISyntaxException;
public class LoadLibraryDeadlock {
@ -78,6 +79,11 @@ public class LoadLibraryDeadlock {
private static String getLocation(Class<?> c) {
var pd = c.getProtectionDomain();
var cs = pd != null ? pd.getCodeSource() : null;
return cs != null ? cs.getLocation().getPath() : null;
try {
// same format as returned by TestLoadLibraryDeadlock::getLocation
return cs != null ? cs.getLocation().toURI().getPath() : null;
} catch (URISyntaxException ex) {
throw new RuntimeException(ex);
}
}
}

View File

@ -169,15 +169,20 @@ public class TestLoadLibraryDeadlock {
"Unable to load native library.");
Asserts.assertTrue(
countLines(outputAnalyzer, "Class1 loaded from " + bJar) > 0,
"Unable to load b.jar.");
countLines(outputAnalyzer, "Class1 loaded from " + toLocationString(bJar)) > 0,
"Unable to load " + toLocationString(bJar));
Asserts.assertTrue(
countLines(outputAnalyzer, "Class2 loaded from " + cJar) > 0,
"Unable to load signed c.jar.");
countLines(outputAnalyzer, "Class2 loaded from " + toLocationString(cJar)) > 0,
"Unable to load signed " + toLocationString(cJar));
Asserts.assertTrue(
countLines(outputAnalyzer, "Signed jar loaded from native library.") > 0,
"Unable to load signed jar from native library.");
}
private static String toLocationString(Path path) {
// same format as returned by LoadLibraryDeadlock::getLocation
return path.toUri().getPath();
}
}