Handle long executable paths in Windows process launching #2230
+91
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add shortenWindowsCommandLine() to shorten all command line arguments that exceed Windows MAX_PATH limit, not just the working directory. This fixes issues where Eclipse is unable to launch processes with long executable paths on Windows.
The fix uses Windows GetShortPathName API via Win32Handler to convert long paths to their 8.3 short form before passing them to ProcessBuilder or Runtime.exec().
This was reported in one of my projects, for example when passing a params file (to overcome limitations of too long arguments) it can happen that the path of the parameter file (e.g. java, javadoc and alike tools) itself exceed the path limit.
The same might be if I try to launch
c:\java\inaverylongpathaht... exxeedcsthelimit\java.exeAs there was already similar workaround for the working directory it feels good to have similar for the arguments itself but as I'm not a regular windows user it would be great to get some feedback from others, the fix is quite trying to avoid unnecessary checks so in almost all cases would only be a no-op