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

javapath/java.exe strips embedded double quotes from command line arguments

    XMLWordPrintable

Details

    • b02
    • generic
    • generic
    • Verified

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        Windows 10

        java version "17.0.5" 2022-10-18 LTS
        Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191)
        Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)

        (The same behavior can be observed from Java version 1.8 and above)

        A DESCRIPTION OF THE PROBLEM :
        When Installing Java 17.0.5, there at least two java.exe installed:

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

        and #2 is the picked up as the java command on the system.

        The two java's respond differently to embedded quoted arguments on the command line

        #1 keeps the quoted args
        #2 strips them

        Please also see JDK-8266473 which fixed the outer double quoted arguments case.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a java program to print out the command line args:

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

        Running this using the javapath/java.exe (the numbers represent the depth of the embedded quotes):
        "C:\Program Files\Common Files\Oracle\Java\javapath\java.exe" PrintArgs "0\"1\\\"2\\\"1\"0"

        gives back

        0"1\2\1"0

        while running them with java from the jdk directoy,
        "C:\Program Files\Java\jdk-17.0.5\bin\java.exe" PrintArgs "0\"1\\\"2\\\"1\"0"

        gives back

        0"1\"2\"1"0

        i.e. the embedded double quotes are respected.




        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        I expect the result of calling both java.exe's to be the same and to respect the embedded double quotes in command line arguments.
        ACTUAL -
        The result differs between the two invocation, and the embedded double quote is dropped from javapath/java.exe

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: