WErrorGen.java revision 1465:b52a38d4536c
10SN/A/*
22362SN/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
30SN/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40SN/A *
50SN/A * This code is free software; you can redistribute it and/or modify it
60SN/A * under the terms of the GNU General Public License version 2 only, as
72362SN/A * published by the Free Software Foundation.
80SN/A *
92362SN/A * This code is distributed in the hope that it will be useful, but WITHOUT
100SN/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
110SN/A * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
120SN/A * version 2 for more details (a copy is included in the LICENSE file that
130SN/A * accompanied this code).
140SN/A *
150SN/A * You should have received a copy of the GNU General Public License version
160SN/A * 2 along with this work; if not, write to the Free Software Foundation,
170SN/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
180SN/A *
190SN/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
200SN/A * or visit www.oracle.com if you need additional information or have any
212362SN/A * questions.
222362SN/A */
232362SN/A
240SN/A/*
250SN/A * @test 6403456
260SN/A * @summary -Werror should work with annotation processing
270SN/A * @library /tools/javac/lib
280SN/A * @build   JavacTestingAbstractProcessor
290SN/A * @compile WErrorGen.java
300SN/A * @compile -proc:only -processor WErrorGen WErrorGen.java
310SN/A * @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java
320SN/A */
330SN/A
340SN/Aimport java.io.*;
350SN/Aimport java.util.*;
360SN/Aimport javax.annotation.processing.*;
370SN/Aimport javax.lang.model.*;
380SN/Aimport javax.lang.model.element.*;
390SN/Aimport javax.tools.*;
400SN/A
410SN/Apublic class WErrorGen extends JavacTestingAbstractProcessor {
420SN/A    @Override
430SN/A    public boolean process(Set<? extends TypeElement> annotations,
440SN/A                           RoundEnvironment roundEnv) {
450SN/A        if (++round == 1) {
460SN/A            try {
470SN/A                JavaFileObject fo = filer.createSourceFile("Gen");
480SN/A                Writer out = fo.openWriter();
490SN/A                out.write("import java.util.*; class Gen { List l; }");
500SN/A                out.close();
510SN/A            } catch (IOException e) {
520SN/A            }
530SN/A        }
540SN/A        return true;
55    }
56
57    int round = 0;
58}
59