Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Cannot Reproduce
-
1.5
-
None
-
SUN JRE 1.5.0.13
Windows XP SP2
Description
First, create the following annotation in Java:
package problem; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Test { String name() default ""; }
Second, create the following groovy script:
import problem.Test; class Script { @Test(name="problems") void teste() { } }
Finally, try to find the annotated method in Java:
GroovyClassLoader loader = new GroovyClassLoader(TesteMain.class.getClassLoader()); Class clazz = loader.parseClass(new File("c:\\Script.groovy")); System.out.println(clazz.getCanonicalName()); for (Method m : clazz.getMethods()) { for (Annotation a : m.getDeclaredAnnotations()) System.out.println(a.toString()); }
The output will only show the class name, not the annotated method. Using a java class instead of a Groovy script, everything works fine.