Program: 9644
Project: 9644
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. 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[] 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);
  }
  if (!validator.canRead(testBaseSrcDir,srcPaths,"String_Node_Str") || !validator.canRead(testBaseSrcDir,injarPaths,"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")) {
    return false;
  }
  int numSources=srcPaths.length + injarPaths.length + spec.argfiles.length+ spec.sourceroots.length;
  if (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[] aspectFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.aspectpath);
  final File[] classFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.classpath);
  if (!validator.canRead(argFiles,"String_Node_Str") || !validator.canRead(injarFiles,"String_Node_Str") || !validator.canRead(aspectFiles,"String_Node_Str")|| !validator.canRead(classFiles,"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 {
    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);
        }
      }
    }
 catch (    IllegalArgumentException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
catch (    IOException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
  }
  if (!validator.canRead(srcFiles,"String_Node_Str")) {
    return false;
  }
  arguments.clear();
  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)));
  }
  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.isStaging) {
      validator.info("String_Node_Str");
    }
  }
  final boolean checkReadable=true;
  File[] cp=new File[3 + classFiles.length];
  System.arraycopy(classFiles,0,cp,0,classFiles.length);
  int index=classFiles.length;
  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);
  }
  if (!LangUtil.isEmpty(JavaRun.BOOTCLASSPATH)) {
    sandbox.setBootclasspath(JavaRun.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. 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[] 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);
  }
  if (!validator.canRead(testBaseSrcDir,srcPaths,"String_Node_Str") || !validator.canRead(testBaseSrcDir,injarPaths,"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")) {
    return false;
  }
  int numSources=srcPaths.length + injarPaths.length + spec.argfiles.length+ spec.sourceroots.length;
  if (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[] aspectFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.aspectpath);
  final File[] classFiles=FileUtil.getBaseDirFiles(testBaseSrcDir,spec.classpath);
  if (!validator.canRead(argFiles,"String_Node_Str") || !validator.canRead(injarFiles,"String_Node_Str") || !validator.canRead(aspectFiles,"String_Node_Str")|| !validator.canRead(classFiles,"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 {
    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);
        }
      }
    }
 catch (    IllegalArgumentException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
catch (    IOException e) {
      validator.fail("String_Node_Str",e);
      return false;
    }
  }
  if (!validator.canRead(srcFiles,"String_Node_Str")) {
    return false;
  }
  arguments.clear();
  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)));
  }
  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.isStaging) {
      validator.info("String_Node_Str");
    }
  }
  final boolean checkReadable=true;
  File[] cp=new File[2 + classFiles.length];
  System.arraycopy(classFiles,0,cp,0,classFiles.length);
  int index=classFiles.length;
  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);
  }
  if (!LangUtil.isEmpty(JavaRun.BOOTCLASSPATH)) {
    sandbox.setBootclasspath(JavaRun.BOOTCLASSPATH,this);
  }
  return true;
}