N
N
nuclear_kote2021-07-13 19:27:16
Java
nuclear_kote, 2021-07-13 19:27:16

Why can't it find the class?

In general, I want to generate a derived class using javassist

ClassPool pool = ClassPool.getDefault();
        pool.appendClassPath(new LoaderClassPath(new UrlClassLoader( .... )));

        CtClass cc = pool.makeClass("com.example.AppInfoServiceImpl", pool.getCtClass("com.example.AppInfoProto$AppInfoService"));
        //..... generate methods
        cc.toClass();


as a result on cc.toClass(); throws java.lang.NoClassDefFoundError. wherein
new UrlClassLoader( .... ).loadClass("com.example.AppInfoProto$AppInfoService")

works fine

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question