Hello, First of all I must say that I have little experience with javassist (I begun using it last week).
What I need to to is to process a couple of classes searching for any method containing a specific custom annotation (say pacote.Anotacao). In the class i declare the method like this (in the Content class): | @pacote.Anotacao | public String getDescription() | { | return description; | } | With javassist I do the following: | | CtClass cc = cp.get(className); | CtMethod[] methods = cc.getDeclaredMethods(); | for (int i = 0; i < methods.length; i++) | { | CtMethod m = methods; | Object[] annotations = m.getAnnotations(); | } | The problem is that m.getAnnotations() rises a java.lang.ClassNotFoundException when I'm processing the annotated method (see above). I've inspected javassist's code but I failed to spot what was wrong (I only noticed that the error rises from a Class.forName(...,...,...) as expected given the thrown exception. The pojnt is that this very same class (pacote.Anotacao) is processed in the same way the class Content is and it loads sucessfully. Note: I'm lauching the javassist's code from an Ant task, fact that I think its irrelevant for this case. Below I show you the stack trace hopping that it helps you helping me :) | [mytask] java.lang.ClassNotFoundException: pacote.Anotacao | [mytask] at java.net.URLClassLoader$1.run(URLClassLoader.java:200) | [mytask] at java.security.AccessController.doPrivileged(Native Method) | [mytask] at java.net.URLClassLoader.findClass(URLClassLoader.java:188) | [mytask] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) | [mytask] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) | [mytask] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) | [mytask] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) | [mytask] at java.lang.Class.forName0(Native Method) | [mytask] at java.lang.Class.forName(Class.java:242) | [mytask] at javassist.bytecode.annotation.MemberValue.loadClass(MemberValue.java:51) | [mytask] at javassist.bytecode.annotation.Annotation.toAnnotationType(Annotation.java:281) | [mytask] at javassist.CtClassType.toAnnotationType(CtClassType.java:404) | [mytask] at javassist.CtBehavior.getAnnotations(CtBehavior.java:112) | [mytask] at injector.Inject.inject(Inject.java:79) | [mytask] at antTask.InjectAccessControl.execute(InjectAccessControl.java:56) | [mytask] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) | [mytask] at org.apache.tools.ant.Task.perform(Task.java:364) | [mytask] at org.apache.tools.ant.Target.execute(Target.java:341) | [mytask] at org.apache.tools.ant.Target.performTasks(Target.java:369) | [mytask] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) | [mytask] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) | [mytask] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) | [mytask] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) | [mytask] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) | [mytask] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) | [mytask] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3908930#3908930 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3908930 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user