Skip to content

[Regression 0.10] MethodAnnotationsScanner no longer find annotated method #351

@ncoquelet

Description

@ncoquelet

Hi
After updated to 0.10 or 0.10.1, Reflections library doesn't works correctly with .getMethodsAnnotatedWith() deprecated method.
Works well with the version 0.9.11

Bellow the code to reproduce it

Thanks a lot for all your works
Cheers

package my.test;

import java.lang.reflect.Method;

import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;

public class FailedReflection10OnAnnotatedMethod {

    public static void main(String[] args) {
        Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("my.test")).setScanners(new MethodAnnotationsScanner()));
        for (Method method : reflections.getMethodsAnnotatedWith(AnAnnotation.class)) {
            System.out.println("found " + method.getName());
        }
    }
}
package my.test;

public class ClassWithAnnotatedMethod {

    @AnAnnotation
    public void annotatedMethod() {
    }
}
package my.test;

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 AnAnnotation {
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions