gnodet-bot commented on PR #13996:
URL: https://github.com/apache/maven/pull/13996#issuecomment-6949990860
@AmarGhugare The Windows integration-test failures are caused by the new
backslash-escape handling in `parseArguments()` eating Windows path separators.
## Root cause
The failing test is `MavenITmng5669ReadPomsOnce`. Its `.mvn/jvm.config`
contains:
```
-javaagent:${javaAgentJar}
```
At test time, `${javaAgentJar}` is expanded to a Windows path like:
```
D:\a\maven\maven\its\core-it-suite\target\user-home\.m2\repository\...\core-it-javaagent-2.1-SNAPSHOT.jar
```
The new code in `parseArguments()` (and symmetrically in
`ArgumentTokenizer.tokenize()`) treats any `\X` outside single-quotes as an
escape sequence and consumes the `\`, emitting only `X`. So every `\` in the
Windows path is stripped:
```
D:\a\maven\maven\its\... → D:amavenmavenits...
```
The JVM then fails to load the agent jar (`Error opening zip file or JAR
manifest missing`), crashing Maven before it even starts — hence the `Error
occurred during initialization of VM` you see in CI stderr.
## Why it only fails on Windows
On Linux/macOS, paths use `/` which is not a special character in the
tokenizer, so no stripping occurs.
## The fix
The backslash-as-escape semantics conflict with **Windows file paths** that
appear in unquoted arguments. When the test harness expands `${javaAgentJar}`
and writes the resulting Windows path into `jvm.config`, those raw backslashes
enter `parseArguments()` unquoted. The new escape code then eats them.
The safest minimal fix is **option 1**: only treat `\X` as an escape
sequence when **inside double-quotes** (the standard POSIX rule). Outside any
quotes, a backslash is a literal character — which is also how the Windows
`@argfile` format handles it. This means:
- Inside `"..."`: `\"` → literal `"`, `\\` → literal `\`
- Outside quotes: `\` is always a literal backslash
This fixes Windows paths in unquoted arguments without breaking the
escape-in-quoted-string feature. The `JvmConfigParserTest` case `-Dname=hello\
world` (backslash-space outside quotes) would need to be updated: on Windows
that backslash is literal, so the result would be `-Dname=hello\` and ` world`
as two separate tokens — or the test fixture should use quotes instead:
`-Dname="hello world"`.
---
_This review was generated by an AI agent, Hermès, on behalf of @gnodet._
<!-- reviewer: gnodet-bot -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]