langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 28335 0b37a4232e35
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
28335
0b37a4232e35 8058373: Group 10a: golden files for tests in tools/javac dir
sogoel
parents: 14963
diff changeset
     2
 * @test /nodynamiccopyright/
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 6403459
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Test that generating programs with syntax errors is a fatal condition
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author  Joseph D. Darcy
14963
974d4423c999 8005282: Use @library tag with non-relative path for javac tests
darcy
parents: 6720
diff changeset
     6
 * @library /tools/javac/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28335
diff changeset
     7
 * @modules java.compiler
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 28335
diff changeset
     8
 *          jdk.compiler
6720
f16f91662ad8 6983738: Use a JavacTestingAbstractProcessor
darcy
parents: 5520
diff changeset
     9
 * @build JavacTestingAbstractProcessor
f16f91662ad8 6983738: Use a JavacTestingAbstractProcessor
darcy
parents: 5520
diff changeset
    10
 * @compile TestReturnCode.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * @compile TestFatalityOfParseErrors.java
28335
0b37a4232e35 8058373: Group 10a: golden files for tests in tools/javac dir
sogoel
parents: 14963
diff changeset
    12
 * @compile/fail/ref=TestFatalityOfParseErrors.out -XDrawDiagnostics -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
import javax.annotation.processing.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
import static javax.lang.model.SourceVersion.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
import javax.lang.model.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
import static javax.tools.Diagnostic.Kind.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
import java.io.PrintWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
import java.io.IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * Write out an incomplete source file and observe that the next round
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * is marked as an error.
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 */
6720
f16f91662ad8 6983738: Use a JavacTestingAbstractProcessor
darcy
parents: 5520
diff changeset
    30
public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
    public boolean process(Set<? extends TypeElement> annotations,
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
                           RoundEnvironment roundEnvironment) {
28335
0b37a4232e35 8058373: Group 10a: golden files for tests in tools/javac dir
sogoel
parents: 14963
diff changeset
    34
        try (PrintWriter pw = new PrintWriter(filer.createSourceFile("SyntaxError").openWriter())) {
0b37a4232e35 8058373: Group 10a: golden files for tests in tools/javac dir
sogoel
parents: 14963
diff changeset
    35
            pw.println("class SyntaxError {");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
        } catch (IOException ioException) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
}