in modules/rmi/src/main/java/org/apache/harmony/rmi/compiler/RMICompiler.java [324:538]
private RMICompiler(String[] args, Object[] classes)
throws RMICompilerException {
int numArgs = args.length;
int version = VERSION_NOT_SET;
boolean keepSources = false;
boolean always = false;
boolean factory = false;
boolean valueMethods = true;
boolean localStubs = true;
boolean poa = false;
boolean debug = false;
boolean warnings = true;
boolean writeClasses = true;
boolean verbose = false;
boolean depend = false;
boolean optionsPresent = (numArgs > 0);
String destinationDir = "."; //$NON-NLS-1$
ArrayList javacOptionsList = new ArrayList();
// User doesn't need any warnings on compiling stubs, as all possible
// issues that may appear concern RMI specification, not user classes.
javacOptionsList.add(optionNoWarnings);
// Parse arguments, adjust values of option fields,
// add necessary options to javacOptionsList.
for (int i = 0; i < numArgs; i++) {
String arg = args[i].intern();
if (arg == optionV11) {
if (version == VERSION_NOT_SET) {
version = VERSION_V11;
} else {
error(errorVersionText);
}
} else if (arg == optionV12) {
if (version == VERSION_NOT_SET) {
version = VERSION_V12;
} else {
error(errorVersionText);
}
} else if (arg == optionVCompat) {
if (version == VERSION_NOT_SET) {
version = VERSION_VCOMPAT;
} else {
error(errorVersionText);
}
} else if (arg == optionIDL) {
if (version == VERSION_NOT_SET) {
version = VERSION_IDL;
} else {
error(errorVersionText);
}
} else if (arg == optionIIOP) {
if (version == VERSION_NOT_SET) {
version = VERSION_IIOP;
} else {
error(errorVersionText);
}
} else if (arg == optionTarget) {
if (i < (numArgs - 1)) {
// If parameter is available,
// add options to javacOptionsList.
String target = args[++i].intern();
String source = (((target == "1.1") || (target == "1.2")) //$NON-NLS-1$ //$NON-NLS-2$
? "1.3" : target); //$NON-NLS-1$
javacOptionsList.add(optionSource);
javacOptionsList.add(source);
javacOptionsList.add(optionTarget);
javacOptionsList.add(target);
} else {
error(errorNeedParameterText, arg);
}
} else if ((arg == optionKeep) || (arg == optionKeepGenerated)) {
keepSources = true;
} else if ((arg == optionAlways) || (arg == optionAlwaysGenerate)) {
always = true;
} else if (arg == optionFactory) {
factory = true;
} else if (arg == optionNoValueMethods) {
valueMethods = false;
} else if (arg == optionNoLocalStubs) {
localStubs = false;
} else if (arg == optionPOA) {
poa = true;
} else if ((arg == optionDebug)
|| arg.startsWith(optionDebugDetails)) {
javacOptionsList.add(arg);
debug = true;
} else if (arg == optionNoWarnings) {
warnings = false;
} else if (arg == optionNoWrite) {
writeClasses = false;
} else if (arg == optionVerbose) {
javacOptionsList.add(arg);
verbose = true;
} else if (arg == optionDepend) {
depend = true;
} else if ((arg == optionIdlModule) || (arg == optionIdlFile)) {
if (i < (numArgs - 2)) {
// @ToDo: implement for IDL support.
i += 2;
} else {
error(errorNeedTwoParametersText, arg);
}
} else if ((arg == optionClassPath) || (arg == optionCP)
|| (arg == optionBootClassPath) || (arg == optionExtDirs)
|| (arg == optionDestinationDir)) {
if (i < (numArgs - 1)) {
// If parameter is available,
// add option to javacOptionsList.
String option = ((arg == optionCP) ? optionClassPath : arg);
javacOptionsList.add(option);
String param = args[++i];
javacOptionsList.add(param);
if (arg == optionDestinationDir) {
destinationDir = param;
} else {
addWarning(option.substring(1), warningClassPathText);
}
} else {
error(errorNeedParameterText, arg);
}
} else if (arg.startsWith(optionJava) || arg.startsWith(optionX)) {
if (arg.length() > 2) {
// If parameter is available,
// add option to javacOptionsList.
javacOptionsList.add(arg);
} else {
error(errorNeedJVMParameterText, arg);
}
} else if (arg.startsWith(optionPrefix)) {
// What starts with dash is probably the non-specified option.
error(errorUnknownOptionText, arg);
} else {
// First arg that is not an option.
if (classes != null) {
// If classes are specified explicitly,
// then this is just an incorrect option.
error(errorUnknownOptionText, arg);
} else {
// If classes are not specified explicitly,
// extract them from args.
int numClasses = (numArgs - i);
classes = new Object[numClasses];
System.arraycopy(args, i, classes, 0, numClasses);
if (i == 0) {
// Mark that no options were really specified.
optionsPresent = false;
}
}
break;
}
}
// Print warnings.
if (warnings) {
for (Iterator i = warningTags.values().iterator(); i.hasNext(); ) {
// rmi.console.1A=WARNING: {0}
System.err.println(Messages.getString("rmi.console.1A", i.next())); //$NON-NLS-1$
}
}
// Check options compatibility.
if (always && (version != VERSION_IDL) && (version != VERSION_IIOP)) {
error(errorUnusableExceptIDL_IIOP, optionAlways);
}
if (factory && (version != VERSION_IDL)) {
error(errorUnusableExceptIDL, optionFactory);
}
if (!valueMethods && (version != VERSION_IDL)) {
error(errorUnusableExceptIDL, optionNoValueMethods);
}
if (!localStubs && (version != VERSION_IIOP)) {
error(errorUnusableExceptIIOP, optionNoLocalStubs);
}
if (poa && (version != VERSION_IIOP)) {
error(errorUnusableExceptIIOP, optionPOA);
}
if (version == VERSION_NOT_SET) {
version = VERSION_V12;
}
// Save configuration.
this.classes = ((classes != null) ? classes : new Object[0]);
this.numClasses = this.classes.length;
this.version = version;
this.keepSources = keepSources;
this.always = always;
this.factory = factory;
this.valueMethods = valueMethods;
this.localStubs = localStubs;
this.poa = poa;
this.debug = debug;
this.warnings = warnings;
this.writeClasses = writeClasses;
this.verbose = verbose;
this.depend = depend;
this.optionsPresent = optionsPresent;
this.destinationDir = destinationDir;
// "Export" Javac options.
javacOptions = (String[]) javacOptionsList.toArray(
new String[javacOptionsList.size()]);
}