author | vromero |
Tue, 08 Jan 2013 13:47:57 +0000 | |
changeset 15040 | 99fd9483d3f0 |
parent 9074 | 76b505d19026 |
child 15384 | 5a8d00abf076 |
permissions | -rw-r--r-- |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
1 |
/* |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
2 |
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
4 |
* |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
8 |
* |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
14 |
* |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
18 |
* |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
23 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
24 |
/* |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 7030606 |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Project-coin: multi-catch types should be pairwise disjoint |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
28 |
* @library ../../lib |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
29 |
* @build JavacTestingAbstractThreadedTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
30 |
* @run main DisjunctiveTypeWellFormednessTest |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
31 |
*/ |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
32 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
33 |
import java.net.URI; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
34 |
import java.util.Arrays; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
35 |
import javax.tools.Diagnostic; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
36 |
import javax.tools.JavaFileObject; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
37 |
import javax.tools.SimpleJavaFileObject; |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
38 |
import com.sun.source.util.JavacTask; |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
39 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
40 |
public class DisjunctiveTypeWellFormednessTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
41 |
extends JavacTestingAbstractThreadedTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
42 |
implements Runnable { |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
43 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
44 |
enum Alternative { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
45 |
EXCEPTION("Exception"), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
46 |
RUNTIME_EXCEPTION("RuntimeException"), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
47 |
IO_EXCEPTION("java.io.IOException"), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
48 |
FILE_NOT_FOUND_EXCEPTION("java.io.FileNotFoundException"), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
49 |
ILLEGAL_ARGUMENT_EXCEPTION("IllegalArgumentException"); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
50 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
51 |
String exceptionStr; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
52 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
53 |
private Alternative(String exceptionStr) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
54 |
this.exceptionStr = exceptionStr; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
55 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
56 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
57 |
static String makeDisjunctiveType(Alternative... alternatives) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
58 |
StringBuilder buf = new StringBuilder(); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
59 |
String sep = ""; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
60 |
for (Alternative alternative : alternatives) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
61 |
buf.append(sep); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
62 |
buf.append(alternative.exceptionStr); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
63 |
sep = "|"; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
64 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
65 |
return buf.toString(); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
66 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
67 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
68 |
boolean disjoint(Alternative that) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
69 |
return disjoint[this.ordinal()][that.ordinal()]; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
70 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
71 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
72 |
static boolean[][] disjoint = { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
73 |
// Exception RuntimeException IOException FileNotFoundException IllegalArgumentException |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
74 |
/*Exception*/ { false, false, false, false, false }, |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
75 |
/*RuntimeException*/ { false, false, true, true, false }, |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
76 |
/*IOException*/ { false, true, false, false, true }, |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
77 |
/*FileNotFoundException*/ { false, true, false, false, true }, |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
78 |
/*IllegalArgumentException*/ { false, false, true, true, false } |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
79 |
}; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
80 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
81 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
82 |
enum Arity { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
83 |
ONE(1), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
84 |
TWO(2), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
85 |
THREE(3), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
86 |
FOUR(4), |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
87 |
FIVE(5); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
88 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
89 |
int n; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
90 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
91 |
private Arity(int n) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
92 |
this.n = n; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
93 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
94 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
95 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
96 |
public static void main(String... args) throws Exception { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
97 |
for (Arity arity : Arity.values()) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
98 |
for (Alternative a1 : Alternative.values()) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
99 |
if (arity == Arity.ONE) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
100 |
pool.execute(new DisjunctiveTypeWellFormednessTest(a1)); |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
101 |
continue; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
102 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
103 |
for (Alternative a2 : Alternative.values()) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
104 |
if (arity == Arity.TWO) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
105 |
pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2)); |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
106 |
continue; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
107 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
108 |
for (Alternative a3 : Alternative.values()) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
109 |
if (arity == Arity.THREE) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
110 |
pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3)); |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
111 |
continue; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
112 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
113 |
for (Alternative a4 : Alternative.values()) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
114 |
if (arity == Arity.FOUR) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
115 |
pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4)); |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
116 |
continue; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
117 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
118 |
for (Alternative a5 : Alternative.values()) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
119 |
pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5)); |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
120 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
121 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
122 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
123 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
124 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
125 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
126 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
127 |
checkAfterExec(false); |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
128 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
129 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
130 |
Alternative[] alternatives; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
131 |
JavaSource source; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
132 |
DiagnosticChecker diagChecker; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
133 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
134 |
DisjunctiveTypeWellFormednessTest(Alternative... alternatives) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
135 |
this.alternatives = alternatives; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
136 |
this.source = new JavaSource(); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
137 |
this.diagChecker = new DiagnosticChecker(); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
138 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
139 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
140 |
class JavaSource extends SimpleJavaFileObject { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
141 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
142 |
String template = "class Test {\n" + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
143 |
"void test() {\n" + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
144 |
"try {} catch (#T e) {}\n" + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
145 |
"}\n" + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
146 |
"}\n"; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
147 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
148 |
String source; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
149 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
150 |
public JavaSource() { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
151 |
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
152 |
source = template.replace("#T", Alternative.makeDisjunctiveType(alternatives)); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
153 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
154 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
155 |
@Override |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
156 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
157 |
return source; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
158 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
159 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
160 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
161 |
@Override |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
162 |
public void run() { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
163 |
JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
164 |
null, null, Arrays.asList(source)); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
165 |
try { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
166 |
ct.analyze(); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
167 |
} catch (Throwable t) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
168 |
processException(t); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
169 |
return; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
170 |
} |
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
171 |
check(); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
172 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
173 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
174 |
void check() { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
175 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
176 |
int non_disjoint = 0; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
177 |
int i = 0; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
178 |
for (Alternative a1 : alternatives) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
179 |
int j = 0; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
180 |
for (Alternative a2 : alternatives) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
181 |
if (i == j) continue; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
182 |
if (!a1.disjoint(a2)) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
183 |
non_disjoint++; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
184 |
break; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
185 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
186 |
j++; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
187 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
188 |
i++; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
189 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
190 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
191 |
if (non_disjoint != diagChecker.errorsFound) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
192 |
throw new Error("invalid diagnostics for source:\n" + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
193 |
source.getCharContent(true) + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
194 |
"\nFound errors: " + diagChecker.errorsFound + |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
195 |
"\nExpected errors: " + non_disjoint); |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
196 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
197 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
198 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
199 |
static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
200 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
201 |
int errorsFound; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
202 |
|
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
203 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
204 |
if (diagnostic.getKind() == Diagnostic.Kind.ERROR && |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
205 |
diagnostic.getCode().startsWith("compiler.err.multicatch.types.must.be.disjoint")) { |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
206 |
errorsFound++; |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
207 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
208 |
} |
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
209 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9074
diff
changeset
|
210 |
|
9074
76b505d19026
7030606: Project-coin: multi-catch types should be pairwise disjoint
mcimadamore
parents:
diff
changeset
|
211 |
} |