author | avstepan |
Tue, 19 May 2015 16:04:14 +0400 | |
changeset 30655 | d83f50188ca9 |
parent 27319 | 030080f03e4f |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
1 |
/* |
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
4 |
* |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
8 |
* |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
14 |
* |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
18 |
* |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
21 |
* questions. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
22 |
*/ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
23 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
24 |
/* |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
25 |
* @test |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
26 |
* @bug 6437138 6482554 |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
27 |
* @summary JSR 199: Compiler doesn't diagnose crash in user code |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
28 |
* @library ../lib |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
29 |
* @build JavacTestingAbstractProcessor TestClientCodeWrapper |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
30 |
* @run main TestClientCodeWrapper |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
31 |
*/ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
32 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
33 |
import java.io.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
34 |
import java.lang.reflect.Method; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
35 |
import java.net.URI; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
36 |
import java.util.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
37 |
import javax.annotation.processing.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
38 |
import javax.lang.model.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
39 |
import javax.lang.model.element.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
40 |
import javax.tools.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
41 |
import com.sun.source.util.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
42 |
import com.sun.tools.javac.api.*; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
43 |
import javax.tools.JavaFileObject.Kind; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
44 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
45 |
public class TestClientCodeWrapper extends JavacTestingAbstractProcessor { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
46 |
public static void main(String... args) throws Exception { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
47 |
new TestClientCodeWrapper().run(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
48 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
49 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
50 |
/** |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
51 |
* Run a series of compilations, each with a different user-provided object |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
52 |
* configured to throw an exception when a specific method is invoked. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
53 |
* Then, verify the exception is thrown as expected. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
54 |
* |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
55 |
* Some methods are not invoked from the compiler, and are excluded from the test. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
56 |
*/ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
57 |
void run() throws Exception { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
58 |
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
59 |
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
60 |
defaultFileManager = fm; |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
61 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
62 |
for (Method m: getMethodsExcept(JavaFileManager.class, "close", "getJavaFileForInput")) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
63 |
test(m); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
64 |
} |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
65 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
66 |
for (Method m: getMethodsExcept(FileObject.class, "delete")) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
67 |
test(m); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
68 |
} |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
69 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
70 |
for (Method m: getMethods(JavaFileObject.class)) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
71 |
test(m); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
72 |
} |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
73 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
74 |
for (Method m: getMethodsExcept(Processor.class, "getCompletions")) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
75 |
test(m); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
76 |
} |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
77 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
78 |
for (Method m: DiagnosticListener.class.getDeclaredMethods()) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
79 |
test(m); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
80 |
} |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
81 |
|
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
82 |
for (Method m: TaskListener.class.getDeclaredMethods()) { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
83 |
test(m); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
84 |
} |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
85 |
|
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
86 |
if (errors > 0) |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
9744
diff
changeset
|
87 |
throw new Exception(errors + " errors occurred"); |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
88 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
89 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
90 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
91 |
/** Get a sorted set of the methods declared on a class. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
92 |
Set<Method> getMethods(Class<?> clazz) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
93 |
return getMethodsExcept(clazz, new String[0]); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
94 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
95 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
96 |
/** Get a sorted set of the methods declared on a class, excluding |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
97 |
* specified methods by name. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
98 |
Set<Method> getMethodsExcept(Class<?> clazz, String... exclude) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
99 |
Set<Method> methods = new TreeSet<Method>(new Comparator<Method>() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
100 |
public int compare(Method m1, Method m2) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
101 |
return m1.toString().compareTo(m2.toString()); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
102 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
103 |
}); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
104 |
Set<String> e = new HashSet<String>(Arrays.asList(exclude)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
105 |
for (Method m: clazz.getDeclaredMethods()) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
106 |
if (!e.contains(m.getName())) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
107 |
methods.add(m); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
108 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
109 |
return methods; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
110 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
111 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
112 |
/** |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
113 |
* Test a method in a user supplied component, to verify javac's handling |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
114 |
* of any exceptions thrown by that method. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
115 |
*/ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
116 |
void test(Method m) throws Exception { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
117 |
testNum++; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
118 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
119 |
File extDirs = new File("empty-extdirs"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
120 |
extDirs.mkdirs(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
121 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
122 |
File testClasses = new File("test" + testNum); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
123 |
testClasses.mkdirs(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
124 |
defaultFileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(testClasses)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
125 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
126 |
System.err.println("test " + testNum + ": " |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
127 |
+ m.getDeclaringClass().getSimpleName() + "." + m.getName()); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
128 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
129 |
StringWriter sw = new StringWriter(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
130 |
PrintWriter pw = new PrintWriter(sw); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
131 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
132 |
List<String> javacOptions = Arrays.asList( |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
133 |
"-extdirs", extDirs.getPath(), // for use by filemanager handleOption |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
134 |
"-processor", TestClientCodeWrapper.class.getName() |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
135 |
); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
136 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
137 |
List<String> classes = Collections.emptyList(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
138 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
139 |
JavacTool tool = JavacTool.create(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
140 |
try { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
141 |
JavacTask task = tool.getTask(pw, |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
142 |
getFileManager(m, defaultFileManager), |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
143 |
getDiagnosticListener(m, pw), |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
144 |
javacOptions, |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
145 |
classes, |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
146 |
getCompilationUnits(m)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
147 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
148 |
if (isDeclaredIn(m, Processor.class)) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
149 |
task.setProcessors(getProcessors(m)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
150 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
151 |
if (isDeclaredIn(m, TaskListener.class)) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
152 |
task.setTaskListener(getTaskListener(m, pw)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
153 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
154 |
boolean ok = task.call(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
155 |
error("compilation " + (ok ? "succeeded" : "failed") + " unexpectedly"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
156 |
} catch (RuntimeException e) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
157 |
System.err.println("caught " + e); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
158 |
if (e.getClass() == RuntimeException.class) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
159 |
Throwable cause = e.getCause(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
160 |
if (cause instanceof UserError) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
161 |
String expect = m.getName(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
162 |
String found = cause.getMessage(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
163 |
checkEqual("exception messaqe", expect, found); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
164 |
} else { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
165 |
cause.printStackTrace(System.err); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
166 |
error("Unexpected exception: " + cause); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
167 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
168 |
} else { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
169 |
e.printStackTrace(System.err); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
170 |
error("Unexpected exception: " + e); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
171 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
172 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
173 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
174 |
pw.close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
175 |
String out = sw.toString(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
176 |
System.err.println(out); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
177 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
178 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
179 |
/** Get a file manager to use for the test compilation. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
180 |
JavaFileManager getFileManager(Method m, JavaFileManager defaultFileManager) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
181 |
return isDeclaredIn(m, JavaFileManager.class, FileObject.class, JavaFileObject.class) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
182 |
? new UserFileManager(m, defaultFileManager) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
183 |
: defaultFileManager; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
184 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
185 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
186 |
/** Get a diagnostic listener to use for the test compilation. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
187 |
DiagnosticListener<JavaFileObject> getDiagnosticListener(Method m, PrintWriter out) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
188 |
return isDeclaredIn(m, DiagnosticListener.class) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
189 |
? new UserDiagnosticListener(m, out) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
190 |
: null; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
191 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
192 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
193 |
/** Get a set of file objects to use for the test compilation. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
194 |
Iterable<? extends JavaFileObject> getCompilationUnits(Method m) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
195 |
File testSrc = new File(System.getProperty("test.src")); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
196 |
File thisSrc = new File(testSrc, TestClientCodeWrapper.class.getName() + ".java"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
197 |
Iterable<? extends JavaFileObject> files = defaultFileManager.getJavaFileObjects(thisSrc); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
198 |
if (isDeclaredIn(m, FileObject.class, JavaFileObject.class)) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
199 |
return Arrays.asList(new UserFileObject(m, files.iterator().next())); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
200 |
else |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
201 |
return files; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
202 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
203 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
204 |
/** Get a set of annotation processors to use for the test compilation. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
205 |
Iterable<? extends Processor> getProcessors(Method m) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
206 |
return Arrays.asList(new UserProcessor(m)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
207 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
208 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
209 |
/** Get a task listener to use for the test compilation. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
210 |
TaskListener getTaskListener(Method m, PrintWriter out) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
211 |
return new UserTaskListener(m, out); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
212 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
213 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
214 |
/** Check if two values are .equal, and report an error if not. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
215 |
<T> void checkEqual(String label, T expect, T found) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
216 |
if (!expect.equals(found)) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
217 |
error("Unexpected value for " + label + ": " + found + "; expected: " + expect); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
218 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
219 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
220 |
/** Report an error. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
221 |
void error(String msg) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
222 |
System.err.println("Error: " + msg); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
223 |
errors++; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
224 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
225 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
226 |
/** Check if a method is declared in any of a set of classes */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
227 |
static boolean isDeclaredIn(Method m, Class<?>... classes) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
228 |
Class<?> dc = m.getDeclaringClass(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
229 |
for (Class<?> c: classes) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
230 |
if (c == dc) return true; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
231 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
232 |
return false; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
233 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
234 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
235 |
/** Throw an intentional error if the method has a given name. */ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
236 |
static void throwUserExceptionIfNeeded(Method m, String name) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
237 |
if (m != null && m.getName().equals(name)) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
238 |
throw new UserError(name); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
239 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
240 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
241 |
StandardJavaFileManager defaultFileManager; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
242 |
int testNum; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
243 |
int errors; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
244 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
245 |
//-------------------------------------------------------------------------- |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
246 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
247 |
/** |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
248 |
* Processor used to trigger use of methods not normally used by javac. |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
249 |
*/ |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
250 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
251 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
252 |
boolean firstRound = false; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
253 |
for (Element e: roundEnv.getRootElements()) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
254 |
if (e.getSimpleName().contentEquals(TestClientCodeWrapper.class.getSimpleName())) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
255 |
firstRound = true; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
256 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
257 |
if (firstRound) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
258 |
try { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
259 |
FileObject f1 = filer.getResource(StandardLocation.CLASS_PATH, "", |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
260 |
TestClientCodeWrapper.class.getName() + ".java"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
261 |
f1.openInputStream().close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
262 |
f1.openReader(false).close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
263 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
264 |
FileObject f2 = filer.createResource( |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
265 |
StandardLocation.CLASS_OUTPUT, "", "f2.txt", (Element[]) null); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
266 |
f2.openOutputStream().close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
267 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
268 |
FileObject f3 = filer.createResource( |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
269 |
StandardLocation.CLASS_OUTPUT, "", "f3.txt", (Element[]) null); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
270 |
f3.openWriter().close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
271 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
272 |
JavaFileObject f4 = filer.createSourceFile("f4", (Element[]) null); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
273 |
f4.openWriter().close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
274 |
f4.getNestingKind(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
275 |
f4.getAccessLevel(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
276 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
277 |
messager.printMessage(Diagnostic.Kind.NOTE, "informational note", |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
278 |
roundEnv.getRootElements().iterator().next()); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
279 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
280 |
} catch (IOException e) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
281 |
throw new UserError(e); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
282 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
283 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
284 |
return true; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
285 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
286 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
287 |
//-------------------------------------------------------------------------- |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
288 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
289 |
// <editor-fold defaultstate="collapsed" desc="User classes"> |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
290 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
291 |
static class UserError extends Error { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
292 |
private static final long serialVersionUID = 1L; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
293 |
UserError(String msg) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
294 |
super(msg); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
295 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
296 |
UserError(Throwable t) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
297 |
super(t); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
298 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
299 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
300 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
301 |
static class UserFileManager extends ForwardingJavaFileManager<JavaFileManager> { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
302 |
Method fileManagerMethod; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
303 |
Method fileObjectMethod; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
304 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
305 |
UserFileManager(Method m, JavaFileManager delegate) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
306 |
super(delegate); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
307 |
if (isDeclaredIn(m, JavaFileManager.class)) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
308 |
fileManagerMethod = m; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
309 |
} else if (isDeclaredIn(m, FileObject.class, JavaFileObject.class)) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
310 |
fileObjectMethod = m; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
311 |
} else |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
312 |
assert false; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
313 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
314 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
315 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
316 |
public ClassLoader getClassLoader(Location location) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
317 |
throwUserExceptionIfNeeded(fileManagerMethod, "getClassLoader"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
318 |
return super.getClassLoader(location); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
319 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
320 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
321 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
322 |
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
323 |
throwUserExceptionIfNeeded(fileManagerMethod, "list"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
324 |
return wrap(super.list(location, packageName, kinds, recurse)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
325 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
326 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
327 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
328 |
public String inferBinaryName(Location location, JavaFileObject file) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
329 |
throwUserExceptionIfNeeded(fileManagerMethod, "inferBinaryName"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
330 |
return super.inferBinaryName(location, unwrap(file)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
331 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
332 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
333 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
334 |
public boolean isSameFile(FileObject a, FileObject b) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
335 |
throwUserExceptionIfNeeded(fileManagerMethod, "isSameFile"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
336 |
return super.isSameFile(unwrap(a), unwrap(b)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
337 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
338 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
339 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
340 |
public boolean handleOption(String current, Iterator<String> remaining) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
341 |
throwUserExceptionIfNeeded(fileManagerMethod, "handleOption"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
342 |
return super.handleOption(current, remaining); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
343 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
344 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
345 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
346 |
public boolean hasLocation(Location location) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
347 |
throwUserExceptionIfNeeded(fileManagerMethod, "hasLocation"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
348 |
return super.hasLocation(location); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
349 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
350 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
351 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
352 |
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
353 |
throwUserExceptionIfNeeded(fileManagerMethod, "getJavaFileForInput"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
354 |
return wrap(super.getJavaFileForInput(location, className, kind)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
355 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
356 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
357 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
358 |
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
359 |
throwUserExceptionIfNeeded(fileManagerMethod, "getJavaFileForOutput"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
360 |
return wrap(super.getJavaFileForOutput(location, className, kind, sibling)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
361 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
362 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
363 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
364 |
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
365 |
throwUserExceptionIfNeeded(fileManagerMethod, "getFileForInput"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
366 |
return wrap(super.getFileForInput(location, packageName, relativeName)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
367 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
368 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
369 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
370 |
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
371 |
throwUserExceptionIfNeeded(fileManagerMethod, "getFileForOutput"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
372 |
return wrap(super.getFileForOutput(location, packageName, relativeName, sibling)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
373 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
374 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
375 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
376 |
public void flush() throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
377 |
throwUserExceptionIfNeeded(fileManagerMethod, "flush"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
378 |
super.flush(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
379 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
380 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
381 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
382 |
public void close() throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
383 |
throwUserExceptionIfNeeded(fileManagerMethod, "close"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
384 |
super.close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
385 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
386 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
387 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
388 |
public int isSupportedOption(String option) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
389 |
throwUserExceptionIfNeeded(fileManagerMethod, "isSupportedOption"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
390 |
return super.isSupportedOption(option); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
391 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
392 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
393 |
public FileObject wrap(FileObject fo) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
394 |
if (fileObjectMethod == null) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
395 |
return fo; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
396 |
return new UserFileObject(fileObjectMethod, (JavaFileObject)fo); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
397 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
398 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
399 |
FileObject unwrap(FileObject fo) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
400 |
if (fo instanceof UserFileObject) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
401 |
return ((UserFileObject) fo).unwrap(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
402 |
else |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
403 |
return fo; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
404 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
405 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
406 |
public JavaFileObject wrap(JavaFileObject fo) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
407 |
if (fileObjectMethod == null) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
408 |
return fo; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
409 |
return new UserFileObject(fileObjectMethod, fo); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
410 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
411 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
412 |
public Iterable<JavaFileObject> wrap(Iterable<? extends JavaFileObject> list) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
413 |
List<JavaFileObject> wrapped = new ArrayList<JavaFileObject>(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
414 |
for (JavaFileObject fo : list) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
415 |
wrapped.add(wrap(fo)); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
416 |
return Collections.unmodifiableList(wrapped); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
417 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
418 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
419 |
JavaFileObject unwrap(JavaFileObject fo) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
420 |
if (fo instanceof UserFileObject) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
421 |
return ((UserFileObject) fo).unwrap(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
422 |
else |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
423 |
return fo; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
424 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
425 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
426 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
427 |
static class UserFileObject extends ForwardingJavaFileObject<JavaFileObject> { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
428 |
Method method; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
429 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
430 |
UserFileObject(Method m, JavaFileObject delegate) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
431 |
super(delegate); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
432 |
assert isDeclaredIn(m, FileObject.class, JavaFileObject.class); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
433 |
this.method = m; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
434 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
435 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
436 |
JavaFileObject unwrap() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
437 |
return fileObject; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
438 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
439 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
440 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
441 |
public Kind getKind() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
442 |
throwUserExceptionIfNeeded(method, "getKind"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
443 |
return super.getKind(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
444 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
445 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
446 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
447 |
public boolean isNameCompatible(String simpleName, Kind kind) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
448 |
throwUserExceptionIfNeeded(method, "isNameCompatible"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
449 |
return super.isNameCompatible(simpleName, kind); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
450 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
451 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
452 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
453 |
public NestingKind getNestingKind() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
454 |
throwUserExceptionIfNeeded(method, "getNestingKind"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
455 |
return super.getNestingKind(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
456 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
457 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
458 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
459 |
public Modifier getAccessLevel() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
460 |
throwUserExceptionIfNeeded(method, "getAccessLevel"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
461 |
return super.getAccessLevel(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
462 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
463 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
464 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
465 |
public URI toUri() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
466 |
throwUserExceptionIfNeeded(method, "toUri"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
467 |
return super.toUri(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
468 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
469 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
470 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
471 |
public String getName() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
472 |
throwUserExceptionIfNeeded(method, "getName"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
473 |
return super.getName(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
474 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
475 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
476 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
477 |
public InputStream openInputStream() throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
478 |
throwUserExceptionIfNeeded(method, "openInputStream"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
479 |
return super.openInputStream(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
480 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
481 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
482 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
483 |
public OutputStream openOutputStream() throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
484 |
throwUserExceptionIfNeeded(method, "openOutputStream"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
485 |
return super.openOutputStream(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
486 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
487 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
488 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
489 |
public Reader openReader(boolean ignoreEncodingErrors) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
490 |
throwUserExceptionIfNeeded(method, "openReader"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
491 |
return super.openReader(ignoreEncodingErrors); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
492 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
493 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
494 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
495 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
496 |
throwUserExceptionIfNeeded(method, "getCharContent"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
497 |
return super.getCharContent(ignoreEncodingErrors); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
498 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
499 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
500 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
501 |
public Writer openWriter() throws IOException { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
502 |
throwUserExceptionIfNeeded(method, "openWriter"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
503 |
return super.openWriter(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
504 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
505 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
506 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
507 |
public long getLastModified() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
508 |
throwUserExceptionIfNeeded(method, "getLastModified"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
509 |
return super.getLastModified(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
510 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
511 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
512 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
513 |
public boolean delete() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
514 |
throwUserExceptionIfNeeded(method, "delete"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
515 |
return super.delete(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
516 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
517 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
518 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
519 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
520 |
static class UserProcessor extends JavacTestingAbstractProcessor { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
521 |
Method method; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
522 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
523 |
UserProcessor(Method m) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
524 |
assert isDeclaredIn(m, Processor.class); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
525 |
method = m; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
526 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
527 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
528 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
529 |
public Set<String> getSupportedOptions() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
530 |
throwUserExceptionIfNeeded(method, "getSupportedOptions"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
531 |
return super.getSupportedOptions(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
532 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
533 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
534 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
535 |
public Set<String> getSupportedAnnotationTypes() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
536 |
throwUserExceptionIfNeeded(method, "getSupportedAnnotationTypes"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
537 |
return super.getSupportedAnnotationTypes(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
538 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
539 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
540 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
541 |
public SourceVersion getSupportedSourceVersion() { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
542 |
throwUserExceptionIfNeeded(method, "getSupportedSourceVersion"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
543 |
return super.getSupportedSourceVersion(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
544 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
545 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
546 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
547 |
public void init(ProcessingEnvironment processingEnv) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
548 |
throwUserExceptionIfNeeded(method, "init"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
549 |
super.init(processingEnv); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
550 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
551 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
552 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
553 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
554 |
throwUserExceptionIfNeeded(method, "process"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
555 |
return true; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
556 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
557 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
558 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
559 |
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
560 |
throwUserExceptionIfNeeded(method, "getCompletions"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
561 |
return super.getCompletions(element, annotation, member, userText); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
562 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
563 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
564 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
565 |
static class UserDiagnosticListener implements DiagnosticListener<JavaFileObject> { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
566 |
Method method; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
567 |
PrintWriter out; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
568 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
569 |
UserDiagnosticListener(Method m, PrintWriter out) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
570 |
assert isDeclaredIn(m, DiagnosticListener.class); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
571 |
this.method = m; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
572 |
this.out = out; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
573 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
574 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
575 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
576 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
577 |
throwUserExceptionIfNeeded(method, "report"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
578 |
out.println("report: " + diagnostic); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
579 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
580 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
581 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
582 |
static class UserTaskListener implements TaskListener { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
583 |
Method method; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
584 |
PrintWriter out; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
585 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
586 |
UserTaskListener(Method m, PrintWriter out) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
587 |
assert isDeclaredIn(m, TaskListener.class); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
588 |
this.method = m; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
589 |
this.out = out; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
590 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
591 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
592 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
593 |
public void started(TaskEvent e) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
594 |
throwUserExceptionIfNeeded(method, "started"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
595 |
out.println("started: " + e); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
596 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
597 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
598 |
@Override |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
599 |
public void finished(TaskEvent e) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
600 |
throwUserExceptionIfNeeded(method, "finished"); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
601 |
out.println("finished: " + e); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
602 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
603 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
604 |
|
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
605 |
// </editor-fold> |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
diff
changeset
|
606 |
} |