Summary: | java task with fork=true uses different JVM than the one set in JAVACMD environment variable | ||
---|---|---|---|
Product: | Ant | Reporter: | A. Knauf <axel.knauf> |
Component: | Core tasks | Assignee: | Ant Notifications List <notifications> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 1.9.4 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Solaris | ||
Attachments: | Proof of concept project for demonstration of the issue |
Description
A. Knauf
2014-02-13 10:38:30 UTC
I did some additional digging and found out that the Java task definition instantiates a CommandlineJava object (at the very top of the class), which in its constructor determines the java executable using the following piece of code: /** * Constructor uses the VM we are running on now. */ public CommandlineJava() { setVm(JavaEnvUtils.getJreExecutable("java")); setVmversion(JavaEnvUtils.getJavaVersion()); } (CommandlineJava.java @ 225ff) The referred-to JavaEnvUtils.getJreExecutable("java") finds the first matching Java executable within a given JAVA_HOME directory. Unfortunately for Solaris, the directory structure of the JDK/JRE is like this: $JAVA_HOME/bin/ # 32bit executables: java, javac, .. $JAVA_HOME/bin/amd64/ # 64bit executables: java, javac, .. This means, regardless of environment specifications, the first matching Java executable will always be the 32bit one on this environment. In addition, the environment variable $JAVACMD which I mentioned in my initial description is only used inside the (shell, batch) wrapper scripts, so this setting will also not be honored from inside JavaEnvUtils. Does it make sense to extend the logic inside JavaEnvUtils to also take into account this variable when trying to determine which Java executable to use? Without having any further knwoledge of the code base, it seems to be as if this may be a simple extension of the getJreExecutable(..) method. However, I cannot oversee what other parts depend on it and may be affected by a change. |