1 /*
2 * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
41 import javax.tools.*;
42 import com.sun.tools.javac.api.JavacTool;
43
44 @Wrap
45 @SupportedAnnotationTypes("Wrap")
46 public class T6403466 extends AbstractProcessor {
47
48 static final String testSrcDir = System.getProperty("test.src");
49 static final String testClassDir = System.getProperty("test.classes");
50 static final String self = T6403466.class.getName();
51 static PrintWriter out = new PrintWriter(System.err, true);
52
53 public static void main(String[] args) throws IOException {
54 JavacTool tool = JavacTool.create();
55
56 try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
57 Iterable<? extends JavaFileObject> files =
58 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
59
60 Iterable<String> options = Arrays.asList(
61 "-XaddExports:"
62 + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
63 + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
64 "-processorpath", testClassDir,
65 "-processor", self,
66 "-s", ".",
67 "-d", ".");
68 JavacTask task = tool.getTask(out, fm, null, options, null, files);
69
70 VerifyingTaskListener vtl = new VerifyingTaskListener(new File(testSrcDir, self + ".out"));
71 task.setTaskListener(vtl);
72
73 if (!task.call())
74 throw new AssertionError("compilation failed");
75
76 if (vtl.iter.hasNext() || vtl.errors)
77 throw new AssertionError("comparison against golden file failed.");
78 }
79 }
80
81 public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
82 if (!rEnv.processingOver()) {
83 Filer filer = processingEnv.getFiler();
84 for (TypeElement anno: annos) {
|
1 /*
2 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
41 import javax.tools.*;
42 import com.sun.tools.javac.api.JavacTool;
43
44 @Wrap
45 @SupportedAnnotationTypes("Wrap")
46 public class T6403466 extends AbstractProcessor {
47
48 static final String testSrcDir = System.getProperty("test.src");
49 static final String testClassDir = System.getProperty("test.classes");
50 static final String self = T6403466.class.getName();
51 static PrintWriter out = new PrintWriter(System.err, true);
52
53 public static void main(String[] args) throws IOException {
54 JavacTool tool = JavacTool.create();
55
56 try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
57 Iterable<? extends JavaFileObject> files =
58 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
59
60 Iterable<String> options = Arrays.asList(
61 "--add-exports",
62 "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
63 + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
64 "--processor-path", testClassDir,
65 "-processor", self,
66 "-s", ".",
67 "-d", ".");
68 JavacTask task = tool.getTask(out, fm, null, options, null, files);
69
70 VerifyingTaskListener vtl = new VerifyingTaskListener(new File(testSrcDir, self + ".out"));
71 task.setTaskListener(vtl);
72
73 if (!task.call())
74 throw new AssertionError("compilation failed");
75
76 if (vtl.iter.hasNext() || vtl.errors)
77 throw new AssertionError("comparison against golden file failed.");
78 }
79 }
80
81 public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
82 if (!rEnv.processingOver()) {
83 Filer filer = processingEnv.getFiler();
84 for (TypeElement anno: annos) {
|