PR: 32609 Make bootclasspath construction in <javac> take build.sysclasspath into account. Probably needs to get used in all other tasks supporting bootclasspath as well. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277259 13f79535-47bb-0310-9956-ffa450edef68master
@@ -213,12 +213,12 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||
// as well as "bootclasspath" and "extdirs" | |||
if (assumeJava11()) { | |||
Path cp = new Path(project); | |||
/* | |||
* XXX - This doesn't mix very well with build.systemclasspath, | |||
*/ | |||
if (bootclasspath != null) { | |||
cp.append(bootclasspath); | |||
Path bp = getBootClassPath(); | |||
if (bp.size() > 0) { | |||
cp.append(bp); | |||
} | |||
if (extdirs != null) { | |||
cp.addExtdirs(extdirs); | |||
} | |||
@@ -237,10 +237,13 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||
cmd.createArgument().setValue("-target"); | |||
cmd.createArgument().setValue(target); | |||
} | |||
if (bootclasspath != null && bootclasspath.size() > 0) { | |||
Path bp = getBootClassPath(); | |||
if (bp.size() > 0) { | |||
cmd.createArgument().setValue("-bootclasspath"); | |||
cmd.createArgument().setPath(bootclasspath); | |||
cmd.createArgument().setPath(bp); | |||
} | |||
if (extdirs != null && extdirs.size() > 0) { | |||
cmd.createArgument().setValue("-extdirs"); | |||
cmd.createArgument().setPath(extdirs); | |||
@@ -523,5 +526,19 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)); | |||
} | |||
/** | |||
* Combines a user specified bootclasspath with the system | |||
* bootclasspath taking build.sysclasspath into account. | |||
* | |||
* @return a non-null Path instance that combines the user | |||
* specified and the system bootclasspath. | |||
*/ | |||
protected Path getBootClassPath() { | |||
Path bp = new Path(project); | |||
if (bootclasspath != null) { | |||
bp.append(bootclasspath); | |||
} | |||
return bp.concatSystemBootClasspath("ignore"); | |||
} | |||
} | |||
@@ -35,7 +35,7 @@ public class Jikes extends DefaultCompilerAdapter { | |||
* Performs a compile using the Jikes compiler from IBM. | |||
* Mostly of this code is identical to doClassicCompile() | |||
* However, it does not support all options like | |||
* bootclasspath, extdirs, deprecation and so on, because | |||
* extdirs, deprecation and so on, because | |||
* there is no option in jikes and I don't understand | |||
* what they should do. | |||
* | |||
@@ -46,12 +46,6 @@ public class Jikes extends DefaultCompilerAdapter { | |||
Path classpath = new Path(project); | |||
// Jikes doesn't support bootclasspath dir (-bootclasspath) | |||
// so we'll emulate it for compatibility and convenience. | |||
if (bootclasspath != null) { | |||
classpath.append(bootclasspath); | |||
} | |||
// Jikes doesn't support an extension dir (-extdir) | |||
// so we'll emulate it for compatibility and convenience. | |||
classpath.addExtdirs(extdirs); | |||
@@ -203,13 +197,10 @@ public class Jikes extends DefaultCompilerAdapter { | |||
int firstFileName = cmd.size(); | |||
logAndAddFilesToCompile(cmd); | |||
// this is a quick hack to make things work in a | |||
// Gump/Kaffe/Jikes combo. I promise I'll explain it later - | |||
// and add a real solution as well ;-) Stefan | |||
if ("true".equals(System.getProperty("build.clonevm")) | |||
&& Path.systemBootClasspath.size() > 0) { | |||
Path boot = getBootClassPath(); | |||
if (boot.size() > 0) { | |||
cmd.createArgument().setValue("-bootclasspath"); | |||
cmd.createArgument().setPath(Path.systemBootClasspath); | |||
cmd.createArgument().setPath(boot); | |||
} | |||
return | |||
@@ -530,7 +530,24 @@ public class Path extends DataType implements Cloneable { | |||
* if ${build.sysclasspath} has not been set. | |||
*/ | |||
public Path concatSystemClasspath(String defValue) { | |||
return concatSpecialPath(defValue, Path.systemClasspath); | |||
} | |||
/** | |||
* Concatenates the system boot class path in the order specified | |||
* by the ${build.sysclasspath} property - using the supplied | |||
* value if ${build.sysclasspath} has not been set. | |||
*/ | |||
public Path concatSystemBootClasspath(String defValue) { | |||
return concatSpecialPath(defValue, Path.systemBootClasspath); | |||
} | |||
/** | |||
* Concatenates a class path in the order specified by the | |||
* ${build.sysclasspath} property - using the supplied value if | |||
* ${build.sysclasspath} has not been set. | |||
*/ | |||
private Path concatSpecialPath(String defValue, Path p) { | |||
Path result = new Path(getProject()); | |||
String order = defValue; | |||
@@ -543,11 +560,11 @@ public class Path extends DataType implements Cloneable { | |||
if (order.equals("only")) { | |||
// only: the developer knows what (s)he is doing | |||
result.addExisting(Path.systemClasspath, true); | |||
result.addExisting(p, true); | |||
} else if (order.equals("first")) { | |||
// first: developer could use a little help | |||
result.addExisting(Path.systemClasspath, true); | |||
result.addExisting(p, true); | |||
result.addExisting(this); | |||
} else if (order.equals("ignore")) { | |||
@@ -562,7 +579,7 @@ public class Path extends DataType implements Cloneable { | |||
} | |||
result.addExisting(this); | |||
result.addExisting(Path.systemClasspath, true); | |||
result.addExisting(p, true); | |||
} | |||