author | darcy |
Wed, 23 Sep 2009 18:29:41 -0700 | |
changeset 3994 | 7df1ecd5eadb |
child 5520 | 86e4b9a9da40 |
permissions | -rw-r--r-- |
3994
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
1 |
/* |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
2 |
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
4 |
* |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
8 |
* |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
13 |
* accompanied this code). |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
14 |
* |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
18 |
* |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
21 |
* have any questions. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
22 |
*/ |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
23 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
24 |
/* |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
25 |
* @test |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
26 |
* @bug 6471577 6517779 |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
27 |
* @summary Test Elements.getConstantExpression |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
28 |
* @author Joseph D. Darcy |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
29 |
* @build TestGetConstantExpression |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
30 |
* @compile -processor TestGetConstantExpression Foo.java |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
31 |
*/ |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
32 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
33 |
import java.util.Set; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
34 |
import javax.annotation.processing.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
35 |
import javax.lang.model.SourceVersion; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
36 |
import static javax.lang.model.SourceVersion.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
37 |
import javax.lang.model.element.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
38 |
import javax.lang.model.util.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
39 |
import static javax.lang.model.util.ElementFilter.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
40 |
import static javax.tools.Diagnostic.Kind.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
41 |
import static javax.tools.StandardLocation.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
42 |
import java.io.*; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
43 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
44 |
/** |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
45 |
* Test basic workings of Elements.getConstantExpression. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
46 |
*/ |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
47 |
@SupportedAnnotationTypes("*") |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
48 |
public class TestGetConstantExpression extends AbstractProcessor { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
49 |
private Elements eltUtils; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
50 |
private Filer filer; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
51 |
private int round = 1; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
52 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
53 |
/** |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
54 |
* Check expected behavior on classes and packages. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
55 |
*/ |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
56 |
public boolean process(Set<? extends TypeElement> annotations, |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
57 |
RoundEnvironment roundEnv) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
58 |
int errors = 0; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
59 |
boolean processingOver = roundEnv.processingOver(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
60 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
61 |
if (!processingOver && round == 1) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
62 |
errors += expectIllegalArgumentException(null); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
63 |
errors += expectIllegalArgumentException(this); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
64 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
65 |
// Generate source code with various constant values and |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
66 |
// make sure it compiles. |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
67 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
68 |
try { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
69 |
PrintWriter pw = new PrintWriter(filer.createSourceFile("ConstantTest").openWriter()); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
70 |
try { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
71 |
Boolean[] booleans = {true, false}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
72 |
Byte[] bytes = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
73 |
Short[] shorts = {Short.MIN_VALUE, -1, 0, 1, Short.MAX_VALUE}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
74 |
Integer[] ints = {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
75 |
Long[] longs = {Long.MIN_VALUE, -1L, 0L,1L, Long.MAX_VALUE}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
76 |
Character[] chars = {Character.MIN_VALUE, ' ', '\t', 'a', 'b', 'c', '~', Character.MAX_VALUE}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
77 |
Float[] floats = {Float.NaN, Float.NEGATIVE_INFINITY, -1.0f, -0.0f, 0.0f, 1.0f, Float.POSITIVE_INFINITY}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
78 |
Double[] doubles = {Double.NaN, Double.NEGATIVE_INFINITY, -1.0, -0.0, 0.0, 1.0, Double.POSITIVE_INFINITY}; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
79 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
80 |
pw.println("class ConstantTest {"); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
81 |
pw.println(String.format(" private static boolean[] booleans = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
82 |
printConstants(booleans))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
83 |
pw.println(String.format(" private static byte[] bytes = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
84 |
printConstants(bytes))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
85 |
pw.println(String.format(" private static short[] shorts = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
86 |
printConstants(shorts))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
87 |
pw.println(String.format(" private static int[] ints = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
88 |
printConstants(ints))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
89 |
pw.println(String.format(" private static long[] longs = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
90 |
printConstants(longs))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
91 |
pw.println(String.format(" private static char[] chars = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
92 |
printConstants(chars))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
93 |
pw.println(String.format(" private static float[] floats = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
94 |
printConstants(floats))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
95 |
pw.println(String.format(" private static double[] doubles = {%s};", |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
96 |
printConstants(doubles))); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
97 |
pw.println("}"); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
98 |
} finally { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
99 |
pw.close(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
100 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
101 |
} catch(IOException io) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
102 |
throw new RuntimeException(io); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
103 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
104 |
round++; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
105 |
} else if (processingOver) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
106 |
if (errors > 0) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
107 |
throw new RuntimeException(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
108 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
109 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
110 |
return true; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
111 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
112 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
113 |
String printConstants(Object[] constants) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
114 |
StringBuilder sb = new StringBuilder(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
115 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
116 |
for(Object o : constants) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
117 |
sb.append(eltUtils.getConstantExpression(o)); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
118 |
sb.append(", "); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
119 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
120 |
return sb.toString(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
121 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
122 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
123 |
int expectIllegalArgumentException(Object o) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
124 |
String s = ""; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
125 |
try { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
126 |
s = eltUtils.getConstantExpression(o); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
127 |
System.err.println("Unexpected string returned: " + s); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
128 |
return 1; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
129 |
} catch (IllegalArgumentException iae) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
130 |
return 0; |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
131 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
132 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
133 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
134 |
public SourceVersion getSupportedSourceVersion() { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
135 |
return SourceVersion.latest(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
136 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
137 |
|
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
138 |
public void init(ProcessingEnvironment processingEnv) { |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
139 |
super.init(processingEnv); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
140 |
eltUtils = processingEnv.getElementUtils(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
141 |
filer = processingEnv.getFiler(); |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
142 |
} |
7df1ecd5eadb
6517779: javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
darcy
parents:
diff
changeset
|
143 |
} |