Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 Javassist,我如何创建一个与我拥有的类完全相同但名称不同的类。我也想保留所有运行时注释。
像这样对我很好:
javassist.ClassPool.getDefault() .getAndRename("com.example.Foo", "com.example.Bar") .toClass();
ClassPool pool = ClassPool.getDefault(); CtClass cc = pool.get("OriginalName"); cc.setName("NewName"); cc.writeFile();