Hi,
I am using reflections 0.9.9 to have a list of all methods annotated with a given annotation.
I have done this in my projects without problems using Java6 and Java7, but if I use Java8 (jdk8u45) I get duplicate hits in case my annotated methods are implementation of abstract methods.
Here an example.
public abstract class AbstractHandler<T extends BeanInterface> {
abstract protected void myMethod(T bean);
}
public class HandlerImplementation extends AbstractHandler<BeanImplementation> {
@MyAnnotation
protected void myMethod(BeanImplementation bean){
...
}
}
When I scan to find all the methods annotated with MyAnnotation I get two hits:
- HandlerImplementation.myMethod(BeanImplementation)
- HandlerImplementation.myMethod(BeanInterface)
The method in the abstract class is not even annotated.
Here the piece of code where I was able to reproduce this behavior:
AbstractScanner methodScanner = new MethodAnnotationsScanner();
Predicate<String> filter = new FilterBuilder().include(FilterBuilder.prefix(HandlerImplementationName));
ConfigurationBuilder configuration = new ConfigurationBuilder();
configuration.filterInputsBy(filter);
configuration.setUrls(ClasspathHelper.forClassLoader(classLoader));
configuration.setMetadataAdapter(new JavassistAdapter());
configuration.setScanners(methodScanner);
configuration.addClassLoader(classLoader);
Reflections reflections = new Reflections(configuration);
Collection<String> collection = methodScanner.getStore().get(MyAnnotatioName);
Anybody has experienced the same or have any hints?
Thanks!
Davide