/* * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Factory to help test updated discovery policy. */ public class Round3Apf implements AnnotationProcessorFactory { // Process @Round3 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("Round3")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } private static int round = 0; public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new Round3Ap(env, atds.size() == 0); } private static class Round3Ap implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; private final boolean empty; Round3Ap(AnnotationProcessorEnvironment env, boolean empty) { this.env = env; this.empty = empty; } public void process() { Round3Apf.round++; try { if (!empty) env.getFiler().createSourceFile("Dummy4").println("@Round4 class Dummy4{}"); } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } System.out.println("Round3Apf: " + round); } } }