Program: 9508
Project: 9508
Buggy source:
/** 
 * This checks that the spec is reasonable and does setup: <ul> <li>calculate and set sandbox testBaseSrcDir as {Sandbox.testBaseDir}/ {Spec.testSrcDirOffset}/<li> <li>get the list of source File to compile as {Sandbox.testBaseSrcDir} / {Spec.getPaths..}</li> <li>get the list of extraClasspath entries to add to default classpath as {Sandbox.testBaseSrcDir} / {Spec.classpath..}</li> <li>get the list of aspectpath entries to use as the aspectpath as {Sandbox. testBaseSrcDir} / {Spec.aspectpath..}</li> </ul> All sources must be readable at this time,  unless spec.badInput is true (for invalid-input tests). If staging, the source files and source roots are copied to a separate staging directory so they can be modified for incremental tests.   Note that (as of this writing) the compiler only handles source roots for incremental tests.
 * @param classesDir the File
 * @see org.aspectj.testing.harness.bridge.AjcTest.IAjcRun#setup(File,File)
 * @throws AbortException containing IOException or IllegalArgumentExceptionif the staging operations fail
 */
public boolean setupAjcRun(Sandbox sandbox,Validator validator){
  if (!validator.nullcheck(spec.getOptionsArray(),"String_Node_Str") || !validator.nullcheck(sandbox,"String_Node_Str") || !validator.nullcheck(spec.compiler,"String_Node_Str")|| !validator.canRead(Globals.F_aspectjrt_jar,"String_Node_Str")|| !validator.canRead(Globals.F_testingclient_jar,"String_Node_Str")) {
    return false;
  }
  this.sandbox=sandbox;
  String rdir=spec.testSrcDirOffset;
  File testBaseSrcDir;
  if ((null == rdir) || (0 == rdir.length())) {
    testBaseSrcDir=sandbox.testBaseDir;
  }
 else {
    testBaseSrcDir=new File(sandbox.testBaseDir,rdir);
    if (!validator.canReadDir(testBaseSrcDir,"String_Node_Str")) {
      return false;
    }
  }
  sandbox.setTestBaseSrcDir(testBaseSrcDir,this);
  final String[] inpathPaths;
  final String[] injarPaths;
  final String[] srcPaths;
{
    final String[] paths=spec.getPathsArray();
    srcPaths=LangUtil.endsWith(paths,CompilerRun.SOURCE_SUFFIXES,true);
    injarPaths=LangUtil.endsWith(paths,CompilerRun.JAR_SUFFIXES,true);
    inpathPaths=LangUtil.selectDirectories(paths,testBaseSrcDir);
    if (!spec.badInput) {
      int found=inpathPaths.length + injarPaths.length + srcPaths.length;
      if (paths.length != found) {
        validator.fail("String_Node_Str" + found + "String_Node_Str"+ paths.length+ "String_Node_Str");
      }
    }
  }
  if (!spec.badInput) {
    if (!validator.canRead(testBaseSrcDir,srcPaths,"String_Node_Str") || !validator.canRead(testBaseSrcDir,injarPaths,"String_Node_Str") || !validator.canRead(testBaseSrcDir,inpathPaths,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.argfiles,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.classpath,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.aspectpath,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.sourceroots,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.extdirs,"String_Node_Str")) {
      return false;
    }
  }
  int numSources=srcPaths.length + injarPaths.length + inpathPaths.length+ spec.argfiles.length+ spec.sourceroots.length;
  if (!spec.badInput && (numSources < 1)) {
    validator.fail("String_Node_Str");
    return false;
  }
  final File[] argFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.argfiles);
  final File[] injarFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,injarPaths);
  final File[] inpathFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,inpathPaths);
  final File[] aspectFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.aspectpath);
  final File[] extdirFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.extdirs);
  final File[] classFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.classpath);
  final File[] xlintFiles=(null == spec.xlintfile ? new File[0] : FileUtil.getBaseDirFiles(testBaseSrcDir,new String[]{spec.xlintfile}));
  if (!spec.badInput) {
    if (!validator.canRead(argFiles,"String_Node_Str") || !validator.canRead(injarFiles,"String_Node_Str") || !validator.canRead(inpathFiles,"String_Node_Str")|| !validator.canRead(aspectFiles,"String_Node_Str")|| !validator.canRead(classFiles,"String_Node_Str")|| !validator.canRead(xlintFiles,"String_Node_Str")) {
      return false;
    }
  }
  final File[] srcFiles;
  File[] sourcerootFiles=new File[0];
  if (!spec.isStaging()) {
    srcFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,srcPaths,CompilerRun.SOURCE_SUFFIXES);
    if (!LangUtil.isEmpty(spec.sourceroots)) {
      sourcerootFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.sourceroots,null);
    }
  }
 else {
    if (spec.badInput) {
      validator.info("String_Node_Str");
    }
    try {
      srcFiles=FileUtil.copyFiles(testBaseSrcDir,srcPaths,sandbox.stagingDir);
      if (!LangUtil.isEmpty(spec.sourceroots)) {
        sourcerootFiles=FileUtil.copyFiles(testBaseSrcDir,spec.sourceroots,sandbox.stagingDir);
        FileFilter pickIncFiles=new FileFilter(){
          public boolean accept(          File file){
            if (file.isDirectory()) {
              return true;
            }
            String path=file.getPath();
            if (!FileUtil.hasSourceSuffix(path)) {
              return false;
            }
            int first=path.indexOf("String_Node_Str");
            int last=path.lastIndexOf("String_Node_Str");
            return (first != last);
          }
        }
;
        for (int i=0; i < sourcerootFiles.length; i++) {
          FileUtil.deleteContents(sourcerootFiles[i],pickIncFiles,false);
        }
        if (0 < sourcerootFiles.length) {
          FileUtil.sleepPastFinalModifiedTime(sourcerootFiles);
        }
      }
      File[] files=FileUtil.getBaseDirFiles(sandbox.stagingDir,srcPaths);
      if (0 < files.length) {
        FileUtil.sleepPastFinalModifiedTime(files);
      }
    }
 catch (    IllegalArgumentException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
catch (    IOException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
  }
  if (!spec.badInput && !validator.canRead(srcFiles,"String_Node_Str")) {
    return false;
  }
  arguments.clear();
  if (!LangUtil.isEmpty(xlintFiles)) {
    arguments.add("String_Node_Str");
    String sr=FileUtil.flatten(xlintFiles,null);
    arguments.add(sr);
  }
  if (!LangUtil.isEmpty(extdirFiles)) {
    arguments.add("String_Node_Str");
    String sr=FileUtil.flatten(extdirFiles,null);
    arguments.add(sr);
  }
  if (!LangUtil.isEmpty(sourcerootFiles)) {
    arguments.add("String_Node_Str");
    String sr=FileUtil.flatten(sourcerootFiles,null);
    arguments.add(sr);
  }
  if (!LangUtil.isEmpty(srcFiles)) {
    arguments.addAll(Arrays.asList(FileUtil.getPaths(srcFiles)));
  }
  injars.clear();
  if (!LangUtil.isEmpty(injarFiles)) {
    injars.addAll(Arrays.asList(FileUtil.getPaths(injarFiles)));
  }
  inpaths.clear();
  if (!LangUtil.isEmpty(inpathFiles)) {
    inpaths.addAll(Arrays.asList(FileUtil.getPaths(inpathFiles)));
  }
  if (!LangUtil.isEmpty(argFiles)) {
    String[] ra=FileUtil.getPaths(argFiles);
    for (int j=0; j < ra.length; j++) {
      arguments.add("String_Node_Str" + ra[j]);
    }
    if (!spec.badInput && spec.isStaging) {
      validator.fail("String_Node_Str");
    }
  }
  final boolean checkReadable=!spec.badInput;
  int size=spec.includeClassesDir ? 3 : 2;
  File[] cp=new File[size + classFiles.length];
  System.arraycopy(classFiles,0,cp,0,classFiles.length);
  int index=classFiles.length;
  if (spec.includeClassesDir) {
    cp[index++]=sandbox.classesDir;
  }
  cp[index++]=Globals.F_aspectjrt_jar;
  cp[index++]=Globals.F_testingclient_jar;
  sandbox.setClasspath(cp,checkReadable,this);
  if (0 < aspectFiles.length) {
    sandbox.setAspectpath(aspectFiles,checkReadable,this);
  }
  AbstractRunSpec.Fork fork=spec.getFork();
  String bootclasspath=fork.getJavaBootclasspath();
  if (fork.fork() && (!LangUtil.isEmpty(bootclasspath))) {
    sandbox.setBootclasspath(bootclasspath,this);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * This checks that the spec is reasonable and does setup: <ul> <li>calculate and set sandbox testBaseSrcDir as {Sandbox.testBaseDir}/ {Spec.testSrcDirOffset}/<li> <li>get the list of source File to compile as {Sandbox.testBaseSrcDir} / {Spec.getPaths..}</li> <li>get the list of extraClasspath entries to add to default classpath as {Sandbox.testBaseSrcDir} / {Spec.classpath..}</li> <li>get the list of aspectpath entries to use as the aspectpath as {Sandbox. testBaseSrcDir} / {Spec.aspectpath..}</li> </ul> All sources must be readable at this time,  unless spec.badInput is true (for invalid-input tests). If staging, the source files and source roots are copied to a separate staging directory so they can be modified for incremental tests.   Note that (as of this writing) the compiler only handles source roots for incremental tests.
 * @param classesDir the File
 * @see org.aspectj.testing.harness.bridge.AjcTest.IAjcRun#setup(File,File)
 * @throws AbortException containing IOException or IllegalArgumentExceptionif the staging operations fail
 */
public boolean setupAjcRun(Sandbox sandbox,Validator validator){
  if (!validator.nullcheck(spec.getOptionsArray(),"String_Node_Str") || !validator.nullcheck(sandbox,"String_Node_Str") || !validator.nullcheck(spec.compiler,"String_Node_Str")|| !validator.canRead(Globals.F_aspectjrt_jar,"String_Node_Str")|| !validator.canRead(Globals.F_testingclient_jar,"String_Node_Str")) {
    return false;
  }
  this.sandbox=sandbox;
  String rdir=spec.testSrcDirOffset;
  File testBaseSrcDir;
  if ((null == rdir) || (0 == rdir.length())) {
    testBaseSrcDir=sandbox.testBaseDir;
  }
 else {
    testBaseSrcDir=new File(sandbox.testBaseDir,rdir);
    if (!validator.canReadDir(testBaseSrcDir,"String_Node_Str")) {
      return false;
    }
  }
  sandbox.setTestBaseSrcDir(testBaseSrcDir,this);
  final String[] inpathPaths;
  final String[] injarPaths;
  final String[] srcPaths;
{
    final String[] paths=spec.getPathsArray();
    srcPaths=LangUtil.endsWith(paths,CompilerRun.SOURCE_SUFFIXES,true);
    injarPaths=LangUtil.endsWith(paths,CompilerRun.JAR_SUFFIXES,true);
    inpathPaths=LangUtil.selectDirectories(paths,testBaseSrcDir);
    if (!spec.badInput) {
      int found=inpathPaths.length + injarPaths.length + srcPaths.length;
      if (paths.length != found) {
        validator.fail("String_Node_Str" + found + "String_Node_Str"+ paths.length+ "String_Node_Str");
      }
    }
  }
  if (!spec.badInput) {
    if (!validator.canRead(testBaseSrcDir,srcPaths,"String_Node_Str") || !validator.canRead(testBaseSrcDir,injarPaths,"String_Node_Str") || !validator.canRead(testBaseSrcDir,inpathPaths,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.argfiles,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.classpath,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.aspectpath,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.sourceroots,"String_Node_Str")|| !validator.canRead(testBaseSrcDir,spec.extdirs,"String_Node_Str")) {
      return false;
    }
  }
  int numSources=srcPaths.length + injarPaths.length + inpathPaths.length+ spec.argfiles.length+ spec.sourceroots.length;
  if (!spec.badInput && (numSources < 1)) {
    validator.fail("String_Node_Str");
    return false;
  }
  final File[] argFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.argfiles);
  final File[] injarFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,injarPaths);
  final File[] inpathFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,inpathPaths);
  final File[] aspectFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.aspectpath);
  final File[] extdirFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.extdirs);
  final File[] classFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.classpath);
  final File[] xlintFiles=(null == spec.xlintfile ? new File[0] : FileUtil.getBaseDirFiles(testBaseSrcDir,new String[]{spec.xlintfile}));
  if (!spec.badInput) {
    if (!validator.canRead(argFiles,"String_Node_Str") || !validator.canRead(injarFiles,"String_Node_Str") || !validator.canRead(inpathFiles,"String_Node_Str")|| !validator.canRead(aspectFiles,"String_Node_Str")|| !validator.canRead(classFiles,"String_Node_Str")|| !validator.canRead(xlintFiles,"String_Node_Str")) {
      return false;
    }
  }
  final File[] srcFiles;
  File[] sourcerootFiles=new File[0];
  if (!spec.isStaging()) {
    srcFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,srcPaths,CompilerRun.SOURCE_SUFFIXES);
    if (!LangUtil.isEmpty(spec.sourceroots)) {
      sourcerootFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.sourceroots,null);
    }
  }
 else {
    if (spec.badInput) {
      validator.info("String_Node_Str");
    }
    try {
      srcFiles=FileUtil.copyFiles(testBaseSrcDir,srcPaths,sandbox.stagingDir);
      if (!LangUtil.isEmpty(spec.sourceroots)) {
        sourcerootFiles=FileUtil.copyFiles(testBaseSrcDir,spec.sourceroots,sandbox.stagingDir);
        FileFilter pickIncFiles=new FileFilter(){
          public boolean accept(          File file){
            if (file.isDirectory()) {
              return true;
            }
            String path=file.getPath();
            if (!FileUtil.hasSourceSuffix(path)) {
              return false;
            }
            int first=path.indexOf("String_Node_Str");
            int last=path.lastIndexOf("String_Node_Str");
            return (first != last);
          }
        }
;
        for (int i=0; i < sourcerootFiles.length; i++) {
          FileUtil.deleteContents(sourcerootFiles[i],pickIncFiles,false);
        }
        if (0 < sourcerootFiles.length) {
          FileUtil.sleepPastFinalModifiedTime(sourcerootFiles);
        }
      }
      File[] files=FileUtil.getBaseDirFiles(sandbox.stagingDir,srcPaths);
      if (0 < files.length) {
        FileUtil.sleepPastFinalModifiedTime(files);
      }
    }
 catch (    IllegalArgumentException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
catch (    IOException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
  }
  if (!spec.badInput && !validator.canRead(srcFiles,"String_Node_Str")) {
    return false;
  }
  arguments.clear();
  if (!LangUtil.isEmpty(xlintFiles)) {
    arguments.add("String_Node_Str");
    String sr=FileUtil.flatten(xlintFiles,null);
    arguments.add(sr);
  }
  if (spec.outjar != null) {
    arguments.add("String_Node_Str");
    arguments.add(spec.outjar);
  }
  if (!LangUtil.isEmpty(extdirFiles)) {
    arguments.add("String_Node_Str");
    String sr=FileUtil.flatten(extdirFiles,null);
    arguments.add(sr);
  }
  if (!LangUtil.isEmpty(sourcerootFiles)) {
    arguments.add("String_Node_Str");
    String sr=FileUtil.flatten(sourcerootFiles,null);
    arguments.add(sr);
  }
  if (!LangUtil.isEmpty(srcFiles)) {
    arguments.addAll(Arrays.asList(FileUtil.getPaths(srcFiles)));
  }
  injars.clear();
  if (!LangUtil.isEmpty(injarFiles)) {
    injars.addAll(Arrays.asList(FileUtil.getPaths(injarFiles)));
  }
  inpaths.clear();
  if (!LangUtil.isEmpty(inpathFiles)) {
    inpaths.addAll(Arrays.asList(FileUtil.getPaths(inpathFiles)));
  }
  if (!LangUtil.isEmpty(argFiles)) {
    String[] ra=FileUtil.getPaths(argFiles);
    for (int j=0; j < ra.length; j++) {
      arguments.add("String_Node_Str" + ra[j]);
    }
    if (!spec.badInput && spec.isStaging) {
      validator.fail("String_Node_Str");
    }
  }
  final boolean checkReadable=!spec.badInput;
  int size=spec.includeClassesDir ? 3 : 2;
  File[] cp=new File[size + classFiles.length];
  System.arraycopy(classFiles,0,cp,0,classFiles.length);
  int index=classFiles.length;
  if (spec.includeClassesDir) {
    cp[index++]=sandbox.classesDir;
  }
  cp[index++]=Globals.F_aspectjrt_jar;
  cp[index++]=Globals.F_testingclient_jar;
  sandbox.setClasspath(cp,checkReadable,this);
  if (0 < aspectFiles.length) {
    sandbox.setAspectpath(aspectFiles,checkReadable,this);
  }
  AbstractRunSpec.Fork fork=spec.getFork();
  String bootclasspath=fork.getJavaBootclasspath();
  if (fork.fork() && (!LangUtil.isEmpty(bootclasspath))) {
    sandbox.setBootclasspath(bootclasspath,this);
  }
  return true;
}