public static CompilerAdapter getCompiler(String compilerType,
Task task) throws BuildException {
return getCompiler(compilerType, task, null);
}
Based on the parameter passed in, this method creates the necessary
factory desired.
The current mapping for compiler names are as follows:
- jikes = jikes compiler
- classic, javac1.1, javac1.2 = the standard compiler from JDK
1.1/1.2
- modern, javac1.3, javac1.4, javac1.5 = the compiler of JDK 1.3+
- jvc, microsoft = the command line compiler from Microsoft's SDK
for Java / Visual J++
- kjc = the kopi compiler
- gcj = the gcj compiler from gcc
- sj, symantec = the Symantec Java compiler
- a fully qualified classname = the name of a compiler
adapter
|
public static CompilerAdapter getCompiler(String compilerType,
Task task,
Path classpath) throws BuildException {
if (compilerType.equalsIgnoreCase("jikes")) {
return new Jikes();
}
if (compilerType.equalsIgnoreCase("extjavac")) {
return new JavacExternal();
}
if (compilerType.equalsIgnoreCase("classic")
|| compilerType.equalsIgnoreCase("javac1.1")
|| compilerType.equalsIgnoreCase("javac1.2")) {
task.log("This version of java does "
+ "not support the classic "
+ "compiler; upgrading to modern",
Project.MSG_WARN);
compilerType = "modern";
}
//on java< =1.3 the modern falls back to classic if it is not found
//but on java >=1.4 we just bail out early
if (compilerType.equalsIgnoreCase("modern")
|| compilerType.equalsIgnoreCase("javac1.3")
|| compilerType.equalsIgnoreCase("javac1.4")
|| compilerType.equalsIgnoreCase("javac1.5")
|| compilerType.equalsIgnoreCase("javac1.6")) {
// does the modern compiler exist?
if (doesModernCompilerExist()) {
return new Javac13();
} else {
throw new BuildException("Unable to find a javac "
+ "compiler;\n"
+ MODERN_COMPILER
+ " is not on the "
+ "classpath.\n"
+ "Perhaps JAVA_HOME does not"
+ " point to the JDK.\n"
+ "It is currently set to \""
+ JavaEnvUtils.getJavaHome()
+ "\"");
}
}
if (compilerType.equalsIgnoreCase("jvc")
|| compilerType.equalsIgnoreCase("microsoft")) {
return new Jvc();
}
if (compilerType.equalsIgnoreCase("kjc")) {
return new Kjc();
}
if (compilerType.equalsIgnoreCase("gcj")) {
return new Gcj();
}
if (compilerType.equalsIgnoreCase("sj")
|| compilerType.equalsIgnoreCase("symantec")) {
return new Sj();
}
return resolveClassName(compilerType,
// Memory-Leak in line below
task.getProject().createClassLoader(classpath));
}
Based on the parameter passed in, this method creates the necessary
factory desired.
The current mapping for compiler names are as follows:
- jikes = jikes compiler
- classic, javac1.1, javac1.2 = the standard compiler from JDK
1.1/1.2
- modern, javac1.3, javac1.4, javac1.5 = the compiler of JDK 1.3+
- jvc, microsoft = the command line compiler from Microsoft's SDK
for Java / Visual J++
- kjc = the kopi compiler
- gcj = the gcj compiler from gcc
- sj, symantec = the Symantec Java compiler
- a fully qualified classname = the name of a compiler
adapter
|