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

javapath/java.exe strips double quotes from command line args

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b28
    • CPU:
      x86_64
    • OS:
      windows_10

      Backports

        Description

        A DESCRIPTION OF THE PROBLEM :
        When installing Java 16.0.1 at least two java.exe files are installed. On my machine:

        1. C:\Program Files\Java\jdk-16.0.1\bin\java.exe
        2. C:\Program Files\Common Files\Oracle\Java\javapath\java.exe

        And #2 is the one linked to the `java` command on the system.

        These two java.exe behave differently with respect to double quoted command line arguments.

        #1 Keeps the double quotes
        #2 Strips the double quotes


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Here's a reproduction:

            public class PrintArgs {
                public static void main(String [] args) {
                    for (String arg: args) {
                        System.out.println(arg);
                    }
                }
            }

        Running this using the installed java (which uses #2 above):

            PS C:\Program Files\Java\jdk-16.0.1\bin> java PrintArgs '\"bar\"'
            bar


        Running it using #1:

            PS C:\Program Files\Java\jdk-16.0.1\bin> .\java.exe PrintArgs '\"bar\"'
            "bar"



        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Should print "bar" (with the double quotes intact).
        ACTUAL -
        Prints bar (double quotes stripped).

        ---------- BEGIN SOURCE ----------
            public class PrintArgs {
                public static void main(String [] args) {
                    for (String arg: args) {
                        System.out.println(arg);
                    }
                }
            }

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

        CUSTOMER SUBMITTED WORKAROUND :
        I have found no workaround what so ever. I'd be super happy to know of one.

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                billyh William Harnois
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: