1 /* |
1 /* |
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
49 import com.sun.tools.javac.code.Type.ErrorType; |
49 import com.sun.tools.javac.code.Type.ErrorType; |
50 import com.sun.tools.javac.code.Type.JCPrimitiveType; |
50 import com.sun.tools.javac.code.Type.JCPrimitiveType; |
51 import com.sun.tools.javac.code.Type.JCVoidType; |
51 import com.sun.tools.javac.code.Type.JCVoidType; |
52 import com.sun.tools.javac.code.Type.MethodType; |
52 import com.sun.tools.javac.code.Type.MethodType; |
53 import com.sun.tools.javac.code.Type.UnknownType; |
53 import com.sun.tools.javac.code.Type.UnknownType; |
|
54 import com.sun.tools.javac.code.Types.UniqueType; |
54 import com.sun.tools.javac.comp.Modules; |
55 import com.sun.tools.javac.comp.Modules; |
55 import com.sun.tools.javac.util.Assert; |
56 import com.sun.tools.javac.util.Assert; |
56 import com.sun.tools.javac.util.Context; |
57 import com.sun.tools.javac.util.Context; |
57 import com.sun.tools.javac.util.Convert; |
58 import com.sun.tools.javac.util.Convert; |
58 import com.sun.tools.javac.util.DefinedBy; |
59 import com.sun.tools.javac.util.DefinedBy; |
244 private final Map<Name, Map<ModuleSymbol,PackageSymbol>> packages = new HashMap<>(); |
245 private final Map<Name, Map<ModuleSymbol,PackageSymbol>> packages = new HashMap<>(); |
245 |
246 |
246 /** A hashtable giving the encountered modules. |
247 /** A hashtable giving the encountered modules. |
247 */ |
248 */ |
248 private final Map<Name, ModuleSymbol> modules = new LinkedHashMap<>(); |
249 private final Map<Name, ModuleSymbol> modules = new LinkedHashMap<>(); |
|
250 |
|
251 private final Map<Types.UniqueType, VarSymbol> classFields = new HashMap<>(); |
|
252 |
|
253 public VarSymbol getClassField(Type type, Types types) { |
|
254 return classFields.computeIfAbsent( |
|
255 new UniqueType(type, types), k -> { |
|
256 Type arg = null; |
|
257 if (type.getTag() == ARRAY || type.getTag() == CLASS) |
|
258 arg = types.erasure(type); |
|
259 else if (type.isPrimitiveOrVoid()) |
|
260 arg = types.boxedClass(type).type; |
|
261 else |
|
262 throw new AssertionError(type); |
|
263 |
|
264 Type t = new ClassType( |
|
265 classType.getEnclosingType(), List.of(arg), classType.tsym); |
|
266 return new VarSymbol( |
|
267 STATIC | PUBLIC | FINAL, names._class, t, type.tsym); |
|
268 }); |
|
269 } |
249 |
270 |
250 public void initType(Type type, ClassSymbol c) { |
271 public void initType(Type type, ClassSymbol c) { |
251 type.tsym = c; |
272 type.tsym = c; |
252 typeOfTag[type.getTag().ordinal()] = type; |
273 typeOfTag[type.getTag().ordinal()] = type; |
253 } |
274 } |