in src/main/org/apache/tools/ant/taskdefs/Java.java [143:215]
protected void checkConfiguration() throws BuildException {
String classname = getCommandLine().getClassname();
String module = getCommandLine().getModule();
final String sourceFile = getCommandLine().getSourceFile();
if (classname == null && getCommandLine().getJar() == null && module == null && sourceFile == null) {
throw new BuildException("Classname must not be null.");
}
if (!fork && getCommandLine().getJar() != null) {
throw new BuildException(
"Cannot execute a jar in non-forked mode. Please set fork='true'. ");
}
if (!fork && getCommandLine().getModule() != null) {
throw new BuildException(
"Cannot execute a module in non-forked mode. Please set fork='true'. ");
}
if (!fork && sourceFile != null) {
throw new BuildException("Cannot execute sourcefile in non-forked mode. Please set fork='true'");
}
if (spawn && !fork) {
throw new BuildException(
"Cannot spawn a java process in non-forked mode. Please set fork='true'. ");
}
if (getCommandLine().getClasspath() != null
&& getCommandLine().getJar() != null) {
log("When using 'jar' attribute classpath-settings are ignored. See the manual for more information.",
Project.MSG_VERBOSE);
}
if (spawn && incompatibleWithSpawn) {
getProject().log(
"spawn does not allow attributes related to input, output, error, result",
Project.MSG_ERR);
getProject().log("spawn also does not allow timeout", Project.MSG_ERR);
getProject().log(
"finally, spawn is not compatible with a nested I/O <redirector>",
Project.MSG_ERR);
throw new BuildException(
"You have used an attribute or nested element which is not compatible with spawn");
}
if (getCommandLine().getAssertions() != null && !fork) {
log("Assertion statements are currently ignored in non-forked mode");
}
if (fork) {
if (perm != null) {
log("Permissions can not be set this way in forked mode.", Project.MSG_WARN);
}
log(getCommandLine().describeCommand(), Project.MSG_VERBOSE);
} else {
if (getCommandLine().getVmCommand().size() > 1) {
log("JVM args ignored when same JVM is used.",
Project.MSG_WARN);
}
if (dir != null) {
log("Working directory ignored when same JVM is used.",
Project.MSG_WARN);
}
if (newEnvironment || null != env.getVariables()) {
log("Changes to environment variables are ignored when same JVM is used.",
Project.MSG_WARN);
}
if (getCommandLine().getBootclasspath() != null) {
log("bootclasspath ignored when same JVM is used.",
Project.MSG_WARN);
}
if (perm == null && SecurityManagerUtil.isSetSecurityManagerAllowed()) {
perm = new Permissions(true);
log("running " + this.getCommandLine().getClassname()
+ " with default permissions (exit forbidden)", Project.MSG_VERBOSE);
}
log("Running in same VM " + getCommandLine().describeJavaCommand(),
Project.MSG_VERBOSE);
}
setupRedirector();
}