ClassPool classPool = ClassPool.getDefault();
classPool.appendSystemPath();
CtClass clazz = classPool.makeClass("Test");
clazz.addMethod(CtNewMethod.make("public void test() {" + s + "}", clazz));
Class<?> testClass = clazz.toClass();
Method testMethod = testClass.getDeclaredMethod("test");
testMethod.invoke(testClass.newInstance());