author | jlahoda |
Fri, 22 Sep 2017 14:06:11 +0200 | |
changeset 47248 | 22d665f53a4a |
parent 47216 | 71c04702a3d5 |
child 47350 | d65c3b21081c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
43137 | 2 |
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.comp; |
|
27 |
||
15385 | 28 |
import java.util.HashSet; |
10 | 29 |
import java.util.Set; |
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
30 |
import java.util.function.BiConsumer; |
15385 | 31 |
|
10 | 32 |
import javax.tools.JavaFileObject; |
33 |
||
34 |
import com.sun.tools.javac.code.*; |
|
27854
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
35 |
import com.sun.tools.javac.code.Lint.LintCategory; |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25007
diff
changeset
|
36 |
import com.sun.tools.javac.code.Scope.ImportFilter; |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25007
diff
changeset
|
37 |
import com.sun.tools.javac.code.Scope.NamedImportScope; |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25007
diff
changeset
|
38 |
import com.sun.tools.javac.code.Scope.StarImportScope; |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25007
diff
changeset
|
39 |
import com.sun.tools.javac.code.Scope.WriteableScope; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
40 |
import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata; |
10 | 41 |
import com.sun.tools.javac.tree.*; |
42 |
import com.sun.tools.javac.util.*; |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
43 |
import com.sun.tools.javac.util.DefinedBy.Api; |
10 | 44 |
|
24895
dd091d389fbf
8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
24604
diff
changeset
|
45 |
import com.sun.tools.javac.code.Symbol.*; |
10 | 46 |
import com.sun.tools.javac.code.Type.*; |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43141
diff
changeset
|
47 |
import com.sun.tools.javac.resources.CompilerProperties.Errors; |
10 | 48 |
import com.sun.tools.javac.tree.JCTree.*; |
49 |
||
50 |
import static com.sun.tools.javac.code.Flags.*; |
|
10950 | 51 |
import static com.sun.tools.javac.code.Flags.ANNOTATION; |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26781
diff
changeset
|
52 |
import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26781
diff
changeset
|
53 |
import static com.sun.tools.javac.code.Kinds.Kind.*; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
54 |
import static com.sun.tools.javac.code.TypeTag.CLASS; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
55 |
import static com.sun.tools.javac.code.TypeTag.ERROR; |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43141
diff
changeset
|
56 |
import com.sun.tools.javac.resources.CompilerProperties.Fragments; |
10950 | 57 |
import static com.sun.tools.javac.tree.JCTree.Tag.*; |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24396
diff
changeset
|
58 |
|
27857 | 59 |
import com.sun.tools.javac.util.Dependencies.CompletionCause; |
11709
0d56d3fc22e6
7129225: javac fails to run annotation processors when star import of package of gensrc
jjh
parents:
10950
diff
changeset
|
60 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; |
10 | 61 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
62 |
||
63 |
/** This is the second phase of Enter, in which classes are completed |
|
27857 | 64 |
* by resolving their headers and entering their members in the into |
65 |
* the class scope. See Enter for an overall overview. |
|
66 |
* |
|
67 |
* This class uses internal phases to process the classes. When a phase |
|
68 |
* processes classes, the lower phases are not invoked until all classes |
|
69 |
* pass through the current phase. Note that it is possible that upper phases |
|
70 |
* are run due to recursive completion. The internal phases are: |
|
71 |
* - ImportPhase: shallow pass through imports, adds information about imports |
|
72 |
* the NamedImportScope and StarImportScope, but avoids queries |
|
73 |
* about class hierarchy. |
|
74 |
* - HierarchyPhase: resolves the supertypes of the given class. Does not handle |
|
75 |
* type parameters of the class or type argument of the supertypes. |
|
76 |
* - HeaderPhase: finishes analysis of the header of the given class by resolving |
|
77 |
* type parameters, attributing supertypes including type arguments |
|
78 |
* and scheduling full annotation attribution. This phase also adds |
|
79 |
* a synthetic default constructor if needed and synthetic "this" field. |
|
80 |
* - MembersPhase: resolves headers for fields, methods and constructors in the given class. |
|
81 |
* Also generates synthetic enum members. |
|
10 | 82 |
* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
83 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
84 |
* If you write code that depends on this, you do so at your own risk. |
10 | 85 |
* This code and its internal interfaces are subject to change or |
86 |
* deletion without notice.</b> |
|
87 |
*/ |
|
27857 | 88 |
public class TypeEnter implements Completer { |
89 |
protected static final Context.Key<TypeEnter> typeEnterKey = new Context.Key<>(); |
|
10 | 90 |
|
91 |
/** A switch to determine whether we check for package/class conflicts |
|
92 |
*/ |
|
93 |
final static boolean checkClash = true; |
|
94 |
||
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1045
diff
changeset
|
95 |
private final Names names; |
10 | 96 |
private final Enter enter; |
27857 | 97 |
private final MemberEnter memberEnter; |
10 | 98 |
private final Log log; |
99 |
private final Check chk; |
|
100 |
private final Attr attr; |
|
101 |
private final Symtab syms; |
|
102 |
private final TreeMaker make; |
|
103 |
private final Todo todo; |
|
104 |
private final Annotate annotate; |
|
26532
aa84b6606229
8056021: checkin for JDK-8027262 breaks Checker Framework
jfranck
parents:
26266
diff
changeset
|
105 |
private final TypeAnnotations typeAnnotations; |
10 | 106 |
private final Types types; |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
939
diff
changeset
|
107 |
private final JCDiagnostic.Factory diags; |
8236
0d8646b7c602
6594914: @SuppressWarnings("deprecation") does not not work for the type of a variable
mcimadamore
parents:
8225
diff
changeset
|
108 |
private final DeferredLintHandler deferredLintHandler; |
19942
e9dae0e41075
8021112: Spurious unchecked warning reported by javac
jlahoda
parents:
19941
diff
changeset
|
109 |
private final Lint lint; |
25007 | 110 |
private final TypeEnvs typeEnvs; |
25844
48eab270456c
8048890: Add option to keep track of symbol completion dependencies
mcimadamore
parents:
25443
diff
changeset
|
111 |
private final Dependencies dependencies; |
10 | 112 |
|
27857 | 113 |
public static TypeEnter instance(Context context) { |
114 |
TypeEnter instance = context.get(typeEnterKey); |
|
10 | 115 |
if (instance == null) |
27857 | 116 |
instance = new TypeEnter(context); |
10 | 117 |
return instance; |
118 |
} |
|
119 |
||
27857 | 120 |
protected TypeEnter(Context context) { |
121 |
context.put(typeEnterKey, this); |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1045
diff
changeset
|
122 |
names = Names.instance(context); |
10 | 123 |
enter = Enter.instance(context); |
27857 | 124 |
memberEnter = MemberEnter.instance(context); |
10 | 125 |
log = Log.instance(context); |
126 |
chk = Check.instance(context); |
|
127 |
attr = Attr.instance(context); |
|
128 |
syms = Symtab.instance(context); |
|
129 |
make = TreeMaker.instance(context); |
|
130 |
todo = Todo.instance(context); |
|
131 |
annotate = Annotate.instance(context); |
|
26532
aa84b6606229
8056021: checkin for JDK-8027262 breaks Checker Framework
jfranck
parents:
26266
diff
changeset
|
132 |
typeAnnotations = TypeAnnotations.instance(context); |
10 | 133 |
types = Types.instance(context); |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
939
diff
changeset
|
134 |
diags = JCDiagnostic.Factory.instance(context); |
8236
0d8646b7c602
6594914: @SuppressWarnings("deprecation") does not not work for the type of a variable
mcimadamore
parents:
8225
diff
changeset
|
135 |
deferredLintHandler = DeferredLintHandler.instance(context); |
19942
e9dae0e41075
8021112: Spurious unchecked warning reported by javac
jlahoda
parents:
19941
diff
changeset
|
136 |
lint = Lint.instance(context); |
25007 | 137 |
typeEnvs = TypeEnvs.instance(context); |
25844
48eab270456c
8048890: Add option to keep track of symbol completion dependencies
mcimadamore
parents:
25443
diff
changeset
|
138 |
dependencies = Dependencies.instance(context); |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
139 |
Source source = Source.instance(context); |
18643
fdd7572e0c18
8016613: javac should avoid source 8 only analysis when compiling for source 7
vromero
parents:
18389
diff
changeset
|
140 |
allowTypeAnnos = source.allowTypeAnnotations(); |
27854
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
141 |
allowDeprecationOnImport = source.allowDeprecationOnImport(); |
10 | 142 |
} |
143 |
||
18643
fdd7572e0c18
8016613: javac should avoid source 8 only analysis when compiling for source 7
vromero
parents:
18389
diff
changeset
|
144 |
/** Switch: support type annotations. |
fdd7572e0c18
8016613: javac should avoid source 8 only analysis when compiling for source 7
vromero
parents:
18389
diff
changeset
|
145 |
*/ |
fdd7572e0c18
8016613: javac should avoid source 8 only analysis when compiling for source 7
vromero
parents:
18389
diff
changeset
|
146 |
boolean allowTypeAnnos; |
fdd7572e0c18
8016613: javac should avoid source 8 only analysis when compiling for source 7
vromero
parents:
18389
diff
changeset
|
147 |
|
27854
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
148 |
/** |
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
149 |
* Switch: should deprecation warnings be issued on import |
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
150 |
*/ |
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
151 |
boolean allowDeprecationOnImport; |
22b4bfc4e22f
8032211: Don't issue deprecation warnings on import statements
jlahoda
parents:
27231
diff
changeset
|
152 |
|
10 | 153 |
/** A flag to disable completion from time to time during member |
154 |
* enter, as we only need to look up types. This avoids |
|
155 |
* unnecessarily deep recursion. |
|
156 |
*/ |
|
157 |
boolean completionEnabled = true; |
|
158 |
||
27857 | 159 |
/* Verify Imports: |
10 | 160 |
*/ |
27857 | 161 |
protected void ensureImportsChecked(List<JCCompilationUnit> trees) { |
162 |
// if there remain any unimported toplevels (these must have |
|
163 |
// no classes at all), process their import statements as well. |
|
164 |
for (JCCompilationUnit tree : trees) { |
|
29149
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
165 |
if (!tree.starImportScope.isFilled()) { |
27857 | 166 |
Env<AttrContext> topEnv = enter.topLevelEnv(tree); |
167 |
finishImports(tree, () -> { completeClass.resolveImports(tree, topEnv); }); |
|
10 | 168 |
} |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
169 |
} |
10 | 170 |
} |
171 |
||
172 |
/* ******************************************************************** |
|
173 |
* Source completer |
|
174 |
*********************************************************************/ |
|
175 |
||
176 |
/** Complete entering a class. |
|
177 |
* @param sym The symbol of the class to be completed. |
|
178 |
*/ |
|
41637 | 179 |
@Override |
10 | 180 |
public void complete(Symbol sym) throws CompletionFailure { |
181 |
// Suppress some (recursive) MemberEnter invocations |
|
182 |
if (!completionEnabled) { |
|
183 |
// Re-install same completer for next time around and return. |
|
8032 | 184 |
Assert.check((sym.flags() & Flags.COMPOUND) == 0); |
10 | 185 |
sym.completer = this; |
186 |
return; |
|
187 |
} |
|
188 |
||
27231
c1ca668b421e
8054448: (ann) Cannot reference field of inner class in an anonymous class
jfranck
parents:
27224
diff
changeset
|
189 |
try { |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
190 |
annotate.blockAnnotations(); |
27857 | 191 |
sym.flags_field |= UNATTRIBUTED; |
1043
11ea4773b0af
6695838: javac does not detect cyclic inheritance involving static inner classes after import clause
mcimadamore
parents:
1040
diff
changeset
|
192 |
|
27857 | 193 |
List<Env<AttrContext>> queue; |
27231
c1ca668b421e
8054448: (ann) Cannot reference field of inner class in an anonymous class
jfranck
parents:
27224
diff
changeset
|
194 |
|
27857 | 195 |
dependencies.push((ClassSymbol) sym, CompletionCause.MEMBER_ENTER); |
196 |
try { |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
197 |
queue = completeClass.completeEnvs(List.of(typeEnvs.get((ClassSymbol) sym))); |
27231
c1ca668b421e
8054448: (ann) Cannot reference field of inner class in an anonymous class
jfranck
parents:
27224
diff
changeset
|
198 |
} finally { |
c1ca668b421e
8054448: (ann) Cannot reference field of inner class in an anonymous class
jfranck
parents:
27224
diff
changeset
|
199 |
dependencies.pop(); |
10 | 200 |
} |
201 |
||
27857 | 202 |
if (!queue.isEmpty()) { |
203 |
Set<JCCompilationUnit> seen = new HashSet<>(); |
|
204 |
||
205 |
for (Env<AttrContext> env : queue) { |
|
206 |
if (env.toplevel.defs.contains(env.enclClass) && seen.add(env.toplevel)) { |
|
207 |
finishImports(env.toplevel, () -> {}); |
|
10 | 208 |
} |
209 |
} |
|
14369
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
210 |
} |
10 | 211 |
} finally { |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
212 |
annotate.unblockAnnotations(); |
15385 | 213 |
} |
214 |
} |
|
10 | 215 |
|
27857 | 216 |
void finishImports(JCCompilationUnit toplevel, Runnable resolve) { |
217 |
JavaFileObject prev = log.useSource(toplevel.sourcefile); |
|
10 | 218 |
try { |
27857 | 219 |
resolve.run(); |
220 |
chk.checkImportsUnique(toplevel); |
|
221 |
chk.checkImportsResolvable(toplevel); |
|
31299
81ce5febcae8
4869999: Error on import statement naming package containing no class files
sadayapalam
parents:
30066
diff
changeset
|
222 |
chk.checkImportedPackagesObservable(toplevel); |
27857 | 223 |
toplevel.namedImportScope.finalizeScope(); |
224 |
toplevel.starImportScope.finalizeScope(); |
|
10 | 225 |
} finally { |
226 |
log.useSource(prev); |
|
227 |
} |
|
228 |
} |
|
229 |
||
27857 | 230 |
abstract class Phase { |
231 |
private final ListBuffer<Env<AttrContext>> queue = new ListBuffer<>(); |
|
232 |
private final Phase next; |
|
233 |
private final CompletionCause phaseName; |
|
234 |
||
235 |
Phase(CompletionCause phaseName, Phase next) { |
|
236 |
this.phaseName = phaseName; |
|
237 |
this.next = next; |
|
238 |
} |
|
239 |
||
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
240 |
public final List<Env<AttrContext>> completeEnvs(List<Env<AttrContext>> envs) { |
27857 | 241 |
boolean firstToComplete = queue.isEmpty(); |
242 |
||
39371
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
243 |
Phase prevTopLevelPhase = topLevelPhase; |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
244 |
|
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
245 |
try { |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
246 |
topLevelPhase = this; |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
247 |
doCompleteEnvs(envs); |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
248 |
} finally { |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
249 |
topLevelPhase = prevTopLevelPhase; |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
250 |
} |
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
251 |
|
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
252 |
if (firstToComplete) { |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
253 |
List<Env<AttrContext>> out = queue.toList(); |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
254 |
|
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
255 |
queue.clear(); |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
256 |
return next != null ? next.completeEnvs(out) : out; |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
257 |
} else { |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
258 |
return List.nil(); |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
259 |
} |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
260 |
} |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
261 |
|
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
262 |
protected void doCompleteEnvs(List<Env<AttrContext>> envs) { |
27857 | 263 |
for (Env<AttrContext> env : envs) { |
264 |
JCClassDecl tree = (JCClassDecl)env.tree; |
|
265 |
||
266 |
queue.add(env); |
|
267 |
||
268 |
JavaFileObject prev = log.useSource(env.toplevel.sourcefile); |
|
269 |
DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); |
|
270 |
try { |
|
271 |
dependencies.push(env.enclClass.sym, phaseName); |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
272 |
runPhase(env); |
27857 | 273 |
} catch (CompletionFailure ex) { |
274 |
chk.completionError(tree.pos(), ex); |
|
275 |
} finally { |
|
276 |
dependencies.pop(); |
|
277 |
deferredLintHandler.setPos(prevLintPos); |
|
278 |
log.useSource(prev); |
|
279 |
} |
|
280 |
} |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
281 |
} |
27857 | 282 |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
283 |
protected abstract void runPhase(Env<AttrContext> env); |
10 | 284 |
} |
285 |
||
27857 | 286 |
private final ImportsPhase completeClass = new ImportsPhase(); |
39371
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
287 |
private Phase topLevelPhase; |
27857 | 288 |
|
289 |
/**Analyze import clauses. |
|
290 |
*/ |
|
291 |
private final class ImportsPhase extends Phase { |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
292 |
|
27857 | 293 |
public ImportsPhase() { |
294 |
super(CompletionCause.IMPORTS_PHASE, new HierarchyPhase()); |
|
295 |
} |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
296 |
|
27857 | 297 |
Env<AttrContext> env; |
298 |
ImportFilter staticImportFilter; |
|
29149
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
299 |
ImportFilter typeImportFilter; |
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
300 |
BiConsumer<JCImport, CompletionFailure> cfHandler = |
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
301 |
(imp, cf) -> chk.completionError(imp.pos(), cf); |
27857 | 302 |
|
303 |
@Override |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
304 |
protected void runPhase(Env<AttrContext> env) { |
27857 | 305 |
JCClassDecl tree = env.enclClass; |
306 |
ClassSymbol sym = tree.sym; |
|
307 |
||
308 |
// If sym is a toplevel-class, make sure any import |
|
309 |
// clauses in its source file have been seen. |
|
310 |
if (sym.owner.kind == PCK) { |
|
311 |
resolveImports(env.toplevel, env.enclosing(TOPLEVEL)); |
|
312 |
todo.append(env); |
|
313 |
} |
|
314 |
||
315 |
if (sym.owner.kind == TYP) |
|
316 |
sym.owner.complete(); |
|
317 |
} |
|
318 |
||
319 |
private void resolveImports(JCCompilationUnit tree, Env<AttrContext> env) { |
|
29149
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
320 |
if (tree.starImportScope.isFilled()) { |
27857 | 321 |
// we must have already processed this toplevel |
322 |
return; |
|
323 |
} |
|
324 |
||
325 |
ImportFilter prevStaticImportFilter = staticImportFilter; |
|
29149
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
326 |
ImportFilter prevTypeImportFilter = typeImportFilter; |
27857 | 327 |
DiagnosticPosition prevLintPos = deferredLintHandler.immediate(); |
328 |
Lint prevLint = chk.setLint(lint); |
|
329 |
Env<AttrContext> prevEnv = this.env; |
|
330 |
try { |
|
331 |
this.env = env; |
|
332 |
final PackageSymbol packge = env.toplevel.packge; |
|
29149
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
333 |
this.staticImportFilter = |
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
334 |
(origin, sym) -> sym.isStatic() && |
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
335 |
chk.importAccessible(sym, packge) && |
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
336 |
sym.isMemberOf((TypeSymbol) origin.owner, types); |
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
337 |
this.typeImportFilter = |
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
338 |
(origin, sym) -> sym.kind == TYP && |
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
339 |
chk.importAccessible(sym, packge); |
27857 | 340 |
|
341 |
// Import-on-demand java.lang. |
|
36526 | 342 |
PackageSymbol javaLang = syms.enterPackage(syms.java_base, names.java_lang); |
31299
81ce5febcae8
4869999: Error on import statement naming package containing no class files
sadayapalam
parents:
30066
diff
changeset
|
343 |
if (javaLang.members().isEmpty() && !javaLang.exists()) |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43141
diff
changeset
|
344 |
throw new FatalError(diags.fragment(Fragments.FatalErrNoJavaLang)); |
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
345 |
importAll(make.at(tree.pos()).Import(make.QualIdent(javaLang), false), javaLang, env); |
27857 | 346 |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
347 |
JCModuleDecl decl = tree.getModuleDecl(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
348 |
|
27857 | 349 |
// Process the package def and all import clauses. |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
350 |
if (tree.getPackage() != null && decl == null) |
27857 | 351 |
checkClassPackageClash(tree.getPackage()); |
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
352 |
|
27857 | 353 |
for (JCImport imp : tree.getImports()) { |
354 |
doImport(imp); |
|
355 |
} |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
356 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
357 |
if (decl != null) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
358 |
//check @Deprecated: |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
359 |
markDeprecated(decl.sym, decl.mods.annotations, env); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
360 |
// process module annotations |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
361 |
annotate.annotateLater(decl.mods.annotations, env, env.toplevel.modle, null); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
362 |
} |
27857 | 363 |
} finally { |
364 |
this.env = prevEnv; |
|
365 |
chk.setLint(prevLint); |
|
366 |
deferredLintHandler.setPos(prevLintPos); |
|
367 |
this.staticImportFilter = prevStaticImportFilter; |
|
29149
3fa94aad0264
8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
27857
diff
changeset
|
368 |
this.typeImportFilter = prevTypeImportFilter; |
27857 | 369 |
} |
370 |
} |
|
371 |
||
372 |
private void checkClassPackageClash(JCPackageDecl tree) { |
|
373 |
// check that no class exists with same fully qualified name as |
|
374 |
// toplevel package |
|
375 |
if (checkClash && tree.pid != null) { |
|
376 |
Symbol p = env.toplevel.packge; |
|
377 |
while (p.owner != syms.rootPackage) { |
|
378 |
p.owner.complete(); // enter all class members of p |
|
36526 | 379 |
//need to lookup the owning module/package: |
380 |
PackageSymbol pack = syms.lookupPackage(env.toplevel.modle, p.owner.getQualifiedName()); |
|
381 |
if (syms.getClass(pack.modle, p.getQualifiedName()) != null) { |
|
27857 | 382 |
log.error(tree.pos, |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43141
diff
changeset
|
383 |
Errors.PkgClashesWithClassOfSameName(p)); |
27857 | 384 |
} |
385 |
p = p.owner; |
|
386 |
} |
|
387 |
} |
|
388 |
// process package annotations |
|
389 |
annotate.annotateLater(tree.annotations, env, env.toplevel.packge, null); |
|
390 |
} |
|
391 |
||
392 |
private void doImport(JCImport tree) { |
|
393 |
JCFieldAccess imp = (JCFieldAccess)tree.qualid; |
|
394 |
Name name = TreeInfo.name(imp); |
|
395 |
||
396 |
// Create a local environment pointing to this tree to disable |
|
397 |
// effects of other imports in Resolve.findGlobalType |
|
398 |
Env<AttrContext> localEnv = env.dup(tree); |
|
399 |
||
400 |
TypeSymbol p = attr.attribImportQualifier(tree, localEnv).tsym; |
|
401 |
if (name == names.asterisk) { |
|
402 |
// Import on demand. |
|
403 |
chk.checkCanonical(imp.selected); |
|
404 |
if (tree.staticImport) |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
405 |
importStaticAll(tree, p, env); |
27857 | 406 |
else |
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
407 |
importAll(tree, p, env); |
27857 | 408 |
} else { |
409 |
// Named type import. |
|
410 |
if (tree.staticImport) { |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
411 |
importNamedStatic(tree, p, name, localEnv); |
27857 | 412 |
chk.checkCanonical(imp.selected); |
413 |
} else { |
|
43141
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
414 |
Type importedType = attribImportType(imp, localEnv); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
415 |
Type originalType = importedType.getOriginalType(); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
416 |
TypeSymbol c = originalType.hasTag(CLASS) ? originalType.tsym : importedType.tsym; |
27857 | 417 |
chk.checkCanonical(imp); |
418 |
importNamed(tree.pos(), c, env, tree); |
|
419 |
} |
|
420 |
} |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
421 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
422 |
|
27857 | 423 |
Type attribImportType(JCTree tree, Env<AttrContext> env) { |
424 |
Assert.check(completionEnabled); |
|
425 |
Lint prevLint = chk.setLint(allowDeprecationOnImport ? |
|
41637 | 426 |
lint : lint.suppress(LintCategory.DEPRECATION, LintCategory.REMOVAL)); |
27857 | 427 |
try { |
428 |
// To prevent deep recursion, suppress completion of some |
|
429 |
// types. |
|
430 |
completionEnabled = false; |
|
431 |
return attr.attribType(tree, env); |
|
432 |
} finally { |
|
433 |
completionEnabled = true; |
|
434 |
chk.setLint(prevLint); |
|
435 |
} |
|
436 |
} |
|
437 |
||
438 |
/** Import all classes of a class or package on demand. |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
439 |
* @param imp The import that is being handled. |
27857 | 440 |
* @param tsym The class or package the members of which are imported. |
441 |
* @param env The env in which the imported classes will be entered. |
|
442 |
*/ |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
443 |
private void importAll(JCImport imp, |
27857 | 444 |
final TypeSymbol tsym, |
445 |
Env<AttrContext> env) { |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
446 |
env.toplevel.starImportScope.importAll(types, tsym.members(), typeImportFilter, imp, cfHandler); |
27857 | 447 |
} |
448 |
||
449 |
/** Import all static members of a class or package on demand. |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
450 |
* @param imp The import that is being handled. |
27857 | 451 |
* @param tsym The class or package the members of which are imported. |
452 |
* @param env The env in which the imported classes will be entered. |
|
453 |
*/ |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
454 |
private void importStaticAll(JCImport imp, |
27857 | 455 |
final TypeSymbol tsym, |
456 |
Env<AttrContext> env) { |
|
457 |
final StarImportScope toScope = env.toplevel.starImportScope; |
|
458 |
final TypeSymbol origin = tsym; |
|
459 |
||
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
460 |
toScope.importAll(types, origin.members(), staticImportFilter, imp, cfHandler); |
27857 | 461 |
} |
462 |
||
463 |
/** Import statics types of a given name. Non-types are handled in Attr. |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
464 |
* @param imp The import that is being handled. |
27857 | 465 |
* @param tsym The class from which the name is imported. |
466 |
* @param name The (simple) name being imported. |
|
467 |
* @param env The environment containing the named import |
|
468 |
* scope to add to. |
|
469 |
*/ |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
470 |
private void importNamedStatic(final JCImport imp, |
27857 | 471 |
final TypeSymbol tsym, |
472 |
final Name name, |
|
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
473 |
final Env<AttrContext> env) { |
27857 | 474 |
if (tsym.kind != TYP) { |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43141
diff
changeset
|
475 |
log.error(DiagnosticFlag.RECOVERABLE, imp.pos(), Errors.StaticImpOnlyClassesAndInterfaces); |
27857 | 476 |
return; |
477 |
} |
|
478 |
||
479 |
final NamedImportScope toScope = env.toplevel.namedImportScope; |
|
480 |
final Scope originMembers = tsym.members(); |
|
481 |
||
32059
ea04f56aeacd
8131915: CompletionFailure during import listing crashes javac
jlahoda
parents:
31299
diff
changeset
|
482 |
imp.importScope = toScope.importByName(types, originMembers, name, staticImportFilter, imp, cfHandler); |
27857 | 483 |
} |
484 |
||
485 |
/** Import given class. |
|
486 |
* @param pos Position to be used for error reporting. |
|
487 |
* @param tsym The class to be imported. |
|
488 |
* @param env The environment containing the named import |
|
489 |
* scope to add to. |
|
490 |
*/ |
|
491 |
private void importNamed(DiagnosticPosition pos, final Symbol tsym, Env<AttrContext> env, JCImport imp) { |
|
492 |
if (tsym.kind == TYP) |
|
493 |
imp.importScope = env.toplevel.namedImportScope.importType(tsym.owner.members(), tsym.owner.members(), tsym); |
|
494 |
} |
|
495 |
||
496 |
} |
|
497 |
||
498 |
/**Defines common utility methods used by the HierarchyPhase and HeaderPhase. |
|
499 |
*/ |
|
500 |
private abstract class AbstractHeaderPhase extends Phase { |
|
501 |
||
502 |
public AbstractHeaderPhase(CompletionCause phaseName, Phase next) { |
|
503 |
super(phaseName, next); |
|
504 |
} |
|
505 |
||
506 |
protected Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) { |
|
507 |
WriteableScope baseScope = WriteableScope.create(tree.sym); |
|
508 |
//import already entered local classes into base scope |
|
509 |
for (Symbol sym : env.outer.info.scope.getSymbols(NON_RECURSIVE)) { |
|
510 |
if (sym.isLocal()) { |
|
511 |
baseScope.enter(sym); |
|
512 |
} |
|
513 |
} |
|
514 |
//import current type-parameters into base scope |
|
515 |
if (tree.typarams != null) |
|
516 |
for (List<JCTypeParameter> typarams = tree.typarams; |
|
517 |
typarams.nonEmpty(); |
|
518 |
typarams = typarams.tail) |
|
519 |
baseScope.enter(typarams.head.type.tsym); |
|
520 |
Env<AttrContext> outer = env.outer; // the base clause can't see members of this class |
|
521 |
Env<AttrContext> localEnv = outer.dup(tree, outer.info.dup(baseScope)); |
|
522 |
localEnv.baseClause = true; |
|
523 |
localEnv.outer = outer; |
|
524 |
localEnv.info.isSelfCall = false; |
|
525 |
return localEnv; |
|
526 |
} |
|
527 |
||
528 |
/** Generate a base clause for an enum type. |
|
529 |
* @param pos The position for trees and diagnostics, if any |
|
530 |
* @param c The class symbol of the enum |
|
531 |
*/ |
|
532 |
protected JCExpression enumBase(int pos, ClassSymbol c) { |
|
533 |
JCExpression result = make.at(pos). |
|
534 |
TypeApply(make.QualIdent(syms.enumSym), |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
535 |
List.of(make.Type(c.type))); |
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
536 |
return result; |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
537 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
538 |
|
36526 | 539 |
protected Type modelMissingTypes(Env<AttrContext> env, Type t, final JCExpression tree, final boolean interfaceExpected) { |
27857 | 540 |
if (!t.hasTag(ERROR)) |
541 |
return t; |
|
542 |
||
543 |
return new ErrorType(t.getOriginalType(), t.tsym) { |
|
544 |
private Type modelType; |
|
545 |
||
546 |
@Override |
|
547 |
public Type getModelType() { |
|
548 |
if (modelType == null) |
|
36526 | 549 |
modelType = new Synthesizer(env.toplevel.modle, getOriginalType(), interfaceExpected).visit(tree); |
27857 | 550 |
return modelType; |
551 |
} |
|
552 |
}; |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
553 |
} |
27857 | 554 |
// where: |
555 |
private class Synthesizer extends JCTree.Visitor { |
|
36526 | 556 |
ModuleSymbol msym; |
27857 | 557 |
Type originalType; |
558 |
boolean interfaceExpected; |
|
559 |
List<ClassSymbol> synthesizedSymbols = List.nil(); |
|
560 |
Type result; |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
561 |
|
36526 | 562 |
Synthesizer(ModuleSymbol msym, Type originalType, boolean interfaceExpected) { |
563 |
this.msym = msym; |
|
27857 | 564 |
this.originalType = originalType; |
565 |
this.interfaceExpected = interfaceExpected; |
|
566 |
} |
|
567 |
||
568 |
Type visit(JCTree tree) { |
|
569 |
tree.accept(this); |
|
570 |
return result; |
|
571 |
} |
|
572 |
||
573 |
List<Type> visit(List<? extends JCTree> trees) { |
|
574 |
ListBuffer<Type> lb = new ListBuffer<>(); |
|
575 |
for (JCTree t: trees) |
|
576 |
lb.append(visit(t)); |
|
577 |
return lb.toList(); |
|
578 |
} |
|
579 |
||
580 |
@Override |
|
581 |
public void visitTree(JCTree tree) { |
|
582 |
result = syms.errType; |
|
583 |
} |
|
584 |
||
585 |
@Override |
|
586 |
public void visitIdent(JCIdent tree) { |
|
587 |
if (!tree.type.hasTag(ERROR)) { |
|
588 |
result = tree.type; |
|
589 |
} else { |
|
36526 | 590 |
result = synthesizeClass(tree.name, msym.unnamedPackage).type; |
27857 | 591 |
} |
592 |
} |
|
593 |
||
594 |
@Override |
|
595 |
public void visitSelect(JCFieldAccess tree) { |
|
596 |
if (!tree.type.hasTag(ERROR)) { |
|
597 |
result = tree.type; |
|
598 |
} else { |
|
599 |
Type selectedType; |
|
600 |
boolean prev = interfaceExpected; |
|
601 |
try { |
|
602 |
interfaceExpected = false; |
|
603 |
selectedType = visit(tree.selected); |
|
604 |
} finally { |
|
605 |
interfaceExpected = prev; |
|
606 |
} |
|
607 |
ClassSymbol c = synthesizeClass(tree.name, selectedType.tsym); |
|
608 |
result = c.type; |
|
609 |
} |
|
610 |
} |
|
611 |
||
612 |
@Override |
|
613 |
public void visitTypeApply(JCTypeApply tree) { |
|
614 |
if (!tree.type.hasTag(ERROR)) { |
|
615 |
result = tree.type; |
|
616 |
} else { |
|
617 |
ClassType clazzType = (ClassType) visit(tree.clazz); |
|
618 |
if (synthesizedSymbols.contains(clazzType.tsym)) |
|
619 |
synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size()); |
|
620 |
final List<Type> actuals = visit(tree.arguments); |
|
621 |
result = new ErrorType(tree.type, clazzType.tsym) { |
|
622 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
|
623 |
public List<Type> getTypeArguments() { |
|
624 |
return actuals; |
|
625 |
} |
|
626 |
}; |
|
627 |
} |
|
628 |
} |
|
629 |
||
630 |
ClassSymbol synthesizeClass(Name name, Symbol owner) { |
|
631 |
int flags = interfaceExpected ? INTERFACE : 0; |
|
632 |
ClassSymbol c = new ClassSymbol(flags, name, owner); |
|
633 |
c.members_field = new Scope.ErrorScope(c); |
|
634 |
c.type = new ErrorType(originalType, c) { |
|
635 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
|
636 |
public List<Type> getTypeArguments() { |
|
637 |
return typarams_field; |
|
638 |
} |
|
639 |
}; |
|
640 |
synthesizedSymbols = synthesizedSymbols.prepend(c); |
|
641 |
return c; |
|
642 |
} |
|
643 |
||
644 |
void synthesizeTyparams(ClassSymbol sym, int n) { |
|
645 |
ClassType ct = (ClassType) sym.type; |
|
646 |
Assert.check(ct.typarams_field.isEmpty()); |
|
647 |
if (n == 1) { |
|
648 |
TypeVar v = new TypeVar(names.fromString("T"), sym, syms.botType); |
|
649 |
ct.typarams_field = ct.typarams_field.prepend(v); |
|
650 |
} else { |
|
651 |
for (int i = n; i > 0; i--) { |
|
652 |
TypeVar v = new TypeVar(names.fromString("T" + i), sym, |
|
653 |
syms.botType); |
|
654 |
ct.typarams_field = ct.typarams_field.prepend(v); |
|
655 |
} |
|
656 |
} |
|
657 |
} |
|
658 |
} |
|
659 |
||
660 |
protected void attribSuperTypes(Env<AttrContext> env, Env<AttrContext> baseEnv) { |
|
661 |
JCClassDecl tree = env.enclClass; |
|
662 |
ClassSymbol sym = tree.sym; |
|
663 |
ClassType ct = (ClassType)sym.type; |
|
664 |
// Determine supertype. |
|
665 |
Type supertype; |
|
666 |
JCExpression extending; |
|
667 |
||
668 |
if (tree.extending != null) { |
|
669 |
extending = clearTypeParams(tree.extending); |
|
33366
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
670 |
supertype = attr.attribBase(extending, baseEnv, true, false, true); |
27857 | 671 |
} else { |
672 |
extending = null; |
|
673 |
supertype = ((tree.mods.flags & Flags.ENUM) != 0) |
|
674 |
? attr.attribBase(enumBase(tree.pos, sym), baseEnv, |
|
675 |
true, false, false) |
|
676 |
: (sym.fullname == names.java_lang_Object) |
|
677 |
? Type.noType |
|
678 |
: syms.objectType; |
|
679 |
} |
|
36526 | 680 |
ct.supertype_field = modelMissingTypes(baseEnv, supertype, extending, false); |
27857 | 681 |
|
682 |
// Determine interfaces. |
|
683 |
ListBuffer<Type> interfaces = new ListBuffer<>(); |
|
684 |
ListBuffer<Type> all_interfaces = null; // lazy init |
|
685 |
List<JCExpression> interfaceTrees = tree.implementing; |
|
686 |
for (JCExpression iface : interfaceTrees) { |
|
687 |
iface = clearTypeParams(iface); |
|
33366
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
688 |
Type it = attr.attribBase(iface, baseEnv, false, true, true); |
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
689 |
if (it.hasTag(CLASS)) { |
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
690 |
interfaces.append(it); |
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
691 |
if (all_interfaces != null) all_interfaces.append(it); |
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
692 |
} else { |
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
693 |
if (all_interfaces == null) |
a113e08cc061
8087349: Test tools/sjavac/IncCompInheritance.java is failing
alundblad
parents:
32913
diff
changeset
|
694 |
all_interfaces = new ListBuffer<Type>().appendList(interfaces); |
36526 | 695 |
all_interfaces.append(modelMissingTypes(baseEnv, it, iface, true)); |
27857 | 696 |
} |
697 |
} |
|
698 |
||
699 |
if ((sym.flags_field & ANNOTATION) != 0) { |
|
700 |
ct.interfaces_field = List.of(syms.annotationType); |
|
701 |
ct.all_interfaces_field = ct.interfaces_field; |
|
702 |
} else { |
|
703 |
ct.interfaces_field = interfaces.toList(); |
|
704 |
ct.all_interfaces_field = (all_interfaces == null) |
|
705 |
? ct.interfaces_field : all_interfaces.toList(); |
|
706 |
} |
|
707 |
} |
|
708 |
//where: |
|
709 |
protected JCExpression clearTypeParams(JCExpression superType) { |
|
710 |
return superType; |
|
711 |
} |
|
712 |
} |
|
713 |
||
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
714 |
private final class HierarchyPhase extends AbstractHeaderPhase implements Completer { |
27857 | 715 |
|
716 |
public HierarchyPhase() { |
|
717 |
super(CompletionCause.HIERARCHY_PHASE, new HeaderPhase()); |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
718 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
719 |
|
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
720 |
@Override |
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
721 |
protected void doCompleteEnvs(List<Env<AttrContext>> envs) { |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
722 |
//The ClassSymbols in the envs list may not be in the dependency order. |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
723 |
//To get proper results, for every class or interface C, the supertypes of |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
724 |
//C must be processed by the HierarchyPhase phase before C. |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
725 |
//To achieve that, the HierarchyPhase is registered as the Completer for |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
726 |
//all the classes first, and then all the classes are completed. |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
727 |
for (Env<AttrContext> env : envs) { |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
728 |
env.enclClass.sym.completer = this; |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
729 |
} |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
730 |
for (Env<AttrContext> env : envs) { |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
731 |
env.enclClass.sym.complete(); |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
732 |
} |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
733 |
} |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
734 |
|
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
735 |
@Override |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
736 |
protected void runPhase(Env<AttrContext> env) { |
27857 | 737 |
JCClassDecl tree = env.enclClass; |
738 |
ClassSymbol sym = tree.sym; |
|
739 |
ClassType ct = (ClassType)sym.type; |
|
740 |
||
741 |
Env<AttrContext> baseEnv = baseEnv(tree, env); |
|
742 |
||
743 |
attribSuperTypes(env, baseEnv); |
|
744 |
||
745 |
if (sym.fullname == names.java_lang_Object) { |
|
746 |
if (tree.extending != null) { |
|
747 |
chk.checkNonCyclic(tree.extending.pos(), |
|
748 |
ct.supertype_field); |
|
749 |
ct.supertype_field = Type.noType; |
|
750 |
} |
|
751 |
else if (tree.implementing.nonEmpty()) { |
|
752 |
chk.checkNonCyclic(tree.implementing.head.pos(), |
|
753 |
ct.interfaces_field.head); |
|
754 |
ct.interfaces_field = List.nil(); |
|
755 |
} |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
756 |
} |
27857 | 757 |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
758 |
markDeprecated(sym, tree.mods.annotations, baseEnv); |
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
759 |
|
27857 | 760 |
chk.checkNonCyclicDecl(tree); |
761 |
} |
|
762 |
//where: |
|
41637 | 763 |
@Override |
27857 | 764 |
protected JCExpression clearTypeParams(JCExpression superType) { |
765 |
switch (superType.getTag()) { |
|
766 |
case TYPEAPPLY: |
|
767 |
return ((JCTypeApply) superType).clazz; |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
768 |
} |
27857 | 769 |
|
770 |
return superType; |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
771 |
} |
27857 | 772 |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
773 |
@Override |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
774 |
public void complete(Symbol sym) throws CompletionFailure { |
39371
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
775 |
Assert.check((topLevelPhase instanceof ImportsPhase) || |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
776 |
(topLevelPhase == this)); |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
777 |
|
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
778 |
if (topLevelPhase != this) { |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
779 |
//only do the processing based on dependencies in the HierarchyPhase: |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
780 |
sym.completer = this; |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
781 |
return ; |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
782 |
} |
ac04aefa4ba6
8148131: compilation result depends on order of sources
jlahoda
parents:
37942
diff
changeset
|
783 |
|
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
784 |
Env<AttrContext> env = typeEnvs.get((ClassSymbol) sym); |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
785 |
|
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
786 |
super.doCompleteEnvs(List.of(env)); |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
787 |
} |
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
788 |
|
27857 | 789 |
} |
790 |
||
791 |
private final class HeaderPhase extends AbstractHeaderPhase { |
|
792 |
||
793 |
public HeaderPhase() { |
|
794 |
super(CompletionCause.HEADER_PHASE, new MembersPhase()); |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
795 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
796 |
|
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
797 |
@Override |
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
798 |
protected void runPhase(Env<AttrContext> env) { |
27857 | 799 |
JCClassDecl tree = env.enclClass; |
800 |
ClassSymbol sym = tree.sym; |
|
801 |
ClassType ct = (ClassType)sym.type; |
|
802 |
||
803 |
// create an environment for evaluating the base clauses |
|
804 |
Env<AttrContext> baseEnv = baseEnv(tree, env); |
|
805 |
||
806 |
if (tree.extending != null) |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
807 |
annotate.queueScanTreeAndTypeAnnotate(tree.extending, baseEnv, sym, tree.pos()); |
27857 | 808 |
for (JCExpression impl : tree.implementing) |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
809 |
annotate.queueScanTreeAndTypeAnnotate(impl, baseEnv, sym, tree.pos()); |
27857 | 810 |
annotate.flush(); |
811 |
||
812 |
attribSuperTypes(env, baseEnv); |
|
813 |
||
814 |
Set<Type> interfaceSet = new HashSet<>(); |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
815 |
|
27857 | 816 |
for (JCExpression iface : tree.implementing) { |
817 |
Type it = iface.type; |
|
818 |
if (it.hasTag(CLASS)) |
|
819 |
chk.checkNotRepeated(iface.pos(), types.erasure(it), interfaceSet); |
|
820 |
} |
|
821 |
||
822 |
annotate.annotateLater(tree.mods.annotations, baseEnv, |
|
823 |
sym, tree.pos()); |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
824 |
|
27857 | 825 |
attr.attribTypeVariables(tree.typarams, baseEnv); |
826 |
for (JCTypeParameter tp : tree.typarams) |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
827 |
annotate.queueScanTreeAndTypeAnnotate(tp, baseEnv, sym, tree.pos()); |
27857 | 828 |
|
829 |
// check that no package exists with same fully qualified name, |
|
830 |
// but admit classes in the unnamed package which have the same |
|
831 |
// name as a top-level package. |
|
832 |
if (checkClash && |
|
36526 | 833 |
sym.owner.kind == PCK && sym.owner != env.toplevel.modle.unnamedPackage && |
834 |
syms.packageExists(env.toplevel.modle, sym.fullname)) { |
|
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43141
diff
changeset
|
835 |
log.error(tree.pos, Errors.ClashWithPkgOfSameName(Kinds.kindName(sym),sym)); |
27857 | 836 |
} |
837 |
if (sym.owner.kind == PCK && (sym.flags_field & PUBLIC) == 0 && |
|
838 |
!env.toplevel.sourcefile.isNameCompatible(sym.name.toString(),JavaFileObject.Kind.SOURCE)) { |
|
839 |
sym.flags_field |= AUXILIARY; |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
840 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
841 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
842 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
843 |
|
27857 | 844 |
/** Enter member fields and methods of a class |
845 |
*/ |
|
846 |
private final class MembersPhase extends Phase { |
|
847 |
||
848 |
public MembersPhase() { |
|
849 |
super(CompletionCause.MEMBERS_PHASE, null); |
|
850 |
} |
|
851 |
||
37942
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
852 |
private boolean completing; |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
853 |
private List<Env<AttrContext>> todo = List.nil(); |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
854 |
|
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
855 |
@Override |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
856 |
protected void doCompleteEnvs(List<Env<AttrContext>> envs) { |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
857 |
todo = todo.prependList(envs); |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
858 |
if (completing) { |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
859 |
return ; //the top-level invocation will handle all envs |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
860 |
} |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
861 |
boolean prevCompleting = completing; |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
862 |
completing = true; |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
863 |
try { |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
864 |
while (todo.nonEmpty()) { |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
865 |
Env<AttrContext> head = todo.head; |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
866 |
todo = todo.tail; |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
867 |
super.doCompleteEnvs(List.of(head)); |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
868 |
} |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
869 |
} finally { |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
870 |
completing = prevCompleting; |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
871 |
} |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
872 |
} |
b0e834553947
8156097: docs build fails with StackOverflowError on Solaris
jlahoda
parents:
36526
diff
changeset
|
873 |
|
27857 | 874 |
@Override |
32913
586e23a1b116
8075274: Compilation still depends on the order of imports
jlahoda
parents:
32059
diff
changeset
|
875 |
protected void runPhase(Env<AttrContext> env) { |
27857 | 876 |
JCClassDecl tree = env.enclClass; |
877 |
ClassSymbol sym = tree.sym; |
|
878 |
ClassType ct = (ClassType)sym.type; |
|
879 |
||
880 |
// Add default constructor if needed. |
|
881 |
if ((sym.flags() & INTERFACE) == 0 && |
|
882 |
!TreeInfo.hasConstructors(tree.defs)) { |
|
883 |
List<Type> argtypes = List.nil(); |
|
884 |
List<Type> typarams = List.nil(); |
|
885 |
List<Type> thrown = List.nil(); |
|
886 |
long ctorFlags = 0; |
|
887 |
boolean based = false; |
|
888 |
boolean addConstructor = true; |
|
889 |
JCNewClass nc = null; |
|
890 |
if (sym.name.isEmpty()) { |
|
891 |
nc = (JCNewClass)env.next.tree; |
|
892 |
if (nc.constructor != null) { |
|
893 |
addConstructor = nc.constructor.kind != ERR; |
|
894 |
Type superConstrType = types.memberType(sym.type, |
|
895 |
nc.constructor); |
|
896 |
argtypes = superConstrType.getParameterTypes(); |
|
897 |
typarams = superConstrType.getTypeArguments(); |
|
898 |
ctorFlags = nc.constructor.flags() & VARARGS; |
|
899 |
if (nc.encl != null) { |
|
900 |
argtypes = argtypes.prepend(nc.encl.type); |
|
901 |
based = true; |
|
902 |
} |
|
903 |
thrown = superConstrType.getThrownTypes(); |
|
904 |
} |
|
905 |
} |
|
906 |
if (addConstructor) { |
|
907 |
MethodSymbol basedConstructor = nc != null ? |
|
908 |
(MethodSymbol)nc.constructor : null; |
|
909 |
JCTree constrDef = DefaultConstructor(make.at(tree.pos), sym, |
|
910 |
basedConstructor, |
|
911 |
typarams, argtypes, thrown, |
|
912 |
ctorFlags, based); |
|
913 |
tree.defs = tree.defs.prepend(constrDef); |
|
914 |
} |
|
915 |
} |
|
916 |
||
917 |
// enter symbols for 'this' into current scope. |
|
918 |
VarSymbol thisSym = |
|
919 |
new VarSymbol(FINAL | HASINIT, names._this, sym.type, sym); |
|
920 |
thisSym.pos = Position.FIRSTPOS; |
|
921 |
env.info.scope.enter(thisSym); |
|
922 |
// if this is a class, enter symbol for 'super' into current scope. |
|
923 |
if ((sym.flags_field & INTERFACE) == 0 && |
|
924 |
ct.supertype_field.hasTag(CLASS)) { |
|
925 |
VarSymbol superSym = |
|
926 |
new VarSymbol(FINAL | HASINIT, names._super, |
|
927 |
ct.supertype_field, sym); |
|
928 |
superSym.pos = Position.FIRSTPOS; |
|
929 |
env.info.scope.enter(superSym); |
|
930 |
} |
|
931 |
||
932 |
finishClass(tree, env); |
|
933 |
||
934 |
if (allowTypeAnnos) { |
|
935 |
typeAnnotations.organizeTypeAnnotationsSignatures(env, (JCClassDecl)env.tree); |
|
936 |
typeAnnotations.validateTypeAnnotationsSignatures(env, (JCClassDecl)env.tree); |
|
937 |
} |
|
938 |
} |
|
939 |
||
940 |
/** Enter members for a class. |
|
941 |
*/ |
|
942 |
void finishClass(JCClassDecl tree, Env<AttrContext> env) { |
|
943 |
if ((tree.mods.flags & Flags.ENUM) != 0 && |
|
43137 | 944 |
!tree.sym.type.hasTag(ERROR) && |
27857 | 945 |
(types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) { |
946 |
addEnumMembers(tree, env); |
|
947 |
} |
|
948 |
memberEnter.memberEnter(tree.defs, env); |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
949 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
950 |
if (tree.sym.isAnnotationType()) { |
30066
d74c06a92bd8
8078600: Infinite loop when compiling annotations with -XDcompletionDeps
alundblad
parents:
29842
diff
changeset
|
951 |
Assert.check(tree.sym.isCompleted()); |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
952 |
tree.sym.setAnnotationTypeMetadata(new AnnotationTypeMetadata(tree.sym, annotate.annotationTypeSourceCompleter())); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29149
diff
changeset
|
953 |
} |
27857 | 954 |
} |
955 |
||
956 |
/** Add the implicit members for an enum type |
|
957 |
* to the symbol table. |
|
958 |
*/ |
|
959 |
private void addEnumMembers(JCClassDecl tree, Env<AttrContext> env) { |
|
960 |
JCExpression valuesType = make.Type(new ArrayType(tree.sym.type, syms.arrayClass)); |
|
961 |
||
962 |
// public static T[] values() { return ???; } |
|
963 |
JCMethodDecl values = make. |
|
964 |
MethodDef(make.Modifiers(Flags.PUBLIC|Flags.STATIC), |
|
965 |
names.values, |
|
966 |
valuesType, |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
967 |
List.nil(), |
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
968 |
List.nil(), |
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
969 |
List.nil(), // thrown |
27857 | 970 |
null, //make.Block(0, Tree.emptyList.prepend(make.Return(make.Ident(names._null)))), |
971 |
null); |
|
972 |
memberEnter.memberEnter(values, env); |
|
973 |
||
974 |
// public static T valueOf(String name) { return ???; } |
|
975 |
JCMethodDecl valueOf = make. |
|
976 |
MethodDef(make.Modifiers(Flags.PUBLIC|Flags.STATIC), |
|
977 |
names.valueOf, |
|
978 |
make.Type(tree.sym.type), |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
979 |
List.nil(), |
27857 | 980 |
List.of(make.VarDef(make.Modifiers(Flags.PARAMETER | |
981 |
Flags.MANDATED), |
|
982 |
names.fromString("name"), |
|
983 |
make.Type(syms.stringType), null)), |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
984 |
List.nil(), // thrown |
27857 | 985 |
null, //make.Block(0, Tree.emptyList.prepend(make.Return(make.Ident(names._null)))), |
986 |
null); |
|
987 |
memberEnter.memberEnter(valueOf, env); |
|
988 |
} |
|
989 |
||
990 |
} |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8242
diff
changeset
|
991 |
|
10 | 992 |
/* *************************************************************************** |
993 |
* tree building |
|
994 |
****************************************************************************/ |
|
995 |
||
996 |
/** Generate default constructor for given class. For classes different |
|
997 |
* from java.lang.Object, this is: |
|
998 |
* |
|
999 |
* c(argtype_0 x_0, ..., argtype_n x_n) throws thrown { |
|
1000 |
* super(x_0, ..., x_n) |
|
1001 |
* } |
|
1002 |
* |
|
1003 |
* or, if based == true: |
|
1004 |
* |
|
1005 |
* c(argtype_0 x_0, ..., argtype_n x_n) throws thrown { |
|
1006 |
* x_0.super(x_1, ..., x_n) |
|
1007 |
* } |
|
1008 |
* |
|
1009 |
* @param make The tree factory. |
|
1010 |
* @param c The class owning the default constructor. |
|
1011 |
* @param argtypes The parameter types of the constructor. |
|
1012 |
* @param thrown The thrown exceptions of the constructor. |
|
1013 |
* @param based Is first parameter a this$n? |
|
1014 |
*/ |
|
1015 |
JCTree DefaultConstructor(TreeMaker make, |
|
1016 |
ClassSymbol c, |
|
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1017 |
MethodSymbol baseInit, |
10 | 1018 |
List<Type> typarams, |
1019 |
List<Type> argtypes, |
|
1020 |
List<Type> thrown, |
|
1021 |
long flags, |
|
1022 |
boolean based) { |
|
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1023 |
JCTree result; |
10 | 1024 |
if ((c.flags() & ENUM) != 0 && |
16558
07c08ad4a700
8010179: Remove transitional target values from javac
darcy
parents:
15720
diff
changeset
|
1025 |
(types.supertype(c.type).tsym == syms.enumSym)) { |
10 | 1026 |
// constructors of true enums are private |
1027 |
flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR; |
|
1028 |
} else |
|
1029 |
flags |= (c.flags() & AccessFlags) | GENERATEDCONSTR; |
|
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1030 |
if (c.name.isEmpty()) { |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1031 |
flags |= ANONCONSTR; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1032 |
} |
47248 | 1033 |
if (based) { |
1034 |
flags |= ANONCONSTR_BASED; |
|
1035 |
} |
|
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1036 |
Type mType = new MethodType(argtypes, null, thrown, c); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1037 |
Type initType = typarams.nonEmpty() ? |
24396 | 1038 |
new ForAll(typarams, mType) : |
1039 |
mType; |
|
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1040 |
MethodSymbol init = new MethodSymbol(flags, names.init, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1041 |
initType, c); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1042 |
init.params = createDefaultConstructorParams(make, baseInit, init, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1043 |
argtypes, based); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1044 |
List<JCVariableDecl> params = make.Params(argtypes, init); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1045 |
List<JCStatement> stats = List.nil(); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1046 |
if (c.type != syms.objectType) { |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1047 |
stats = stats.prepend(SuperCall(make, typarams, params, based)); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1048 |
} |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1049 |
result = make.MethodDef(init, make.Block(0, stats)); |
10 | 1050 |
return result; |
1051 |
} |
|
1052 |
||
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1053 |
private List<VarSymbol> createDefaultConstructorParams( |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1054 |
TreeMaker make, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1055 |
MethodSymbol baseInit, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1056 |
MethodSymbol init, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1057 |
List<Type> argtypes, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1058 |
boolean based) { |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1059 |
List<VarSymbol> initParams = null; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1060 |
List<Type> argTypesList = argtypes; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1061 |
if (based) { |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1062 |
/* In this case argtypes will have an extra type, compared to baseInit, |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1063 |
* corresponding to the type of the enclosing instance i.e.: |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1064 |
* |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1065 |
* Inner i = outer.new Inner(1){} |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1066 |
* |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1067 |
* in the above example argtypes will be (Outer, int) and baseInit |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1068 |
* will have parameter's types (int). So in this case we have to add |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1069 |
* first the extra type in argtypes and then get the names of the |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1070 |
* parameters from baseInit. |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1071 |
*/ |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1072 |
initParams = List.nil(); |
19941
8b91e8eb2d20
7047734: javac, the LVT is not generated correctly in several scenarios
vromero
parents:
19656
diff
changeset
|
1073 |
VarSymbol param = new VarSymbol(PARAMETER, make.paramName(0), argtypes.head, init); |
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1074 |
initParams = initParams.append(param); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1075 |
argTypesList = argTypesList.tail; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1076 |
} |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1077 |
if (baseInit != null && baseInit.params != null && |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1078 |
baseInit.params.nonEmpty() && argTypesList.nonEmpty()) { |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
1079 |
initParams = (initParams == null) ? List.nil() : initParams; |
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1080 |
List<VarSymbol> baseInitParams = baseInit.params; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1081 |
while (baseInitParams.nonEmpty() && argTypesList.nonEmpty()) { |
19941
8b91e8eb2d20
7047734: javac, the LVT is not generated correctly in several scenarios
vromero
parents:
19656
diff
changeset
|
1082 |
VarSymbol param = new VarSymbol(baseInitParams.head.flags() | PARAMETER, |
17999
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1083 |
baseInitParams.head.name, argTypesList.head, init); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1084 |
initParams = initParams.append(param); |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1085 |
baseInitParams = baseInitParams.tail; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1086 |
argTypesList = argTypesList.tail; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1087 |
} |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1088 |
} |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1089 |
return initParams; |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1090 |
} |
42ae6fe53718
8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes
vromero
parents:
17578
diff
changeset
|
1091 |
|
10 | 1092 |
/** Generate call to superclass constructor. This is: |
1093 |
* |
|
1094 |
* super(id_0, ..., id_n) |
|
1095 |
* |
|
1096 |
* or, if based == true |
|
1097 |
* |
|
1098 |
* id_0.super(id_1,...,id_n) |
|
1099 |
* |
|
1100 |
* where id_0, ..., id_n are the names of the given parameters. |
|
1101 |
* |
|
1102 |
* @param make The tree factory |
|
1103 |
* @param params The parameters that need to be passed to super |
|
1104 |
* @param typarams The type parameters that need to be passed to super |
|
1105 |
* @param based Is first parameter a this$n? |
|
1106 |
*/ |
|
1107 |
JCExpressionStatement SuperCall(TreeMaker make, |
|
1108 |
List<Type> typarams, |
|
1109 |
List<JCVariableDecl> params, |
|
1110 |
boolean based) { |
|
1111 |
JCExpression meth; |
|
1112 |
if (based) { |
|
1113 |
meth = make.Select(make.Ident(params.head), names._super); |
|
1114 |
params = params.tail; |
|
1115 |
} else { |
|
1116 |
meth = make.Ident(names._super); |
|
1117 |
} |
|
1118 |
List<JCExpression> typeargs = typarams.nonEmpty() ? make.Types(typarams) : null; |
|
1119 |
return make.Exec(make.Apply(typeargs, meth, make.Idents(params))); |
|
1120 |
} |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1121 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1122 |
/** |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1123 |
* Mark sym deprecated if annotations contain @Deprecated annotation. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1124 |
*/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1125 |
public void markDeprecated(Symbol sym, List<JCAnnotation> annotations, Env<AttrContext> env) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1126 |
// In general, we cannot fully process annotations yet, but we |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1127 |
// can attribute the annotation types and then check to see if the |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1128 |
// @Deprecated annotation is present. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1129 |
attr.attribAnnotationTypes(annotations, env); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1130 |
handleDeprecatedAnnotations(annotations, sym); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1131 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1132 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1133 |
/** |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1134 |
* If a list of annotations contains a reference to java.lang.Deprecated, |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1135 |
* set the DEPRECATED flag. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1136 |
* If the annotation is marked forRemoval=true, also set DEPRECATED_REMOVAL. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1137 |
**/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1138 |
private void handleDeprecatedAnnotations(List<JCAnnotation> annotations, Symbol sym) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1139 |
for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1140 |
JCAnnotation a = al.head; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1141 |
if (a.annotationType.type == syms.deprecatedType) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1142 |
sym.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1143 |
a.args.stream() |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1144 |
.filter(e -> e.hasTag(ASSIGN)) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1145 |
.map(e -> (JCAssign) e) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1146 |
.filter(assign -> TreeInfo.name(assign.lhs) == names.forRemoval) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1147 |
.findFirst() |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1148 |
.ifPresent(assign -> { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1149 |
JCExpression rhs = TreeInfo.skipParens(assign.rhs); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1150 |
if (rhs.hasTag(LITERAL) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1151 |
&& Boolean.TRUE.equals(((JCLiteral) rhs).getValue())) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1152 |
sym.flags_field |= DEPRECATED_REMOVAL; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1153 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1154 |
}); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1155 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1156 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41932
diff
changeset
|
1157 |
} |
10 | 1158 |
} |