JDK-8035418 : Not able to parse command line arguments when path contains multiple quotes
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 7u51
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • Submitted: 2014-01-24
  • Updated: 2014-02-20
  • Resolved: 2014-02-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_minorResolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
When path to Java executables contains an even number of quoted string, this executable is not able to parse the command line arguments.

So, for example:
1/ C:\>"C:\Program Files\Java\jre7\bin\java" -version => works
2/ C:\>"C:\Program Files"\"Java\jre7\bin\java" -version => doesn't work
3/ C:\>"C:\Program Files"\"Java"\"jre7\bin\java" -version => work

On jre 1.6.0_45, all these examples work.

See on java.exe, pack200.exe, keytool.exe

REGRESSION.  Last worked in version 6u45

ADDITIONAL REGRESSION INFORMATION:
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
C:\>"C:\Program Files\Java\jre7"\"bin\java" -version

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Java version should be displayed:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
ACTUAL -
Java usage is displayed instead:

C:\>"C:\Program Files\Java\jre7"\"bin\java" -version
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -hotspot      is a synonym for the "server" VM  [deprecated]
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
C:\>"C:\Program Files\Java\jre7\bin\java" -version

Or even:
C:\>"C:\Program Files"\"Java"\"jre7\bin\java" -version
Comments
As of JDK7 the java launcher uses a different command line parser, use of a quotes must be strictly Microsoft specific, the workaround is the correct way to quote an argument with spaces. The problem lies in the interpretation of "\", this is another variant of JDK-8030961, that bug describes the idiosyncrasies of windows parsing. As for this bug, this ought to be closed WNF. Priority justification: Impact: Medium, inconvenient Likelhood: Medium, intermittent. Workaround: Low, quote the entire commenad ILW = MML => P4
20-02-2014