author | vromero |
Tue, 06 Sep 2016 17:04:43 -0700 | |
changeset 40835 | 6ab9ed1abc46 |
parent 39601 | 5b37e511ae4b |
permissions | -rw-r--r-- |
19122
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
1 |
/* |
39601 | 2 |
* Copyright (c) 2013, 2016, 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 |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
27319
diff
changeset
|
28 |
* @modules java.compiler |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
27319
diff
changeset
|
29 |
* jdk.compiler |
19122
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
30 |
* @run main TreeEndPosTest |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
31 |
*/ |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
32 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
33 |
import java.io.ByteArrayOutputStream; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
34 |
import java.io.File; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
35 |
import java.io.IOException; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
36 |
import java.io.PrintWriter; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
37 |
import java.net.URI; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
38 |
import java.util.ArrayList; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
39 |
import java.util.List; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
40 |
import javax.tools.Diagnostic; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
41 |
import javax.tools.DiagnosticCollector; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
42 |
import javax.tools.JavaCompiler; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
43 |
import javax.tools.JavaFileManager; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
44 |
import javax.tools.JavaFileObject; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
45 |
import javax.tools.SimpleJavaFileObject; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
46 |
import javax.tools.ToolProvider; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
47 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
48 |
public class TreeEndPosTest { |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
49 |
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
|
50 |
DiagnosticCollector dc) { |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
51 |
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
|
52 |
} |
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 |
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
|
55 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
56 |
final String source; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
57 |
int startPos; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
58 |
int endPos; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
59 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
this.source = source; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
63 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
64 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
65 |
@Override |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
66 |
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
|
67 |
return source; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
68 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
69 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
70 |
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
|
71 |
String postamble, String expected) { |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
return js; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
76 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
77 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
81 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
final String name = "Bug"; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
85 |
StringBuilder code = new StringBuilder(); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
86 |
if (preamble != null) { |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
87 |
code.append(preamble); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
88 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
89 |
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
|
90 |
if (body != null) { |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
91 |
code.append(body); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
92 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
93 |
code.append("}"); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
94 |
if (postamble != null) { |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
95 |
code.append(postamble); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
96 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
97 |
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
|
98 |
js.startPos = start; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
99 |
js.endPos = end; |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
100 |
return js; |
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 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
103 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
104 |
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
|
105 |
testUninitializedVariable(); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
106 |
testMissingAnnotationValue(); |
27121
36889255488f
8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents:
19122
diff
changeset
|
107 |
testUnresolvableAnnotationAttribute(); |
19122
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
108 |
testFinalVariableWithDefaultConstructor(); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
109 |
testFinalVariableWithConstructor(); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
110 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
111 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
112 |
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
|
113 |
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
|
114 |
"B()")); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
115 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
null, "@interface Foo { }", "\"vvvv\"")); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
119 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
120 |
|
27121
36889255488f
8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents:
19122
diff
changeset
|
121 |
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
|
122 |
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
|
123 |
null, "@interface Foo { }", "value")); |
36889255488f
8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents:
19122
diff
changeset
|
124 |
} |
36889255488f
8054956: Javac reports wrong error offset for unknown identifier of annotation element/value pair
jlahoda
parents:
19122
diff
changeset
|
125 |
|
19122
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
"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
|
129 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
130 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
131 |
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
|
132 |
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
|
133 |
"{}")); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
134 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
135 |
|
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
136 |
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
|
137 |
ByteArrayOutputStream ba = new ByteArrayOutputStream(); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
138 |
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
|
139 |
File tempDir = new File("."); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
140 |
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
141 |
DiagnosticCollector dc = new DiagnosticCollector(); |
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
142 |
try (JavaFileManager javaFileManager = getJavaFileManager(compiler, dc)) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
143 |
List<String> options = new ArrayList<>(); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
144 |
options.add("-cp"); |
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("-d"); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
147 |
options.add(tempDir.getPath()); |
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
39601
diff
changeset
|
148 |
options.add("--should-stop:at=GENERATE"); |
19122
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
149 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
150 |
List<JavaFileObject> sources = new ArrayList<>(); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
151 |
sources.add(src); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
152 |
JavaCompiler.CompilationTask task = |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
153 |
compiler.getTask(writer, javaFileManager, |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
154 |
dc, options, null, |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
155 |
sources); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
156 |
task.call(); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
157 |
for (Diagnostic diagnostic : (List<Diagnostic>) dc.getDiagnostics()) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
158 |
long actualStart = diagnostic.getStartPosition(); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
159 |
long actualEnd = diagnostic.getEndPosition(); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
160 |
System.out.println("Source: " + src.source); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
161 |
System.out.println("Diagnostic: " + diagnostic); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
162 |
System.out.print("Start position: Expected: " + src.startPos); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
163 |
System.out.println(", Actual: " + actualStart); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
164 |
System.out.print("End position: Expected: " + src.endPos); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
165 |
System.out.println(", Actual: " + actualEnd); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
166 |
if (src.startPos != actualStart || src.endPos != actualEnd) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
167 |
throw new RuntimeException("error: trees don't match"); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
27121
diff
changeset
|
168 |
} |
19122
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 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
171 |
} |
1841f2fa76de
8017216: javac doesn't fill in end position for some errors of type not found
ksrini
parents:
diff
changeset
|
172 |
} |