public boolean isRunnableSpec(File file) throws IOException {
    if (!(file.getName().endsWith(".class") && file.isFile()))
      return false;

    try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) {
      SpecClassFileVisitor visitor = new SpecClassFileVisitor();
      AsmClassReader reader = new AsmClassReader(stream);
      reader.accept(visitor);
      return visitor.isRunnableSpec();
    }
  }
Finds all class files below a base directory that contain a runnable spec.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/buildsupport/SpecClassFileFinder.java