public static JavacOptions parse(OptionChecker primary, OptionChecker secondary, String... arguments) { List<String> recognizedOptions = new ArrayList<String>(); List<String> unrecognizedOptions = new ArrayList<String>(); List<String> classNames = new ArrayList<String>(); List<File> files = new ArrayList<File>(); for (int i = 0; i < arguments.length; i++) { String argument = arguments[i]; int optionCount = primary.isSupportedOption(argument); if (optionCount < 0) { optionCount = secondary.isSupportedOption(argument); } if (optionCount < 0) { File file = new File(argument); if (file.exists()) files.add(file); else if (SourceVersion.isName(argument)) classNames.add(argument); else unrecognizedOptions.add(argument); } else { for (int j = 0; j < optionCount + 1; j++) { int index = i + j; if (index == arguments.length) throw new IllegalArgumentException(argument); recognizedOptions.add(arguments[index]); } i += optionCount; } } return new JavacOptions(recognizedOptions, classNames, files, unrecognizedOptions); }