langtools/test/tools/javac/positions/TreeEndPosTest.java
author jjg
Wed, 29 Oct 2014 17:25:23 -0700
changeset 27319 030080f03e4f
parent 27121 36889255488f
child 30730 d3ce7619db2c
permissions -rw-r--r--
8062348: langtools tests should close file manager (group 1) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     1
/*
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     4
 *
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     8
 *
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    13
 * accompanied this code).
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    14
 *
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    18
 *
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    21
 * questions.
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    22
 */
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    23
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    24
/*
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    25
 * @test
27121
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
    26
 * @bug 8017216 8019422 8019421 8054956
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    27
 * @summary verify start and end positions
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    28
 * @run main TreeEndPosTest
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    29
 */
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    30
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    31
import java.io.ByteArrayOutputStream;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    32
import java.io.File;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    33
import java.io.IOException;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    34
import java.io.PrintWriter;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    35
import java.net.URI;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    36
import java.util.ArrayList;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    37
import java.util.List;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    38
import javax.tools.Diagnostic;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    39
import javax.tools.DiagnosticCollector;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    40
import javax.tools.JavaCompiler;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    41
import javax.tools.JavaFileManager;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    42
import javax.tools.JavaFileObject;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    43
import javax.tools.SimpleJavaFileObject;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    44
import javax.tools.ToolProvider;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    45
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    46
public class TreeEndPosTest {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    47
    private static JavaFileManager getJavaFileManager(JavaCompiler compiler,
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    48
            DiagnosticCollector dc) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    49
        return compiler.getStandardFileManager(dc, null, null);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    50
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    51
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    52
    static class JavaSource extends SimpleJavaFileObject {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    53
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    54
        final String source;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    55
        int startPos;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    56
        int endPos;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    57
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    58
        private JavaSource(String filename, String source) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    59
            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    60
            this.source = source;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    61
        }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    62
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    63
        @Override
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    64
        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    65
            return source;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    66
        }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    67
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    68
        static JavaSource createJavaSource(String preamble, String body,
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    69
                String postamble, String expected) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    70
            JavaSource js = createJavaSource(preamble, body, postamble, -1, -1);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    71
            js.startPos = js.source.indexOf(expected);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    72
            js.endPos   = js.startPos + expected.length();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    73
            return js;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    74
        }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    75
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    76
        static JavaSource createJavaSource(String body, String expected) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    77
            return createJavaSource(null, body, null, expected);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    78
        }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    79
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    80
        private static JavaSource createJavaSource(String preamble, String body,
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    81
                String postamble, int start, int end) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    82
            final String name = "Bug";
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    83
            StringBuilder code = new StringBuilder();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    84
            if (preamble != null) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    85
                code.append(preamble);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    86
            }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    87
            code.append("public class " + name + "{");
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    88
            if (body != null) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    89
                code.append(body);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    90
            }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    91
            code.append("}");
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    92
            if (postamble != null) {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    93
                code.append(postamble);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    94
            }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    95
            JavaSource js = new JavaSource(name + ".java", code.toString());
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    96
            js.startPos = start;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    97
            js.endPos = end;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    98
            return js;
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
    99
        }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   100
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   101
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   102
    public static void main(String... args) throws IOException {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   103
        testUninitializedVariable();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   104
        testMissingAnnotationValue();
27121
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
   105
        testUnresolvableAnnotationAttribute();
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   106
        testFinalVariableWithDefaultConstructor();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   107
        testFinalVariableWithConstructor();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   108
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   109
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   110
    static void testUninitializedVariable() throws IOException {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   111
        compile(JavaSource.createJavaSource("Object o = new A().new B(); class A { }",
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   112
                "B()"));
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   113
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   114
    static void testMissingAnnotationValue() throws IOException {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   115
        compile(JavaSource.createJavaSource("@Foo(\"vvvv\")",
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   116
                null, "@interface Foo { }", "\"vvvv\""));
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   117
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   118
27121
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
   119
    static void testUnresolvableAnnotationAttribute() throws IOException {
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
   120
        compile(JavaSource.createJavaSource("@Foo(value=\"vvvv\")",
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
   121
                null, "@interface Foo { }", "value"));
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
   122
    }
36889255488f 8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents: 19122
diff changeset
   123
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   124
    static void testFinalVariableWithDefaultConstructor() throws IOException {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   125
        compile(JavaSource.createJavaSource("private static final String Foo; public void bar() { }",
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   126
                "private static final String Foo;"));
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   127
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   128
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   129
    static void testFinalVariableWithConstructor() throws IOException {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   130
        compile(JavaSource.createJavaSource("public Bug (){} private static final String Foo; public void bar() { }",
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   131
                "{}"));
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   132
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   133
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   134
    static void compile(JavaSource src) throws IOException {
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   135
        ByteArrayOutputStream ba = new ByteArrayOutputStream();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   136
        PrintWriter writer = new PrintWriter(ba);
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   137
        File tempDir = new File(".");
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   138
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   139
        DiagnosticCollector dc = new DiagnosticCollector();
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   140
        try (JavaFileManager javaFileManager = getJavaFileManager(compiler, dc)) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   141
            List<String> options = new ArrayList<>();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   142
            options.add("-cp");
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   143
            options.add(tempDir.getPath());
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   144
            options.add("-d");
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   145
            options.add(tempDir.getPath());
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   146
            options.add("-XDshouldStopPolicy=GENERATE");
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   147
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   148
            List<JavaFileObject> sources = new ArrayList<>();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   149
            sources.add(src);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   150
            JavaCompiler.CompilationTask task =
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   151
                    compiler.getTask(writer, javaFileManager,
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   152
                    dc, options, null,
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   153
                    sources);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   154
            task.call();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   155
            for (Diagnostic diagnostic : (List<Diagnostic>) dc.getDiagnostics()) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   156
                long actualStart = diagnostic.getStartPosition();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   157
                long actualEnd = diagnostic.getEndPosition();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   158
                System.out.println("Source: " + src.source);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   159
                System.out.println("Diagnostic: " + diagnostic);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   160
                System.out.print("Start position: Expected: " + src.startPos);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   161
                System.out.println(", Actual: " + actualStart);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   162
                System.out.print("End position: Expected: " + src.endPos);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   163
                System.out.println(", Actual: " + actualEnd);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   164
                if (src.startPos != actualStart || src.endPos != actualEnd) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   165
                    throw new RuntimeException("error: trees don't match");
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 27121
diff changeset
   166
                }
19122
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   167
            }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   168
        }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   169
    }
1841f2fa76de 8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff changeset
   170
}