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

javapath\java.exe duplicates backslashes when calling actual java.exe

XMLWordPrintable

    • x86_64
    • windows

      ADDITIONAL SYSTEM INFORMATION :
      Windows Server 2019 Essentials (64-bit)

      java version "21" 2023-09-19 LTS
      Java(TM) SE Runtime Environment (build 21+35-LTS-2513)
      Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      `C:\Program Files\Common Files\Oracle\Java\javapath\java.exe` doubles all backslashes when it calls the actual `C:\Program Files\Java\jdk-21\bin\java.exe`.

      Example command typed into cmd:

      "C:\Program Files\Common Files\Oracle\Java\javapath\java.exe" Sleep.java a\1\2\3

      launches a new process with the following command line (per ProcessExplorer):

      "C:\\Program Files\\Java\\jdk-21\\bin\\java.exe" Sleep.java a\\1\\2\\3

      While the extra backslashes in the file path are tolerated by Windows, the extra backlashes in arguments or VM parameters are a cause for problems.

      REGRESSION : Last worked in version 20.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      "C:\Program Files\Common Files\Oracle\Java\javapath\java.exe" PrintArgs.java a\1\2\3

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program prints the following to stdout:
      a\1\2\3
      ACTUAL -
      The program prints the following to stdout:
      a\\1\\2\\3

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

      CUSTOMER SUBMITTED WORKAROUND :
      Call the actual java.exe in `C:\Program Files\Java\jdk-21\bin` directly.

      FREQUENCY : always


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: