Thu, 21 Feb 2013 14:43:51 -0800
8008405: Now that metafactory is in place, add javac lambda serialization tests
Summary: Tests part of original langtools serialization review.
Reviewed-by: mcimadamore
darcy@494 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
darcy@494 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
darcy@494 | 4 | * |
darcy@494 | 5 | * This code is free software; you can redistribute it and/or modify it |
darcy@494 | 6 | * under the terms of the GNU General Public License version 2 only, as |
darcy@494 | 7 | * published by the Free Software Foundation. |
darcy@494 | 8 | * |
darcy@494 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
darcy@494 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
darcy@494 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
darcy@494 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
darcy@494 | 13 | * accompanied this code). |
darcy@494 | 14 | * |
darcy@494 | 15 | * You should have received a copy of the GNU General Public License version |
darcy@494 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
darcy@494 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
darcy@494 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
darcy@494 | 22 | */ |
darcy@494 | 23 | |
darcy@494 | 24 | /* |
darcy@494 | 25 | * @test |
darcy@494 | 26 | * @bug 6634138 |
darcy@494 | 27 | * @author Joseph D. Darcy |
darcy@494 | 28 | * @summary Verify source files output after processing is over are compiled |
darcy@1466 | 29 | * @library /tools/javac/lib |
darcy@699 | 30 | * @build JavacTestingAbstractProcessor |
darcy@494 | 31 | * @compile T6634138.java |
darcy@494 | 32 | * @compile -processor T6634138 Dummy.java |
darcy@494 | 33 | * @run main ExerciseDependency |
darcy@494 | 34 | */ |
darcy@494 | 35 | |
darcy@494 | 36 | import java.lang.annotation.Annotation; |
darcy@494 | 37 | import java.io.*; |
darcy@494 | 38 | import java.util.Collections; |
darcy@494 | 39 | import java.util.Set; |
darcy@494 | 40 | import java.util.HashSet; |
darcy@494 | 41 | import java.util.List; |
darcy@494 | 42 | import java.util.ArrayList; |
darcy@494 | 43 | import java.util.Arrays; |
darcy@494 | 44 | import javax.annotation.processing.*; |
darcy@494 | 45 | import javax.lang.model.SourceVersion; |
darcy@494 | 46 | import javax.lang.model.element.*; |
darcy@494 | 47 | import javax.lang.model.util.*; |
darcy@494 | 48 | |
darcy@699 | 49 | public class T6634138 extends JavacTestingAbstractProcessor { |
darcy@494 | 50 | public boolean process(Set<? extends TypeElement> annotations, |
darcy@494 | 51 | RoundEnvironment roundEnvironment) { |
darcy@494 | 52 | // Write out files *after* processing is over. |
darcy@494 | 53 | if (roundEnvironment.processingOver()) { |
darcy@494 | 54 | System.out.println("Writing out source files."); |
darcy@494 | 55 | try { |
darcy@494 | 56 | PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.WrittenAfterProcessing").openWriter()); |
darcy@494 | 57 | try { |
darcy@494 | 58 | pw.println("package foo;"); |
darcy@494 | 59 | pw.println("public class WrittenAfterProcessing {"); |
darcy@494 | 60 | pw.println(" public WrittenAfterProcessing() {super();}"); |
darcy@494 | 61 | pw.println("}"); |
darcy@494 | 62 | } finally { |
darcy@494 | 63 | pw.close(); |
darcy@494 | 64 | } |
darcy@494 | 65 | |
darcy@494 | 66 | pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter()); |
darcy@494 | 67 | try { |
darcy@494 | 68 | pw.println("@Deprecated"); |
darcy@494 | 69 | pw.println("package foo;"); |
darcy@494 | 70 | } finally { |
darcy@494 | 71 | pw.close(); |
darcy@494 | 72 | } |
darcy@494 | 73 | } catch(IOException io) { |
darcy@494 | 74 | throw new RuntimeException(io); |
darcy@494 | 75 | } |
darcy@494 | 76 | } |
darcy@494 | 77 | return true; |
darcy@494 | 78 | } |
darcy@494 | 79 | } |
darcy@494 | 80 | |
darcy@494 | 81 | |
darcy@494 | 82 |