Skip to content

ant: <java fork="true"> throws NullPointerException (NPE at address ...) and never runs the class #598

Description

@LSantha

Summary

ant's <java fork="true"> task does not run the class: it throws a hard JVM-level NullPointerException and produces no side effect at all.

Repro (JNode all-plugins boot /full.jgz, serial agent console)

Dir: /devices/hdb1/devtest/ant1 (JFAT).

WH3.java:

public class WH3 { public static void main(String[] a) throws Exception {
  java.io.PrintWriter w = new java.io.PrintWriter(new java.io.FileOutputStream("/devices/hdb1/devtest/ant1/wh3.txt"));
  w.println("WH3 RAN"); w.close(); System.out.println("WH3_SYS_OUT");
} }

build.xml:

<project name="t" default="job">
  <target name="job">
    <javac srcdir="." destdir="."/>
    <java classname="WH3" fork="true" failonerror="true">
      <classpath location="."/>
    </java>
  </target>
</project>

Run ant from that dir.

Observed output:

Buildfile: build.xml
java.lang.NullPointerException: NPE at address 3CDFE8D6

wh3.txt is NOT created and no class output appears — ExecuteJava crashes when forking.

Same project with fork="false" runs the class fine (side effect created), so this is specific to the fork="true" path.

Analysis

The ant <java> task with fork="true" tries to spawn/run the class in another JVM (ant's ExecuteJava / forking machinery). On JNode this path hits a JVM-level NPE (NPE at address ...), before the task body executes.

Suggested fix

Implement forking with a JNode-owned JVM invocation path (like the shell's java command), or explicitly document/disable fork support. Prefer fork="false" meanwhile.

Workaround

Use fork="false" + explicit <classpath> + a public target class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/doneThe agent finished successfully; PR opened or comment posted.area/corecore/ — VM, kernel, scheduler, classmgr, drivers.kind/bugConfirmed bug report with a repro or stack trace.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions