import java.lang.annotation.*; import java.util.*; @Foo(0) @FooContainer(value={@Foo(1),@Foo(2)}) class A {} @Retention(RetentionPolicy.RUNTIME) @interface Foo { int value(); } @Retention(RetentionPolicy.RUNTIME) @interface FooContainer { Foo[] value(); } public class T { public static void main(String[] args) { Annotation[] as = A.class.getAnnotations(); String res = Arrays.asList(as).toString(); String expected = "[@FooContainer(value=[@Foo(value=1), @Foo(value=2)]), @Foo(value=0)]"; if (!res.equals(expected)) { System.out.println("Got: " + res); System.out.println("Expecting: " + expected); throw new RuntimeException("Woha"); } } }