Skip to content

Instantly share code, notes, and snippets.

@raphw
Last active January 21, 2016 08:47
Show Gist options
  • Save raphw/413fe5ce51fdf2f82849 to your computer and use it in GitHub Desktop.
Save raphw/413fe5ce51fdf2f82849 to your computer and use it in GitHub Desktop.
Incorrect resolution of type annotations on nested parameterized type.
public class Foo {
public static void main(String[] args) throws Exception {
System.out.println(Arrays.asList(Foo.class.getDeclaredField("bar").getAnnotatedType().getAnnotations()));
System.out.println(Arrays.asList(Foo.class.getDeclaredField("qux").getAnnotatedType().getAnnotations()));
}
GenericNested<Void>.@TypeAnnotation Inner bar;
Nested.@TypeAnnotation Inner qux;
static class GenericNested<T> {
class Inner { }
}
static class Nested {
class Inner { }
}
@Retention(RetentionPolicy.RUNTIME)
@Target(Element.TYPE_USE)
@interface TypeAnnotation { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment