darcy@494: /* ohair@554: * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. darcy@494: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. darcy@494: * darcy@494: * This code is free software; you can redistribute it and/or modify it darcy@494: * under the terms of the GNU General Public License version 2 only, as darcy@494: * published by the Free Software Foundation. darcy@494: * darcy@494: * This code is distributed in the hope that it will be useful, but WITHOUT darcy@494: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or darcy@494: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License darcy@494: * version 2 for more details (a copy is included in the LICENSE file that darcy@494: * accompanied this code). darcy@494: * darcy@494: * You should have received a copy of the GNU General Public License version darcy@494: * 2 along with this work; if not, write to the Free Software Foundation, darcy@494: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. darcy@494: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. darcy@494: */ darcy@494: darcy@494: /* darcy@494: * @test darcy@494: * @bug 6634138 darcy@494: * @author Joseph D. Darcy darcy@494: * @summary Verify source files output after processing is over are compiled darcy@494: * @compile T6634138.java darcy@494: * @compile -processor T6634138 Dummy.java darcy@494: * @run main ExerciseDependency darcy@494: */ darcy@494: darcy@494: import java.lang.annotation.Annotation; darcy@494: import java.io.*; darcy@494: import java.util.Collections; darcy@494: import java.util.Set; darcy@494: import java.util.HashSet; darcy@494: import java.util.List; darcy@494: import java.util.ArrayList; darcy@494: import java.util.Arrays; darcy@494: import javax.annotation.processing.*; darcy@494: import javax.lang.model.SourceVersion; darcy@494: import javax.lang.model.element.*; darcy@494: import javax.lang.model.util.*; darcy@494: darcy@494: @SupportedAnnotationTypes("*") darcy@494: public class T6634138 extends AbstractProcessor { darcy@494: private Filer filer; darcy@494: darcy@494: public boolean process(Set annotations, darcy@494: RoundEnvironment roundEnvironment) { darcy@494: // Write out files *after* processing is over. darcy@494: if (roundEnvironment.processingOver()) { darcy@494: System.out.println("Writing out source files."); darcy@494: try { darcy@494: PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.WrittenAfterProcessing").openWriter()); darcy@494: try { darcy@494: pw.println("package foo;"); darcy@494: pw.println("public class WrittenAfterProcessing {"); darcy@494: pw.println(" public WrittenAfterProcessing() {super();}"); darcy@494: pw.println("}"); darcy@494: } finally { darcy@494: pw.close(); darcy@494: } darcy@494: darcy@494: pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter()); darcy@494: try { darcy@494: pw.println("@Deprecated"); darcy@494: pw.println("package foo;"); darcy@494: } finally { darcy@494: pw.close(); darcy@494: } darcy@494: } catch(IOException io) { darcy@494: throw new RuntimeException(io); darcy@494: } darcy@494: } darcy@494: return true; darcy@494: } darcy@494: darcy@494: @Override darcy@494: public SourceVersion getSupportedSourceVersion() { darcy@494: return SourceVersion.latest(); darcy@494: } darcy@494: darcy@494: public void init(ProcessingEnvironment processingEnv) { darcy@494: super.init(processingEnv); darcy@494: filer = processingEnv.getFiler(); darcy@494: } darcy@494: } darcy@494: darcy@494: darcy@494: