8321159: SymbolLookup.libraryLookup(Path, Arena) Assumes default Filesystem

Reviewed-by: mcimadamore
This commit is contained in:
Per Minborg 2023-12-06 08:02:52 +00:00
parent 9d776777c5
commit a0920aa436
2 changed files with 42 additions and 0 deletions

View file

@ -37,6 +37,7 @@ import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import java.lang.invoke.MethodHandles;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
@ -284,6 +285,7 @@ public interface SymbolLookup {
* @throws WrongThreadException if {@code arena} is a confined arena, and this method
* is called from a thread {@code T}, other than the arena's owner thread
* @throws IllegalArgumentException if {@code path} does not point to a valid library
* in the default file system
* @throws IllegalCallerException If the caller is in a module that does not have
* native access enabled
*/
@ -292,6 +294,9 @@ public interface SymbolLookup {
static SymbolLookup libraryLookup(Path path, Arena arena) {
Reflection.ensureNativeAccess(Reflection.getCallerClass(),
SymbolLookup.class, "libraryLookup");
if (path.getFileSystem() != FileSystems.getDefault()) {
throw new IllegalArgumentException("Path not in default file system: " + path);
}
return libraryLookup(path, RawNativeLibraries::load, arena);
}