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

RuntimeMXBean.getInputArguments() doesn't handle arguments with spaces properly

XMLWordPrintable

    • b05
    • x86
    • windows_xp
    • Verified

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

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

      A DESCRIPTION OF THE PROBLEM :
      This routine isn't properly returning arguments with spaces in them. This is a problem for us when trying to parse -javaagent flags with spaces for file paths.





      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      >javac -target 1.5 EchoArgs.java

      >java -D"value=one two three" EchoArgs

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      -Dvalue=one two three
      one two three
      ACTUAL -
      -Dvalue=one
      two
      three
      one two three

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class EchoArgs {
          public static void main(String args[]) {
              for (String str: java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()) {
                  System.out.println(str);
              }
              System.out.println(System.getProperty("value"));
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      assume that arguments start with a - and hope that no other values do (i.e., there isn't anything reliable)

            mchung Mandy Chung (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: