Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5008

[drlvm][kernel] Runtime.exec() cannot load executable with non-ASCII characters in name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • DRLVM
    • None
    • win32

    Description

      Current implementation of Runtime kernel class in DRLVM is unable to handle non-English characters in file names properly. For example you cannot do Runtime.exec() if name of target executable contains Russian letters. Please see the test case below.

      hello.c

      #include <stdio.h>
      int main() {
      printf("%s\n", "Hello world!");
      }

      ExecWithLocalizedName.java

      import java.io.*;

      public class ExecWithLocalizedName {
      public static void main(String argv[]) throws Exception {
      Process proc = Runtime.getRuntime().exec(argv[0]);
      InputStreamReader reader = new InputStreamReader(proc.getInputStream());
      StringBuilder sb = new StringBuilder();
      int c;

      while ((c = reader.read()) != -1)

      { sb.append((char) c); }

      reader.close();

      System.out.println(sb.toString());
      }
      }

      Compile everything (in MSVC environment):
      cl hello.c -o здрасте.exe
      javac ExecWithLocalizedName.java

      If executed on J9 (or RI):
      %J9_HOME%\bin\java ExecWithLocalizedName здрасте.exe
      Hello world!

      If executed on DRLVM:
      %DRLVM_HOME%\bin\java ExecWithLocalizedName здрасте.exe
      Uncaught exception in main:
      java.io.IOException: The creation of the Process has just failed: "чфЁрёЄх.exe"
      at java.lang.Runtime$SubProcess.execVM(Runtime.java:327)
      at java.lang.Runtime.exec(Runtime.java:641)
      at java.lang.Runtime.exec(Runtime.java:584)
      at java.lang.Runtime.exec(Runtime.java:543)
      at ExecWithLocalizedName.main(ExecWithLocalizedName.java:5)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zakha Alexei Zakharov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: