@Test public void staticallyKnownAnnotation() throws Exception { TestUtils.makeSource(src, "impl.C", "import " + Marker.class.getName().replace('$', '.') + ";", "@Marker(stuff=\"hello\")", "public class C {}"); TestUtils.runApt(src, null, clz, new File[] { new File(URI.create(Marker.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm())) }, null); int cnt = 0; for (IndexItem<Marker,Object> item : Index.load(Marker.class, Object.class, loader)) { cnt++; assertEquals("impl.C", ((Class) item.element()).getName()); assertEquals("impl.C", item.instance().getClass().getName()); Marker proxy = item.annotation(); assertEquals(Marker.class, proxy.annotationType()); assertEquals("hello", proxy.stuff()); Marker real1 = Marked1.class.getAnnotation(Marker.class), real2 = Marked2.class.getAnnotation(Marker.class); assertEquals(real1, proxy); assertEquals(proxy, real1); assertEquals(real1.hashCode(), proxy.hashCode()); assertFalse(real2.equals(proxy)); assertFalse(proxy.equals(real2)); } assertEquals(1, cnt); }
public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws IllegalArgumentException { return load(annotation, instanceType, Thread.currentThread().getContextClassLoader()); }
Index implements Iterable<IndexItem<A,I>> { public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws IllegalArgumentException { return load(annotation, instanceType, Thread.currentThread().getContextClassLoader()); } }
Index implements Iterable<IndexItem<A,I>> { public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws IllegalArgumentException { return load(annotation, instanceType, Thread.currentThread().getContextClassLoader()); } private  Index(Class<A> annotation, Class<I> instance, ClassLoader loader); }
Index implements Iterable<IndexItem<A,I>> { public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws IllegalArgumentException { return load(annotation, instanceType, Thread.currentThread().getContextClassLoader()); } private  Index(Class<A> annotation, Class<I> instance, ClassLoader loader); static Index<A,I> load(Class<A> annotation, Class<I> instanceType); static Index<A,I> load(Class<A> annotation, Class<I> instanceType, ClassLoader loader); Iterator<IndexItem<A,I>> iterator(); }
Index implements Iterable<IndexItem<A,I>> { public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws IllegalArgumentException { return load(annotation, instanceType, Thread.currentThread().getContextClassLoader()); } private  Index(Class<A> annotation, Class<I> instance, ClassLoader loader); static Index<A,I> load(Class<A> annotation, Class<I> instanceType); static Index<A,I> load(Class<A> annotation, Class<I> instanceType, ClassLoader loader); Iterator<IndexItem<A,I>> iterator();  }