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

Runtime.exec(String[], String[]) claims envp is system properties!

XMLWordPrintable

    • 1.2
    • sparc
    • solaris_2.5.1
    • Not verified

          JLS Sec 20.16.6 reads

      Given an array of strings cmdarray, representing the
      tokens of a command line, and an array of strings envp,
      representing an "environment" that defines system
      properties, this method creates a new process in which
      to execute the specified command and returns a Process
      object (§20.15) representing the new process.

          envp is the operating system specific environment strings,
          and not system properties. The following piece of code:

      String[] env = { "foo=bar", "bar=foo" };
      Runtime.getRuntime().exec("ls", env);

          sets the "char *envp[]" of main() in the "ls" program.

          One user tried to exec a java program instead of "ls" and
          excepted his Java program to be able to get at envp values
          via System.getProperty(), which is what a reading of the
          spec seems to imply (see part 2 of evaluation in bug
          4061350). Since Runtime.exec can exec arbitrary programs
          which don't care or know about "system properties", the JLS
          is wrong, and what the code does is correct.

      anand.palaniswamy@Eng 1997-08-26

            gbrachasunw Gilad Bracha (Inactive)
            apalanissunw Anand Palaniswamy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: