Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta annotations on methoods are not resolved #269

Open
godart opened this issue Oct 9, 2019 · 1 comment
Open

Meta annotations on methoods are not resolved #269

godart opened this issue Oct 9, 2019 · 1 comment

Comments

@godart
Copy link

godart commented Oct 9, 2019

getMethodsAnnotatedWith() does not return methods with meta-annotations like getTypesAnnotatedWith

Example:

@Target({METHOD, ANNOTATION_TYPE})
@Retention(RUNTIME)
@interface MetaMethod { }

@MetaMethod
@Target(METHOD)
@Retention(RUNTIME)
@interface AM {}

@MetaMethod
@Target(METHOD)
@Retention(RUNTIME)
@interface BM {}

class A1 {
    @AM public void inA1() {}
}
class B1 {
    @BM public void inB1() {}
}
class A2 {
    @AM public void inA2() {}
}

public class Annotations {

    public static void main(String[] args) {
        Reflections reflections = new Reflections(
                new ConfigurationBuilder()
                        .forPackages("org.jsondoc.springmvc.scanner")
                        .addScanners(new MethodAnnotationsScanner()));
        System.out.println("MetaMethods:");
        for (Method type: reflections.getMethodsAnnotatedWith(MetaMethod.class)) {
            System.out.println(type.getName());
        }
        System.out.println("AnnotatedMethdos");
        for (Method type: reflections.getMethodsAnnotatedWith(AM.class)) {
            System.out.println(type.getName());
        }
    }
}

prints

MetaMethods:
AnnotatedMethdos
inA2
inA1

expected:

MetaMethods:
inA1
inA2
inB1
AnnotatedMethdos
inA2
inA1
@godart
Copy link
Author

godart commented Oct 9, 2019

#208 describes a similar inconsistency for type annotations.

ziqin pushed a commit to ziqin/reflections that referenced this issue May 8, 2020
ziqin pushed a commit to ziqin/reflections that referenced this issue May 31, 2020
@ziqin ziqin mentioned this issue May 31, 2020
maxmousee added a commit to maxmousee/reflections that referenced this issue May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant