ClassPool pool = new ClassPool();
// Inside Maven Surefire, the system classpath is not sufficient to find all
// the necessary files.
pool.appendClassPath(new LoaderClassPath(_extraLoader));
CtClass ctClass = pool.makeClass(SYNTH_COMPONENT_CLASSNAME);
ctClass.setSuperclass(pool.get(BasicComponent.class.getName()));
// Implement method getName()
CtMethod method = CtNewMethod.make(
"public String getName() { return \"" + name + "\"; }",
ctClass);
ctClass.addMethod(method);
ctClass.addInterface(pool.get(Named.class.getName()));
ctClass.writeFile(_extraClasspath.getAbsolutePath());
}