T6395974.java revision 2687:56f8be952a5c
1139826Simp/*
2191672Sbms * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
353541Sshin * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
453541Sshin *
553541Sshin * This code is free software; you can redistribute it and/or modify it
653541Sshin * under the terms of the GNU General Public License version 2 only, as
753541Sshin * published by the Free Software Foundation.
853541Sshin *
953541Sshin * This code is distributed in the hope that it will be useful, but WITHOUT
1053541Sshin * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1153541Sshin * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12191672Sbms * version 2 for more details (a copy is included in the LICENSE file that
13191672Sbms * accompanied this code).
14191672Sbms *
1553541Sshin * You should have received a copy of the GNU General Public License version
16191672Sbms * 2 along with this work; if not, write to the Free Software Foundation,
1753541Sshin * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1853541Sshin *
19191672Sbms * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2053541Sshin * or visit www.oracle.com if you need additional information or have any
2153541Sshin * questions.
2253541Sshin */
2353541Sshin
2453541Sshin/*
2553541Sshin * @test
2653541Sshin * @bug 6395974
27174510Sobrien * @summary files are parsed even after failure to find annotation processor is reported
28174510Sobrien */
2953541Sshin
3053541Sshinimport java.io.*;
31139826Simpimport java.util.*;
3253541Sshin
3353541Sshinimport javax.tools.*;
3453541Sshin
3553541Sshinimport com.sun.source.util.*;
3653541Sshinimport com.sun.source.util.TaskEvent.Kind;
3753541Sshinimport com.sun.tools.javac.api.*;
3853541Sshin
3953541Sshin
4053541Sshinpublic class T6395974 {
4153541Sshin    public static void main(String... args) throws Throwable {
4253541Sshin        String self = T6395974.class.getName();
4353541Sshin
4453541Sshin        String testSrc = System.getProperty("test.src");
4553541Sshin
4653541Sshin        JavacTool tool = JavacTool.create();
4753541Sshin        try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
4853541Sshin            Iterable<?extends JavaFileObject> f =
4953541Sshin                fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self + ".java")));
5053541Sshin
5153541Sshin            PrintWriter out = new PrintWriter(System.err, true);
5253541Sshin
5353541Sshin            JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out,
5453541Sshin                                                              fm,
5553541Sshin                                                              null,
5653541Sshin                                                              Arrays.asList("-processor",
5753541Sshin                                                                            "Foo.java"),
5853541Sshin                                                              null,
5953541Sshin                                                              f);
6053541Sshin
6153541Sshin            MyTaskListener tl = new MyTaskListener();
6253541Sshin            task.setTaskListener(tl);
6353541Sshin
6453541Sshin            task.call();
6553541Sshin        }
66174510Sobrien    }
67174510Sobrien
68174510Sobrien    static class MyTaskListener implements TaskListener {
6962587Sitojun        public void started(TaskEvent e) {
7062587Sitojun            if (e.getKind() != Kind.COMPILATION) {
7155009Sshin                throw new AssertionError("Unexpected TaskListener event: " + e);
7253541Sshin            }
7353541Sshin        }
7453541Sshin        public void finished(TaskEvent e) {
7553541Sshin        }
7653541Sshin
77191672Sbms        TaskEvent event;
78151539Ssuz    }
79151539Ssuz}
80126603Sume