author | vromero |
Tue, 08 Jan 2013 13:47:57 +0000 | |
changeset 15040 | 99fd9483d3f0 |
parent 14547 | 86d8d242b0c4 |
child 15384 | 5a8d00abf076 |
permissions | -rw-r--r-- |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
1 |
/* |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
4 |
* |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
8 |
* |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
14 |
* |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
18 |
* |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
23 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
24 |
/* |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
26 |
* @summary Automatic test for checking correctness of default super/this resolution |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
27 |
* @library ../../lib |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
28 |
* @build JavacTestingAbstractThreadedTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
29 |
* @run main TestDefaultSuperCall |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
30 |
*/ |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
31 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
32 |
import java.net.URI; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
33 |
import java.util.Arrays; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
34 |
import java.util.ArrayList; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
35 |
import java.util.List; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
36 |
import java.util.Locale; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
37 |
import javax.tools.Diagnostic; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
38 |
import javax.tools.JavaFileObject; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
39 |
import javax.tools.SimpleJavaFileObject; |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
40 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
41 |
import com.sun.source.util.JavacTask; |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
42 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
43 |
public class TestDefaultSuperCall |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
44 |
extends JavacTestingAbstractThreadedTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
45 |
implements Runnable { |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
46 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
47 |
enum InterfaceKind { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
48 |
DEFAULT("interface A extends B { default void m() { } }"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
49 |
ABSTRACT("interface A extends B { void m(); }"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
50 |
NONE("interface A extends B { }"); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
51 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
52 |
String interfaceStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
53 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
54 |
InterfaceKind(String interfaceStr) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
55 |
this.interfaceStr = interfaceStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
56 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
57 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
58 |
boolean methodDefined() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
59 |
return this == DEFAULT; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
60 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
61 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
62 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
63 |
enum PruneKind { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
64 |
NO_PRUNE("interface C { }"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
65 |
PRUNE("interface C extends A { }"); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
66 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
67 |
boolean methodDefined(InterfaceKind ik) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
68 |
return this == PRUNE && |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
69 |
ik.methodDefined(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
70 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
71 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
72 |
String interfaceStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
73 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
74 |
PruneKind(String interfaceStr) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
75 |
this.interfaceStr = interfaceStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
76 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
77 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
78 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
79 |
enum QualifierKind { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
80 |
DIRECT_1("C"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
81 |
DIRECT_2("A"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
82 |
INDIRECT("B"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
83 |
UNRELATED("E"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
84 |
ENCLOSING_1(null), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
85 |
ENCLOSING_2(null); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
86 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
87 |
String qualifierStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
88 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
89 |
QualifierKind(String qualifierStr) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
90 |
this.qualifierStr = qualifierStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
91 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
92 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
93 |
String getQualifier(Shape sh) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
94 |
switch (this) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
95 |
case ENCLOSING_1: return sh.enclosingAt(0); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
96 |
case ENCLOSING_2: return sh.enclosingAt(1); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
97 |
default: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
98 |
return qualifierStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
99 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
100 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
101 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
102 |
boolean isEnclosing() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
103 |
return this == ENCLOSING_1 || |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
104 |
this == ENCLOSING_2; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
105 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
106 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
107 |
boolean allowSuperCall(InterfaceKind ik, PruneKind pk) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
108 |
switch (this) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
109 |
case DIRECT_1: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
110 |
return pk.methodDefined(ik); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
111 |
case DIRECT_2: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
112 |
return ik.methodDefined() && pk == PruneKind.NO_PRUNE; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
113 |
default: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
114 |
return false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
115 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
116 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
117 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
118 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
119 |
enum ExprKind { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
120 |
THIS("this"), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
121 |
SUPER("super"); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
122 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
123 |
String exprStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
124 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
125 |
ExprKind(String exprStr) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
126 |
this.exprStr = exprStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
127 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
128 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
129 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
130 |
enum ElementKind { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
131 |
INTERFACE("interface #N { #B }", true), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
132 |
INTERFACE_EXTENDS("interface #N extends A, C { #B }", true), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
133 |
CLASS("class #N { #B }", false), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
134 |
CLASS_EXTENDS("abstract class #N implements A, C { #B }", false), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
135 |
STATIC_CLASS("static class #N { #B }", true), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
136 |
STATIC_CLASS_EXTENDS("abstract static class #N implements A, C { #B }", true), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
137 |
ANON_CLASS("new Object() { #B };", false), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
138 |
METHOD("void test() { #B }", false), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
139 |
STATIC_METHOD("static void test() { #B }", true), |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
140 |
DEFAULT_METHOD("default void test() { #B }", false); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
141 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
142 |
String templateDecl; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
143 |
boolean isStatic; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
144 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
145 |
ElementKind(String templateDecl, boolean isStatic) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
146 |
this.templateDecl = templateDecl; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
147 |
this.isStatic = isStatic; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
148 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
149 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
150 |
boolean isClassDecl() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
151 |
switch(this) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
152 |
case METHOD: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
153 |
case STATIC_METHOD: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
154 |
case DEFAULT_METHOD: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
155 |
return false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
156 |
default: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
157 |
return true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
158 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
159 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
160 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
161 |
boolean isAllowedEnclosing(ElementKind ek, boolean isTop) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
162 |
switch (this) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
163 |
case CLASS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
164 |
case CLASS_EXTENDS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
165 |
//class is implicitly static inside interface, so skip this combo |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
166 |
return ek.isClassDecl() && |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
167 |
ek != INTERFACE && ek != INTERFACE_EXTENDS; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
168 |
case ANON_CLASS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
169 |
return !ek.isClassDecl(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
170 |
case METHOD: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
171 |
return ek == CLASS || ek == CLASS_EXTENDS || |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
172 |
ek == STATIC_CLASS || ek == STATIC_CLASS_EXTENDS || |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
173 |
ek == ANON_CLASS; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
174 |
case INTERFACE: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
175 |
case INTERFACE_EXTENDS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
176 |
case STATIC_CLASS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
177 |
case STATIC_CLASS_EXTENDS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
178 |
case STATIC_METHOD: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
179 |
return (isTop && (ek == CLASS || ek == CLASS_EXTENDS)) || |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
180 |
ek == STATIC_CLASS || ek == STATIC_CLASS_EXTENDS; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
181 |
case DEFAULT_METHOD: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
182 |
return ek == INTERFACE || ek == INTERFACE_EXTENDS; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
183 |
default: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
184 |
throw new AssertionError("Bad enclosing element kind" + this); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
185 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
186 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
187 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
188 |
boolean isAllowedTop() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
189 |
switch (this) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
190 |
case CLASS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
191 |
case CLASS_EXTENDS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
192 |
case INTERFACE: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
193 |
case INTERFACE_EXTENDS: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
194 |
return true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
195 |
default: |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
196 |
return false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
197 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
198 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
199 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
200 |
boolean hasSuper() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
201 |
return this == INTERFACE_EXTENDS || |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
202 |
this == STATIC_CLASS_EXTENDS || |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
203 |
this == CLASS_EXTENDS; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
204 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
205 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
206 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
207 |
static class Shape { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
208 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
209 |
String shapeStr; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
210 |
List<ElementKind> enclosingElements; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
211 |
List<String> enclosingNames; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
212 |
List<String> elementsWithMethod; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
213 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
214 |
Shape(ElementKind... elements) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
215 |
errWriter.println("elements = " + Arrays.toString(elements)); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
216 |
enclosingElements = new ArrayList<>(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
217 |
enclosingNames = new ArrayList<>(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
218 |
elementsWithMethod = new ArrayList<>(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
219 |
int count = 0; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
220 |
String prevName = null; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
221 |
for (ElementKind ek : elements) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
222 |
String name = "name"+count++; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
223 |
if (ek.isStatic) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
224 |
enclosingElements = new ArrayList<>(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
225 |
enclosingNames = new ArrayList<>(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
226 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
227 |
if (ek.isClassDecl()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
228 |
enclosingElements.add(ek); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
229 |
enclosingNames.add(name); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
230 |
} else { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
231 |
elementsWithMethod.add(prevName); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
232 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
233 |
String element = ek.templateDecl.replaceAll("#N", name); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
234 |
shapeStr = shapeStr == |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
235 |
null ? element : shapeStr.replaceAll("#B", element); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
236 |
prevName = name; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
237 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
238 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
239 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
240 |
String getShape(QualifierKind qk, ExprKind ek) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
241 |
String methName = ek == ExprKind.THIS ? "test" : "m"; |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
242 |
String call = qk.getQualifier(this) + "." + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
243 |
ek.exprStr + "." + methName + "();"; |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
244 |
return shapeStr.replaceAll("#B", call); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
245 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
246 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
247 |
String enclosingAt(int index) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
248 |
return index < enclosingNames.size() ? |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
249 |
enclosingNames.get(index) : "BAD"; |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
250 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
251 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
252 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
253 |
public static void main(String... args) throws Exception { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
254 |
for (InterfaceKind ik : InterfaceKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
255 |
for (PruneKind pk : PruneKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
256 |
for (ElementKind ek1 : ElementKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
257 |
if (!ek1.isAllowedTop()) continue; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
258 |
for (ElementKind ek2 : ElementKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
259 |
if (!ek2.isAllowedEnclosing(ek1, true)) continue; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
260 |
for (ElementKind ek3 : ElementKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
261 |
if (!ek3.isAllowedEnclosing(ek2, false)) continue; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
262 |
for (ElementKind ek4 : ElementKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
263 |
if (!ek4.isAllowedEnclosing(ek3, false)) continue; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
264 |
for (ElementKind ek5 : ElementKind.values()) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
265 |
if (!ek5.isAllowedEnclosing(ek4, false) || |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
266 |
ek5.isClassDecl()) continue; |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
267 |
for (QualifierKind qk : QualifierKind.values()) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
268 |
for (ExprKind ek : ExprKind.values()) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
269 |
pool.execute( |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
270 |
new TestDefaultSuperCall(ik, pk, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
271 |
new Shape(ek1, ek2, ek3, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
272 |
ek4, ek5), qk, ek)); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
273 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
274 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
275 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
276 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
277 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
278 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
279 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
280 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
281 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
282 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
283 |
checkAfterExec(); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
284 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
285 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
286 |
InterfaceKind ik; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
287 |
PruneKind pk; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
288 |
Shape sh; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
289 |
QualifierKind qk; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
290 |
ExprKind ek; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
291 |
JavaSource source; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
292 |
DiagnosticChecker diagChecker; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
293 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
294 |
TestDefaultSuperCall(InterfaceKind ik, PruneKind pk, Shape sh, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
295 |
QualifierKind qk, ExprKind ek) { |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
296 |
this.ik = ik; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
297 |
this.pk = pk; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
298 |
this.sh = sh; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
299 |
this.qk = qk; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
300 |
this.ek = ek; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
301 |
this.source = new JavaSource(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
302 |
this.diagChecker = new DiagnosticChecker(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
303 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
304 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
305 |
class JavaSource extends SimpleJavaFileObject { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
306 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
307 |
String template = "interface E {}\n" + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
308 |
"interface B { }\n" + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
309 |
"#I\n" + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
310 |
"#P\n" + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
311 |
"#C"; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
312 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
313 |
String source; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
314 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
315 |
public JavaSource() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
316 |
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
317 |
source = template.replaceAll("#I", ik.interfaceStr) |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
318 |
.replaceAll("#P", pk.interfaceStr) |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
319 |
.replaceAll("#C", sh.getShape(qk, ek)); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
320 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
321 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
322 |
@Override |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
323 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
324 |
return source; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
325 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
326 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
327 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
328 |
public void run() { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
329 |
JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, |
14547 | 330 |
null, null, Arrays.asList(source)); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
331 |
try { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
332 |
ct.analyze(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
333 |
} catch (Throwable ex) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
334 |
processException(ex); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
335 |
return; |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
336 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
337 |
check(); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
338 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
339 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
340 |
void check() { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
341 |
boolean errorExpected = false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
342 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
343 |
boolean badEnclosing = false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
344 |
boolean badThis = false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
345 |
boolean badSuper = false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
346 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
347 |
if (qk == QualifierKind.ENCLOSING_1 && |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
348 |
sh.enclosingNames.size() < 1) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
349 |
errorExpected |= true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
350 |
badEnclosing = true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
351 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
352 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
353 |
if (qk == QualifierKind.ENCLOSING_2 && |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
354 |
sh.enclosingNames.size() < 2) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
355 |
errorExpected |= true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
356 |
badEnclosing = true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
357 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
358 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
359 |
if (ek == ExprKind.THIS) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
360 |
boolean found = false; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
361 |
for (int i = 0; i < sh.enclosingElements.size(); i++) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
362 |
if (sh.enclosingElements.get(i) == ElementKind.ANON_CLASS) continue; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
363 |
if (sh.enclosingNames.get(i).equals(qk.getQualifier(sh))) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
364 |
found = sh.elementsWithMethod.contains(sh.enclosingNames.get(i)); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
365 |
break; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
366 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
367 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
368 |
errorExpected |= !found; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
369 |
if (!found) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
370 |
badThis = true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
371 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
372 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
373 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
374 |
if (ek == ExprKind.SUPER) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
375 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
376 |
int lastIdx = sh.enclosingElements.size() - 1; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
377 |
boolean found = lastIdx == -1 ? false : |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
378 |
sh.enclosingElements.get(lastIdx).hasSuper() && |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
379 |
qk.allowSuperCall(ik, pk); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
380 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
381 |
errorExpected |= !found; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
382 |
if (!found) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
383 |
badSuper = true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
384 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
385 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
386 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
387 |
checkCount.incrementAndGet(); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
388 |
if (diagChecker.errorFound != errorExpected) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
389 |
throw new AssertionError("Problem when compiling source:\n" + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
390 |
source.getCharContent(true) + |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
391 |
"\nenclosingElems: " + sh.enclosingElements + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
392 |
"\nenclosingNames: " + sh.enclosingNames + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
393 |
"\nelementsWithMethod: " + sh.elementsWithMethod + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
394 |
"\nbad encl: " + badEnclosing + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
395 |
"\nbad this: " + badThis + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
396 |
"\nbad super: " + badSuper + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
397 |
"\nqual kind: " + qk + |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
398 |
"\nfound error: " + diagChecker.errorFound); |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
399 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
400 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
401 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
402 |
static class DiagnosticChecker |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
403 |
implements javax.tools.DiagnosticListener<JavaFileObject> { |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
404 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
405 |
boolean errorFound; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
406 |
|
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
407 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
408 |
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
409 |
errWriter.println(diagnostic.getMessage(Locale.getDefault())); |
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
410 |
errorFound = true; |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
411 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
412 |
} |
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
413 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
414 |
|
14443
91c05eb19277
7192246: Add type-checking support for default methods
mcimadamore
parents:
diff
changeset
|
415 |
} |