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

Dropping backslash from the ends of command-line arguments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 7-pool
    • 7u10
    • tools

      FULL PRODUCT VERSION :
      C:\Program Files\Java\jdk1.7.0_10\bin>java -version
      java version " 1.7.0_10 "
      Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows Server 2003 Enterprise x64 Edition Service Pack 2

      A DESCRIPTION OF THE PROBLEM :
      Looks like the Java 1.7u10 started to drop the backslash from the end of command-line arguments. If you compare:

      Nice comparison at http://stackoverflow.com/questions/13913196/file-separator-java-7-option-causes-exceptionininitializererror/14055630#comment19766438_14055630

      public class test {
        public static void main(String[] argz) {
          for(String s : argz) {
           System.out.println( " agg= " + s + " | " );
          }

          System.out.println( " prop= " + System.getProperty( " prop " ) + " | " );
        }
      }

      I start it with Java 1.7.0_07 and _10:

      C:\Java\jdk1.7.0_07\bin\java.exe -cp . -Dprop=z\\ test a\\ b
      agg=a\\|
      agg=b|
      prop=z\\|

      and _10

      C:\Java\jdk1.7.0_10\bin\java.exe -cp . -Dprop=z\\ test a\\ b
      agg=a|
      agg=b|
      prop=z|



      Also, this uses issues while passing file.separator=\ argument, which e.g. causes TeamCity build agent to fail: http://youtrack.jetbrains.com/issue/TW-25070

      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create the single main class from the description and run the provided commands.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      u10 should behave the same like the previous u07 or u09
      ACTUAL -
      Backslash dropped from the command line arguments, which should not occur.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.*;

      public class test {
        public static void main(String[] argz) {
          for(String s : argz) {
           System.out.println( " agg= " + s + " | " );
          }

          System.out.println( " prop= " + System.getProperty( " prop " ) + " | " );
        }
      }
      ---------- END SOURCE ----------

            ksrini Kumar Srinivasan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: