Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8321386

SymbolLookup.libraryLookup(Path, Arena) Assumes default Filesystem

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 22
    • core-libs
    • None
    • behavioral
    • minimal
    • Rather than silently ignoring any custom file system, an `IllegalArgumentException` will be thrown. As the previous FFM API version was a preview, this change should not affect any production system.
    • Java API
    • SE

    Description

      Summary

      Throw an IllegalArgumentException in Symbol.libraryLookup(Path path, Arena arena) if the path is not in the default file system.

      Problem

      The Symbol.libraryLookup(Path path, Arena arena) method ignores any custom file system as it always uses the default file system anyhow (as it ultimately relies on dlopen).

      Solution

      As it is very difficult (if not impossible) to support custom file systems for library loading, it is better to throw an exception rather than just silently stripping away the file system used. This is also more secure as there is no ambiguity as to the path of the library that should be loaded by the method.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java b/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java
      index 1d04032a1ff3..de955a025419 100644
      --- a/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java
      +++ b/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java
      
      @@ -284,6 +285,7 @@ static SymbolLookup libraryLookup(String name, Arena arena) {
            * @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
            */

      Attachments

        Issue Links

          Activity

            People

              pminborg Per-Ake Minborg
              webbuggrp Webbug Group
              Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: