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

Runtime.exec(java.lang.String[], java.lang.String[]) seems broken

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Not verified

      Description

      Runtime.exec(java.lang.String[], java.lang.String[]) seems broken,
      but without docs I can't really tell.


      I get a core dump with the following code.

      import java.io.*;

      class java_lang_Runtime_methods_beta{
              public static void main (String args[]) throws Exception {

                      Runtime r = Runtime.getRuntime();

                      r.traceInstructions(true);

                      r.traceMethodCalls(true);

                      if ( r.freeMemory() > 0 ) {
                              System.out.print("Runtime.freeMemory() passed\\n");
                      }
                      else {
                              System.out.print("Runtime.freeMemory() failed\\n");

                      }
                      r.gc();

                      Process p;
                      String envp[] = new String[3];
                      envp[0] = "SERVER_SOFTWARE=bar";
                      try {
                              int c;
                              p = Runtime.getRuntime().exec("/bin/echo $SERVER_SOFTWARE", envp);
                              InputStream in = p.getInputStream();
                              while ((c=in.read()) >=0)
                                  System.out.print((char)c);
                              System.out.println();
                              String cmds[] = { new String("/bin/echo Test"),
                                      new String("/bin/echo Test2")} ;



                              p = Runtime.getRuntime().exec(cmds, envp);



                              in = p.getInputStream();
                              while ((c=in.read()) >=0)
                                  System.out.print((char)c);
                              System.out.println();
                      }
                      catch (IOException e) {
                               System.out.println("command failed.");
                      }

      // r.load("/usr/lib/libc.so");

      // r.loadLibrary("libc");

                      r.runFinalization();

                      if ( r.totalMemory() > 0 ) {
                              System.out.print("Runtime.totalMemory() passed\\n");
                      }
                      else {
                              System.out.print("Runtime.totalMemory() failed\\n");

                      }

              }
      }

        Attachments

          Activity

            People

            Assignee:
            tlindholsunw Timothy Lindholm (Inactive)
            Reporter:
            hwilliamsunw Headley Williamson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: