WErrorGen.java revision 1465:b52a38d4536c
1169691Skan/*
2169691Skan * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3169691Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4169691Skan *
5169691Skan * This code is free software; you can redistribute it and/or modify it
6169691Skan * under the terms of the GNU General Public License version 2 only, as
7169691Skan * published by the Free Software Foundation.
8169691Skan *
9169691Skan * This code is distributed in the hope that it will be useful, but WITHOUT
10169691Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11169691Skan * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12169691Skan * version 2 for more details (a copy is included in the LICENSE file that
13169691Skan * accompanied this code).
14169691Skan *
15169691Skan * You should have received a copy of the GNU General Public License version
16169691Skan * 2 along with this work; if not, write to the Free Software Foundation,
17169691Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18169691Skan *
19169691Skan * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20169691Skan * or visit www.oracle.com if you need additional information or have any
21169691Skan * questions.
22169691Skan */
23169691Skan
24169691Skan/*
25169691Skan * @test 6403456
26169691Skan * @summary -Werror should work with annotation processing
27169691Skan * @library /tools/javac/lib
28169691Skan * @build   JavacTestingAbstractProcessor
29169691Skan * @compile WErrorGen.java
30169691Skan * @compile -proc:only -processor WErrorGen WErrorGen.java
31169691Skan * @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java
32169691Skan */
33169691Skan
34169691Skanimport java.io.*;
35169691Skanimport java.util.*;
36169691Skanimport javax.annotation.processing.*;
37169691Skanimport javax.lang.model.*;
38169691Skanimport javax.lang.model.element.*;
39169691Skanimport javax.tools.*;
40169691Skan
41169691Skanpublic class WErrorGen extends JavacTestingAbstractProcessor {
42169691Skan    @Override
43169691Skan    public boolean process(Set<? extends TypeElement> annotations,
44169691Skan                           RoundEnvironment roundEnv) {
45169691Skan        if (++round == 1) {
46169691Skan            try {
47169691Skan                JavaFileObject fo = filer.createSourceFile("Gen");
48169691Skan                Writer out = fo.openWriter();
49169691Skan                out.write("import java.util.*; class Gen { List l; }");
50169691Skan                out.close();
51169691Skan            } catch (IOException e) {
52169691Skan            }
53169691Skan        }
54169691Skan        return true;
55169691Skan    }
56169691Skan
57169691Skan    int round = 0;
58169691Skan}
59169691Skan