28 import java.util.Collection;
29 import java.util.Collections;
30 import java.util.EnumSet;
31 import java.util.HashMap;
32 import java.util.LinkedHashMap;
33 import java.util.Map;
34
35 import javax.lang.model.element.ElementVisitor;
36
37 import com.sun.tools.javac.code.Scope.WriteableScope;
38 import com.sun.tools.javac.code.Source.Feature;
39 import com.sun.tools.javac.code.Symbol.ClassSymbol;
40 import com.sun.tools.javac.code.Symbol.Completer;
41 import com.sun.tools.javac.code.Symbol.CompletionFailure;
42 import com.sun.tools.javac.code.Symbol.MethodSymbol;
43 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
44 import com.sun.tools.javac.code.Symbol.PackageSymbol;
45 import com.sun.tools.javac.code.Symbol.RootPackageSymbol;
46 import com.sun.tools.javac.code.Symbol.TypeSymbol;
47 import com.sun.tools.javac.code.Symbol.VarSymbol;
48 import com.sun.tools.javac.code.Type.BottomType;
49 import com.sun.tools.javac.code.Type.ClassType;
50 import com.sun.tools.javac.code.Type.ErrorType;
51 import com.sun.tools.javac.code.Type.JCPrimitiveType;
52 import com.sun.tools.javac.code.Type.JCVoidType;
53 import com.sun.tools.javac.code.Type.MethodType;
54 import com.sun.tools.javac.code.Type.UnknownType;
55 import com.sun.tools.javac.code.Types.UniqueType;
56 import com.sun.tools.javac.comp.Modules;
57 import com.sun.tools.javac.jvm.Target;
58 import com.sun.tools.javac.util.Assert;
59 import com.sun.tools.javac.util.Context;
60 import com.sun.tools.javac.util.Convert;
61 import com.sun.tools.javac.util.DefinedBy;
62 import com.sun.tools.javac.util.DefinedBy.Api;
63 import com.sun.tools.javac.util.Iterators;
64 import com.sun.tools.javac.util.JavacMessages;
65 import com.sun.tools.javac.util.List;
66 import com.sun.tools.javac.util.Name;
67 import com.sun.tools.javac.util.Names;
310 new ClassSymbol(
311 PUBLIC, names.fromString(name), type, rootPackage));
312 }
313
314 public void initType(Type type, String name, String bname) {
315 initType(type, name);
316 boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname);
317 }
318
319 /** The class symbol that owns all predefined symbols.
320 */
321 public final ClassSymbol predefClass;
322
323 /** Enter a class into symbol table.
324 * @param s The name of the class.
325 */
326 private Type enterClass(String s) {
327 return enterClass(java_base, names.fromString(s)).type;
328 }
329
330 public void synthesizeEmptyInterfaceIfMissing(final Type type) {
331 final Completer completer = type.tsym.completer;
332 type.tsym.completer = new Completer() {
333 @Override
334 public void complete(Symbol sym) throws CompletionFailure {
335 try {
336 completer.complete(sym);
337 } catch (CompletionFailure e) {
338 sym.flags_field |= (PUBLIC | INTERFACE);
339 ((ClassType) sym.type).supertype_field = objectType;
340 }
341 }
342
343 @Override
344 public boolean isTerminal() {
345 return completer.isTerminal();
346 }
347 };
348 }
349
|
28 import java.util.Collection;
29 import java.util.Collections;
30 import java.util.EnumSet;
31 import java.util.HashMap;
32 import java.util.LinkedHashMap;
33 import java.util.Map;
34
35 import javax.lang.model.element.ElementVisitor;
36
37 import com.sun.tools.javac.code.Scope.WriteableScope;
38 import com.sun.tools.javac.code.Source.Feature;
39 import com.sun.tools.javac.code.Symbol.ClassSymbol;
40 import com.sun.tools.javac.code.Symbol.Completer;
41 import com.sun.tools.javac.code.Symbol.CompletionFailure;
42 import com.sun.tools.javac.code.Symbol.MethodSymbol;
43 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
44 import com.sun.tools.javac.code.Symbol.PackageSymbol;
45 import com.sun.tools.javac.code.Symbol.RootPackageSymbol;
46 import com.sun.tools.javac.code.Symbol.TypeSymbol;
47 import com.sun.tools.javac.code.Symbol.VarSymbol;
48 import com.sun.tools.javac.code.Type.ArrayType;
49 import com.sun.tools.javac.code.Type.BottomType;
50 import com.sun.tools.javac.code.Type.ClassType;
51 import com.sun.tools.javac.code.Type.ErrorType;
52 import com.sun.tools.javac.code.Type.JCPrimitiveType;
53 import com.sun.tools.javac.code.Type.JCVoidType;
54 import com.sun.tools.javac.code.Type.MethodType;
55 import com.sun.tools.javac.code.Type.UnknownType;
56 import com.sun.tools.javac.code.Types.UniqueType;
57 import com.sun.tools.javac.comp.Modules;
58 import com.sun.tools.javac.jvm.Target;
59 import com.sun.tools.javac.util.Assert;
60 import com.sun.tools.javac.util.Context;
61 import com.sun.tools.javac.util.Convert;
62 import com.sun.tools.javac.util.DefinedBy;
63 import com.sun.tools.javac.util.DefinedBy.Api;
64 import com.sun.tools.javac.util.Iterators;
65 import com.sun.tools.javac.util.JavacMessages;
66 import com.sun.tools.javac.util.List;
67 import com.sun.tools.javac.util.Name;
68 import com.sun.tools.javac.util.Names;
311 new ClassSymbol(
312 PUBLIC, names.fromString(name), type, rootPackage));
313 }
314
315 public void initType(Type type, String name, String bname) {
316 initType(type, name);
317 boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname);
318 }
319
320 /** The class symbol that owns all predefined symbols.
321 */
322 public final ClassSymbol predefClass;
323
324 /** Enter a class into symbol table.
325 * @param s The name of the class.
326 */
327 private Type enterClass(String s) {
328 return enterClass(java_base, names.fromString(s)).type;
329 }
330
331 /** Enter a class into symbol table.
332 * @param s The name of the class.
333 */
334 public Type enterClass(ModuleSymbol moduleSymbol, String s) {
335 try {
336 return enterClass(moduleSymbol, names.fromString(s)).type;
337 } catch (Throwable ex) {
338 ex.printStackTrace();
339 return Type.noType;
340 }
341 }
342
343 public void synthesizeEmptyInterfaceIfMissing(final Type type) {
344 final Completer completer = type.tsym.completer;
345 type.tsym.completer = new Completer() {
346 @Override
347 public void complete(Symbol sym) throws CompletionFailure {
348 try {
349 completer.complete(sym);
350 } catch (CompletionFailure e) {
351 sym.flags_field |= (PUBLIC | INTERFACE);
352 ((ClassType) sym.type).supertype_field = objectType;
353 }
354 }
355
356 @Override
357 public boolean isTerminal() {
358 return completer.isTerminal();
359 }
360 };
361 }
362
|