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

System.load() fails with an UnsatisfiedLinkError if path contains a space char.

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      German Windows (contains a space in the temp-directory where File.createTempFile() creates the file)

      A DESCRIPTION OF THE PROBLEM :
      System.load(String filename) fails if the filename contains a space character.
      This is mostly the case if you create a file with File.createTempFile on a German Windows to copy a native library from a jar-file into it.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to load a library that's absolut path contains a space character
      String path = "an absolut path with space chars"
      System.load(path)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      library should be loaded
      ACTUAL -
      I receive the following exception:

      Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Documents and Settings\breuniga\Local Settings\Temp\SerialPort13860tmp: Can't find dependent libraries
      ...

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      see above

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
        To load a native library from a jar-file I use the following code:

      InputStream inputStream =
         getClass().getClassLoader().getResourceAsStream(path);
      File tmpLibraryFile = File.createTempFile(name, "tmp");
      FileOutputStream outputStream = new FileOutputStream(tmpLibraryFile);
      CopyUtils.copy(inputStream, outputStream);
      outputStream.close();
      System.load(tmpLibraryFile.getAbsolutePath()); <-- fails on German Windows


      If I use a tmpLibraryFile without a space character in the path everything works fine.

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Create the tmpLibraryFile with File.createTempFile(name, "tmp", new File("path_without_space_chars").
      But this is not a good solution, because I have to use a specific directory where the user must have write permissions and this path is platformdependent.

        Attachments

          Activity

            People

            • Assignee:
              uta Alexey Utkin (Inactive)
              Reporter:
              ndcosta Nelson Dcosta
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: