That's because the JVM had loaded JLabel
before toClass() was called. To avoid this,
maybe you should write your own class
loader to run your whole application.
For details, please take a look at the tutorial.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3843
Well, now I get errors:
javassist.CannotCompileException: by java.lang.LinkageError: duplicate class
definition: javax/swing/JLabel
| at javassist.CtClass.toClass(CtClass.java:900)
| at javassist.CtClass.toClass(CtClass.java:860)
| at AASwing.main(AASwing.java:40)
| Exception
This problem should have been fixed in CVS_HEAD.
Please download the source files from CVS and try again.
At least, I could run the following code without any problem:
| ClassPool pool = ClassPool.getDefault();
| CtClass cc = pool.get("javax.swing.JComponent");
| CtMethod m = cc.getDeclared