@Override
  @SuppressWarnings("unchecked")
  protected void setPaths(
      ArrayList bootclasspaths,
      String sourcepathClasspathArg,
      ArrayList sourcepathClasspaths,
      ArrayList classpaths,
      ArrayList extdirsClasspaths,
      ArrayList endorsedDirClasspaths,
      String customEncoding) {

    ArrayList<FileSystem.Classpath> fileSystemClasspaths = new ArrayList<FileSystem.Classpath>();
    EclipseFileManager javaFileManager = null;
    StandardJavaFileManager standardJavaFileManager = null;
    if (this.fileManager instanceof EclipseFileManager) {
      javaFileManager = (EclipseFileManager) this.fileManager;
    }
    if (this.fileManager instanceof StandardJavaFileManager) {
      standardJavaFileManager = (StandardJavaFileManager) this.fileManager;
    }

    if (javaFileManager != null) {
      if ((javaFileManager.flags & EclipseFileManager.HAS_ENDORSED_DIRS) == 0
          && (javaFileManager.flags & EclipseFileManager.HAS_BOOTCLASSPATH) != 0) {
        fileSystemClasspaths.addAll(this.handleEndorseddirs(null));
      }
    }
    Iterable<? extends File> location = null;
    if (standardJavaFileManager != null) {
      location = standardJavaFileManager.getLocation(StandardLocation.PLATFORM_CLASS_PATH);
    }
    if (location != null) {
      for (File file : location) {
        Classpath classpath = FileSystem.getClasspath(file.getAbsolutePath(), null, null);
        if (classpath != null) {
          fileSystemClasspaths.add(classpath);
        }
      }
    }
    if (javaFileManager != null) {
      if ((javaFileManager.flags & EclipseFileManager.HAS_EXT_DIRS) == 0
          && (javaFileManager.flags & EclipseFileManager.HAS_BOOTCLASSPATH) != 0) {
        fileSystemClasspaths.addAll(this.handleExtdirs(null));
      }
    }
    if (standardJavaFileManager != null) {
      location = standardJavaFileManager.getLocation(StandardLocation.SOURCE_PATH);
    } else {
      location = null;
    }
    if (location != null) {
      for (File file : location) {
        Classpath classpath = FileSystem.getClasspath(file.getAbsolutePath(), null, null);
        if (classpath != null) {
          fileSystemClasspaths.add(classpath);
        }
      }
    }
    if (standardJavaFileManager != null) {
      location = standardJavaFileManager.getLocation(StandardLocation.CLASS_PATH);
    } else {
      location = null;
    }
    if (location != null) {
      for (File file : location) {
        Classpath classpath = FileSystem.getClasspath(file.getAbsolutePath(), null, null);
        if (classpath != null) {
          fileSystemClasspaths.add(classpath);
        }
      }
    }
    if (this.checkedClasspaths == null) {
      fileSystemClasspaths.addAll(this.handleBootclasspath(null, null));
      fileSystemClasspaths.addAll(this.handleClasspath(null, null));
    }
    fileSystemClasspaths = FileSystem.ClasspathNormalizer.normalize(fileSystemClasspaths);
    final int size = fileSystemClasspaths.size();
    if (size != 0) {
      this.checkedClasspaths = new FileSystem.Classpath[size];
      int i = 0;
      for (FileSystem.Classpath classpath : fileSystemClasspaths) {
        this.checkedClasspaths[i++] = classpath;
      }
    }
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  protected void addNewEntry(
      ArrayList paths,
      String currentClasspathName,
      ArrayList currentRuleSpecs,
      String customEncoding,
      String destPath,
      boolean isSourceOnly,
      boolean rejectDestinationPathOnJars) {

    int rulesSpecsSize = currentRuleSpecs.size();
    AccessRuleSet accessRuleSet = null;
    if (rulesSpecsSize != 0) {
      AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
      boolean rulesOK = true;
      Iterator i = currentRuleSpecs.iterator();
      int j = 0;
      while (i.hasNext()) {
        String ruleSpec = (String) i.next();
        char key = ruleSpec.charAt(0);
        String pattern = ruleSpec.substring(1);
        if (pattern.length() > 0) {
          switch (key) {
            case '+':
              accessRules[j++] = new AccessRule(pattern.toCharArray(), 0);
              break;
            case '~':
              accessRules[j++] =
                  new AccessRule(pattern.toCharArray(), IProblem.DiscouragedReference);
              break;
            case '-':
              accessRules[j++] = new AccessRule(pattern.toCharArray(), IProblem.ForbiddenReference);
              break;
            case '?':
              accessRules[j++] =
                  new AccessRule(
                      pattern.toCharArray(),
                      IProblem.ForbiddenReference,
                      true /*keep looking for accessible type*/);
              break;
            default:
              rulesOK = false;
          }
        } else {
          rulesOK = false;
        }
      }
      if (rulesOK) {
        accessRuleSet =
            new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
      } else {
        return;
      }
    }
    if (Main.NONE.equals(destPath)) {
      destPath = Main.NONE; // keep == comparison valid
    }
    if (rejectDestinationPathOnJars
        && destPath != null
        && (currentClasspathName.endsWith(".jar")
            || //$NON-NLS-1$
            currentClasspathName.endsWith(".zip"))) { // $NON-NLS-1$
      throw new IllegalArgumentException(
          this.bind(
              "configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$
              currentClasspathName));
    }
    FileSystem.Classpath currentClasspath =
        FileSystem.getClasspath(
            currentClasspathName, customEncoding, isSourceOnly, accessRuleSet, destPath, null);
    if (currentClasspath != null) {
      paths.add(currentClasspath);
    }
  }