package javassist.test; import javassist.ClassPool; import javassist.CtClass; public class ExtendSample { public static void main(String[] args) throws Exception{ ClassPool pool = ClassPool.getDefault(); CtClass cc = pool.makeClass("dynamic.clazz.Sample"); cc.setSuperclass(pool.get("java.lang.String")); Class<?> clazz = cc.toClass(); Object obj = clazz.newInstance(); } } Exception in thread "main"