package com.artemis;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.util.CheckClassAdapter;

public final class ClassUtil implements Opcodes
{
	private ClassUtil() {}

	public static void injectMethodStub(ClassWriter cw, String methodName) {
		MethodVisitor mv = cw.visitMethod(ACC_PROTECTED, methodName, "()V", null, null);
		mv.visitCode();
		mv.visitInsn(RETURN);
		mv.visitEnd();
	}
	
	public static void injectAnnotation(ClassWriter cw, String desc) {
		AnnotationVisitor av = cw.visitAnnotation(desc, true);
		av.visitEnd();
	}
	
	public static void writeClass(ClassWriter writer, String file) {
		FileOutputStream fos = null;
		try	{
			fos = new FileOutputStream(file);
			fos.write(writer.toByteArray());
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (fos != null) try {
				fos.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public static String verifyClass(ClassWriter writer) {
		StringWriter sw = new StringWriter();
		PrintWriter printer = new PrintWriter(sw);

		CheckClassAdapter.verify(new ClassReader(writer.toByteArray()), false, printer);

		return sw.toString();
	}
	
	public static List<File> find(Set<File> roots) {
		List<File> klazzes = new ArrayList<>();

		for (File root : roots) {
			if (!root.isDirectory())
				throw new IllegalAccessError(root + " must be a folder.");

			addFiles(klazzes, root);
		}

		return klazzes;
	}
	
	private static void addFiles(List<File> files, File folder) {
		for (File f : folder.listFiles()) {
			if (f.isFile() && f.getName().endsWith(".class"))
				files.add(f);
			else if (f.isDirectory())
				addFiles(files, f);
		}
	}
}

@@ -178,24 +178,54 @@
 .ArrayList;%0A
+import java.util.Collections;%0A
 import java.
@@ -1547,24 +1547,116 @@
 String();%0A%09%7D
+%0A%0A%09public static List%3CFile%3E find(File root) %7B%0A%09%09return find(Collections.singleton(root));%0A%09%7D
 %0A%09%0A%09public s

Fix build error