JDK-8210810 : Escaped character at specific position in argument file is not handled properly
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 9,10,11,12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2018-09-16
  • Updated: 2018-10-12
  • Resolved: 2018-09-28
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.
JDK 11 JDK 12
11.0.2Fixed 12 b14Fixed
Description
ADDITIONAL SYSTEM INFORMATION :
Can be reproduced on JDK 9.0.4/10.0.2/11+28, Windows 7 and 10

A DESCRIPTION OF THE PROBLEM :
Recently we found our application throws `ClassNotFoundException`. After some investigation, this is an issue affecting JDK 9/10/11 (which supports @optionFile in `java` argument list) on Windows. 

REGRESSION : Last worked in version 11

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I created a repo to reproduce it:

https://github.com/blindpirate/jdk-cp-option-file-issue

- On Windows (tested on Win 7/10 With 9.0.4/10.0.2/11+28).
- Clone https://github.com/blindpirate/jdk-cp-option-file-issue
- Copy `groovy/groovy-all-2.4.15.jar` to `C:\tcagent1\work-1234567890123456-subprojects-tooling-api-build-integ-test-lib\groovy-all-2.4.15.jar` (this path is at the end of `problematic-cp.txt` file). What matters is the path length.
- `cd jdk-cp-option-file-issue`.
- Run `javac -cp '.;./groovy/groovy-all-2.4.15.jar' Main.java` to perform a compilation.
- Run `java @problematic-cp.txt Main` you get a `java.lang.NoClassDefFoundError: groovy/lang/GroovyObject`.
- Modify `problematic-cp.txt`, add or remove one character in the `-cp` list (don't change the ending `C:\\tcagent1\\work-1234567890123456-subprojects-tooling-api-build-integ-test-lib\\groovy-all-2.4.15.jar;."`), for example, change `C:\\tcagent1\\work\\1234567890123456\\intTestHomeDir\\worker-1\\caches\\4.10.1-20180912160000+0000\\workerMain\\gradle-worker.jar` to `C:\\tcagent1\\work\\1234567890123456\\intTestHomeDir\\worker-1\\caches\\4.10.1-20180912160000+0000\\workerMain\\gradle-worker.ja`
- Run `java @problematic-cp.txt Main` you get the successful result.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Classpath can be read from option file.
ACTUAL -
It doesn't work somehow.

CUSTOMER SUBMITTED WORKAROUND :
Not found.

FREQUENCY : always



Comments
The issue is caused by escape character at the parsing boundary(currently 4096 bytes), and this could causing some characters be duplicated and result in corrupted value.
27-09-2018

This issue is reproducible on all the versions
17-09-2018