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

Java argument file is parsed unexpectedly with trailing comment

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When a Java argument file (@argument_file) contains a comment following immediately (no spaces) a value, then the parser behaves unexpectedly. If it cannot be fixed (due to maintaining backward compatibility), then please document these behavior.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the following simple Java code as `test.javash`:

      ```
      public class Main {
        public static void main(String[] args) {
          for (String arg: args) {
            System.out.println(arg + ": " + System.getProperty(arg));
          }
        }
      }
      ```

      and the following Bash script:

      ```
      run_java() {
        echo "-- input"
        cat args
        echo "-- output"
        java @args --source 24 test.javash my_var1 my_var2 my_var3
        echo "-- end"
        echo
      }

      cat > args <<EOF
      -Dmy_var1=value1 -Dmy_var2=value2#COMMENT
      -Dmy_var3=value3
      EOF
      run_java

      cat > args <<EOF
      -Dmy_var1=value1 -Dmy_var2=value"2"#COMMENT
      -Dmy_var3=value3
      EOF
      run_java

      cat > args <<EOF
      -Dmy_var1=value1 -Dmy_var2=value"2"#COMMENT
       -Dmy_var3=value3
      EOF
      run_java

      cat > args <<EOF
      -Dmy_var1=value1 -Dmy_var2=valu"e"2#COMMENT
      -Dmy_var3=value3
      EOF
      run_java

      cat > args <<EOF
      -Dmy_var1=value1 -Dmy_var2=value2
      -Dmy_var3=value"3"#COMMENT
      EOF
      run_java
      ```

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect all "-- output" parts to contain:
      my_var1: value1
      my_var2: value2
      my_var3: value3
      ACTUAL -
      -- input
      -Dmy_var1=value1 -Dmy_var2=value2#COMMENT
      -Dmy_var3=value3
      -- output
      my_var1: value1
      my_var2: null
      my_var3: value3
      -- end

      -- input
      -Dmy_var1=value1 -Dmy_var2=value"2"#COMMENT
      -Dmy_var3=value3
      -- output
      my_var1: value1
      my_var2: value2-Dmy_var3=value3
      my_var3: null
      -- end

      -- input
      -Dmy_var1=value1 -Dmy_var2=value"2"#COMMENT
       -Dmy_var3=value3
      -- output
      my_var1: value1
      my_var2: value2-Dmy_var3=value3
      my_var3: null
      -- end

      -- input
      -Dmy_var1=value1 -Dmy_var2=valu"e"2#COMMENT
      -Dmy_var3=value3
      -- output
      my_var1: value1
      my_var2: value-Dmy_var3=value3
      my_var3: null
      -- end

      -- input
      -Dmy_var1=value1 -Dmy_var2=value2
      -Dmy_var3=value"3"#COMMENT
      -- output
      my_var1: value1
      my_var2: value2
      my_var3: null
      -- end

            cstein Christian Stein
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: