* @throws Throwable
*/
public static void main(String[] argv) throws Throwable {
final FileSystemClassFactory fileSystem =
new FileSystemClassFactoryImpl();
List fileList = new LinkedList();
String bootClassPath = System.getProperty("sun.boot.class.path");
String classPath = System.getProperty("java.class.path");
String sourcePath = ".";
String className = null;
List args = new LinkedList();
boolean debug = true;
String sourceVersion = null;
String targetVersion = null;
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
if (className == null && arg.startsWith("-")) {
if (arg.equals("-sourcepath")) {
if ((i + 1) < argv.length) {
sourcePath = argv[++i];
}
} else if (arg.equals("-classpath") || arg.equals("-cp")) {
if ((i + 1) < argv.length) {
classPath = argv[++i];
}
} else if (arg.equals("-bootclasspath")) {
if ((i + 1) < argv.length) {
bootClassPath = argv[++i];
}
} else if (arg.equals("-source")) {
if ((i + 1) < argv.length) {
sourceVersion = argv[++i];
}
} else if (arg.equals("-target")) {
if ((i + 1) < argv.length) {
targetVersion = argv[++i];
}
} else if (arg.startsWith("-g")) {
debug = !arg.equals("-g:none");
} else if (arg.equals("-help")) {
usage();
return;
} else {
unknownOption(arg);
}
} else {
if (className == null) {
className = argv[i];
} else {
args.add(argv[i]);
}
}
}
if (className == null) {
usage();
return;
}
fileSystem.setBootClassPath(bootClassPath);
fileSystem.setClassPath(classPath);
fileSystem.setSourcePath(sourcePath);
final JavaCompiler compiler = new JavaCompilerImpl();
compiler.setDebug(debug);
if (sourceVersion != null) {
compiler.setSourceVersion(sourceVersion);
}