@Nullable
  public static File getClassFile(Class<?> clazz) {
    CodeSource source = clazz.getProtectionDomain().getCodeSource();
    if (source == null) {
      return null;
    }
    File dir = new File(source.getLocation().getPath());
    if (!dir.isDirectory()) return null; // class file might be contained in Jar
    File clazzFile = new File(dir, clazz.getName().replace('.', File.separatorChar) + ".class");
    return clazzFile.isFile() ? clazzFile : null;
  }
Returns the class file for the given class (which has been verified to exist in the returned location),
or null if the class file could not be found (e.g. because it is contained in a Jar).
spock-core/src/main/java/org/spockframework/util/ReflectionUtil.java