docs: public String[] processOptions(String args[])
      {
          targetPackage = "";        // default to no package
          compilerEnv.setGenerateDebugInfo(false);   // default to no symbols
          for (int i=0; i < args.length; i++) {
              String arg = args[i];
              if (!arg.startsWith("-")) {
                  int tail = args.length - i;
                  if (targetName != null && tail > 1) {
                      addError("msg.multiple.js.to.file", targetName);
                      return null;
                  }
                  String[] result = new String[tail];
                  for (int j = 0; j != tail; ++j) {
                      result[j] = args[i + j];
                  }
                  return result;
              }
              if (arg.equals("-help") || arg.equals("-h")
                  || arg.equals("--help"))
              {
                  printHelp = true;
                  return null;
              }
  
              try {
                  if (arg.equals("-version") && ++i < args.length) {
                      int version = Integer.parseInt(args[i]);
                      compilerEnv.setLanguageVersion(version);
                      continue;
                  }
                  if ((arg.equals("-opt") || arg.equals("-O"))  &&
                      ++i < args.length)
                  {
                      int optLevel = Integer.parseInt(args[i]);
                      compilerEnv.setOptimizationLevel(optLevel);
                      continue;
                  }
              }
              catch (NumberFormatException e) {
                  badUsage(args[i]);
                  return null;
              }
              if (arg.equals("-nosource")) {
                  compilerEnv.setGeneratingSource(false);
                  continue;
              }
              if (arg.equals("-debug") || arg.equals("-g")) {
                  compilerEnv.setGenerateDebugInfo(true);
                  continue;
              }
              if (arg.equals("-main-method-class") && ++i < args.length) {
                  compiler.setMainMethodClass(args[i]);
                  continue;
              }
              if (arg.equals("-encoding") && ++i < args.length) {
                  characterEncoding = args[i];
                  continue;
              }
              if (arg.equals("-o") && ++i < args.length) {
                  String name = args[i];
                  int end = name.length();
                  if (end == 0
                      || !Character.isJavaIdentifierStart(name.charAt(0)))
                  {
                      addError("msg.invalid.classfile.name", name);
                      continue;
                  }
                  for (int j = 1; j < end; j++) {
                      char c = name.charAt(j);
                      if (!Character.isJavaIdentifierPart(c)) {
                          if (c == '.') {
                              // check if it is the dot in .class
                              if (j == end - 6 && name.endsWith(".class")) {
                                  name = name.substring(0, j);
                                  break;
                              }
                          }
                          addError("msg.invalid.classfile.name", name);
                          break;
                      }
                  }
                  targetName = name;
                  continue;
              }
              if (arg.equals("-observe-instruction-count")) {
                  compilerEnv.setGenerateObserverCount(true);
              }
              if (arg.equals("-package") && ++i < args.length) {
                  String pkg = args[i];
                  int end = pkg.length();
                  for (int j = 0; j != end; ++j) {
                      char c = pkg.charAt(j);
                      if (Character.isJavaIdentifierStart(c)) {
                          for (++j; j != end; ++j) {
                              c = pkg.charAt(j);
                              if (!Character.isJavaIdentifierPart(c)) {
                                  break;
                              }
                          }
                          if (j == end) {
                              break;
                          }
                          if (c == '.' && j != end - 1) {
                              continue;
                          }
                      }
                      addError("msg.package.name", targetPackage);
                      return null;
                  }
                  targetPackage = pkg;
                  continue;
              }
              if (arg.equals("-extends") && ++i < args.length) {
                  String targetExtends = args[i];
                  Class<?> superClass;
                  try {
                      superClass = Class.forName(targetExtends);
                  } catch (ClassNotFoundException e) {
                      throw new Error(e.toString()); // TODO: better error
                  }
                  compiler.setTargetExtends(superClass);
                  continue;
              }
              if (arg.equals("-implements") && ++i < args.length) {
                  // TODO: allow for multiple comma-separated interfaces.
                  String targetImplements = args[i];
                  StringTokenizer st = new StringTokenizer(targetImplements,
                                                           ",");
                  List<Class<?>> list = new ArrayList<Class<?>>();
                  while (st.hasMoreTokens()) {
                      String className = st.nextToken();
                      try {
                          list.add(Class.forName(className));
                      } catch (ClassNotFoundException e) {
                          throw new Error(e.toString()); // TODO: better error
                      }
                  }
                  Class<?>[] implementsClasses = list.toArray(new Class<?>[list.size()]);
                  compiler.setTargetImplements(implementsClasses);
                  continue;
              }
              if (arg.equals("-d") && ++i < args.length) {
                  destinationDir = args[i];
                  continue;
              }
              badUsage(arg);
              return null;
          }
          // no file name
          p(ToolErrorReporter.getMessage("msg.no.file"));
          return null;
      }