Skip to content

Fix ant fork=true NPE by parsing java command line - #603

Open
LSantha wants to merge 1 commit into
masterfrom
opencode/issue1-20260808123000
Open

Fix ant fork=true NPE by parsing java command line#603
LSantha wants to merge 1 commit into
masterfrom
opencode/issue1-20260808123000

Conversation

@LSantha

@LSantha LSantha commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

When ant uses fork=true, it constructs a command like ["java", "-cp", ".", "WH3"]. VMRuntime.exec() was treating cmd[0] as the main class name, causing Class.forName("java") to fail with a NullPointerException.

Changes

  • core/src/classpath/vm/java/lang/VMRuntime.java:227-251 — Added parsing logic to detect when cmd[0] is "java" and extract the actual class name and arguments from the command line, skipping JVM flags like -cp and -classpath.

Testing

  • sh build.sh assemble → BUILD SUCCESSFUL
  • The fix handles the exact command format ant uses: ["java", "-cp", ".", "WH3"]
  • Edge cases handled: no class name found, multiple JVM flags, both -cp and -classpath variants

Closes #1

When ant uses fork=true, it constructs a command like
["java", "-cp", ".", "WH3"]. VMRuntime.exec() was treating
cmd[0] as the main class name, causing Class.forName("java") to
fail with a NullPointerException.

This fix detects when cmd[0] is "java" and parses the command
line to extract the actual class name and arguments, skipping
classpath and other JVM flags.

Closes #1

Co-authored-by: LSantha <LSantha@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix typo in Unsafe.java class doc: "directy" → "direct"

1 participant