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;
225 public final Type typeDescriptorType;
226 public final Type recordType;
227 public final Type switchBootstrapsType;
228 public final Type constantBootstrapsType;
229 public final Type valueBasedType;
230 public final Type valueBasedInternalType;
231 public final Type classDescType;
232 public final Type enumDescType;
233
234 // For serialization lint checking
235 public final Type objectStreamFieldType;
236 public final Type objectInputStreamType;
237 public final Type objectOutputStreamType;
238 public final Type ioExceptionType;
239 public final Type objectStreamExceptionType;
240 // For externalization lint checking
241 public final Type externalizableType;
242 public final Type objectInputType;
243 public final Type objectOutputType;
244
245 /** The symbol representing the length field of an array.
246 */
247 public final VarSymbol lengthVar;
248
249 /** The symbol representing the final finalize method on enums */
250 public final MethodSymbol enumFinalFinalize;
251
252 /** The symbol representing the close method on TWR AutoCloseable type */
253 public final MethodSymbol autoCloseableClose;
254
255 /** The predefined type that belongs to a tag.
256 */
257 public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
258
259 /** The name of the class that belongs to a basic type tag.
260 */
261 public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
262
263 /** A hashtable containing the encountered top-level and member classes,
264 * indexed by flat names. The table does not contain local classes.
608 previewFeatureType = enterClass("jdk.internal.javac.PreviewFeature");
609 previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
610 restrictedType = enterClass("jdk.internal.javac.Restricted");
611 typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
612 recordType = enterClass("java.lang.Record");
613 switchBootstrapsType = enterClass("java.lang.runtime.SwitchBootstraps");
614 constantBootstrapsType = enterClass("java.lang.invoke.ConstantBootstraps");
615 valueBasedType = enterClass("jdk.internal.ValueBased");
616 valueBasedInternalType = enterSyntheticAnnotation("jdk.internal.ValueBased+Annotation");
617 classDescType = enterClass("java.lang.constant.ClassDesc");
618 enumDescType = enterClass("java.lang.Enum$EnumDesc");
619 // For serialization lint checking
620 objectStreamFieldType = enterClass("java.io.ObjectStreamField");
621 objectInputStreamType = enterClass("java.io.ObjectInputStream");
622 objectOutputStreamType = enterClass("java.io.ObjectOutputStream");
623 ioExceptionType = enterClass("java.io.IOException");
624 objectStreamExceptionType = enterClass("java.io.ObjectStreamException");
625 externalizableType = enterClass("java.io.Externalizable");
626 objectInputType = enterClass("java.io.ObjectInput");
627 objectOutputType = enterClass("java.io.ObjectOutput");
628 synthesizeEmptyInterfaceIfMissing(autoCloseableType);
629 synthesizeEmptyInterfaceIfMissing(cloneableType);
630 synthesizeEmptyInterfaceIfMissing(serializableType);
631 synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
632 synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
633 synthesizeEmptyInterfaceIfMissing(stringConcatFactory);
634 synthesizeBoxTypeIfMissing(doubleType);
635 synthesizeBoxTypeIfMissing(floatType);
636 synthesizeBoxTypeIfMissing(voidType);
637
638 // Enter a synthetic class that is used to mark internal
639 // proprietary classes in ct.sym. This class does not have a
640 // class file.
641 proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
642
643 // Enter a synthetic class that is used to provide profile info for
644 // classes in ct.sym. This class does not have a class file.
645 profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
646 MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
647 profileType.tsym.members().enter(m);
648
649 // Enter a class for arrays.
650 // The class implements java.lang.Cloneable and java.io.Serializable.
651 // It has a final length field and a clone method.
652 ClassType arrayClassType = (ClassType)arrayClass.type;
653 arrayClassType.supertype_field = objectType;
|
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;
226 public final Type typeDescriptorType;
227 public final Type recordType;
228 public final Type switchBootstrapsType;
229 public final Type constantBootstrapsType;
230 public final Type valueBasedType;
231 public final Type valueBasedInternalType;
232 public final Type classDescType;
233 public final Type enumDescType;
234
235 // For serialization lint checking
236 public final Type objectStreamFieldType;
237 public final Type objectInputStreamType;
238 public final Type objectOutputStreamType;
239 public final Type ioExceptionType;
240 public final Type objectStreamExceptionType;
241 // For externalization lint checking
242 public final Type externalizableType;
243 public final Type objectInputType;
244 public final Type objectOutputType;
245
246 // For code reflection
247 public final Type codeReflectionType;
248 public final Type quotedType;
249 public final Type quotableType;
250 public final Type closureOpType;
251 public final Type lambdaOpType;
252 public final Type opInterpreterType;
253 public final Type opParserType;
254 public final Type opType;
255 public final MethodSymbol opInterpreterInvoke;
256 public final MethodSymbol opParserFromString;
257
258 /** The symbol representing the length field of an array.
259 */
260 public final VarSymbol lengthVar;
261
262 /** The symbol representing the final finalize method on enums */
263 public final MethodSymbol enumFinalFinalize;
264
265 /** The symbol representing the close method on TWR AutoCloseable type */
266 public final MethodSymbol autoCloseableClose;
267
268 /** The predefined type that belongs to a tag.
269 */
270 public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
271
272 /** The name of the class that belongs to a basic type tag.
273 */
274 public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
275
276 /** A hashtable containing the encountered top-level and member classes,
277 * indexed by flat names. The table does not contain local classes.
621 previewFeatureType = enterClass("jdk.internal.javac.PreviewFeature");
622 previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
623 restrictedType = enterClass("jdk.internal.javac.Restricted");
624 typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
625 recordType = enterClass("java.lang.Record");
626 switchBootstrapsType = enterClass("java.lang.runtime.SwitchBootstraps");
627 constantBootstrapsType = enterClass("java.lang.invoke.ConstantBootstraps");
628 valueBasedType = enterClass("jdk.internal.ValueBased");
629 valueBasedInternalType = enterSyntheticAnnotation("jdk.internal.ValueBased+Annotation");
630 classDescType = enterClass("java.lang.constant.ClassDesc");
631 enumDescType = enterClass("java.lang.Enum$EnumDesc");
632 // For serialization lint checking
633 objectStreamFieldType = enterClass("java.io.ObjectStreamField");
634 objectInputStreamType = enterClass("java.io.ObjectInputStream");
635 objectOutputStreamType = enterClass("java.io.ObjectOutputStream");
636 ioExceptionType = enterClass("java.io.IOException");
637 objectStreamExceptionType = enterClass("java.io.ObjectStreamException");
638 externalizableType = enterClass("java.io.Externalizable");
639 objectInputType = enterClass("java.io.ObjectInput");
640 objectOutputType = enterClass("java.io.ObjectOutput");
641 // For code reflection
642 codeReflectionType = enterClass("java.lang.runtime.CodeReflection");
643 quotedType = enterClass("java.lang.reflect.code.Quoted");
644 quotableType = enterClass("java.lang.reflect.code.Quotable");
645 closureOpType = enterClass("java.lang.reflect.code.op.CoreOp$ClosureOp");
646 lambdaOpType = enterClass("java.lang.reflect.code.op.CoreOp$LambdaOp");
647 opInterpreterType = enterClass("java.lang.reflect.code.interpreter.Interpreter");
648 opType = enterClass("java.lang.reflect.code.Op");
649 opInterpreterInvoke = new MethodSymbol(PUBLIC | STATIC | VARARGS,
650 names.fromString("invoke"),
651 new MethodType(List.of(opType, new ArrayType(objectType, arrayClass)), objectType,
652 List.nil(), methodClass),
653 opInterpreterType.tsym);
654 opParserType = enterClass("java.lang.reflect.code.parser.OpParser");
655 opParserFromString = new MethodSymbol(PUBLIC | STATIC,
656 names.fromString("fromStringOfFuncOp"),
657 new MethodType(List.of(stringType), opType,
658 List.nil(), methodClass),
659 opParserType.tsym);
660 synthesizeEmptyInterfaceIfMissing(autoCloseableType);
661 synthesizeEmptyInterfaceIfMissing(cloneableType);
662 synthesizeEmptyInterfaceIfMissing(serializableType);
663 synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
664 synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
665 synthesizeEmptyInterfaceIfMissing(stringConcatFactory);
666 synthesizeEmptyInterfaceIfMissing(quotedType);
667 synthesizeEmptyInterfaceIfMissing(quotableType);
668 synthesizeBoxTypeIfMissing(doubleType);
669 synthesizeBoxTypeIfMissing(floatType);
670 synthesizeBoxTypeIfMissing(voidType);
671
672 // Enter a synthetic class that is used to mark internal
673 // proprietary classes in ct.sym. This class does not have a
674 // class file.
675 proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
676
677 // Enter a synthetic class that is used to provide profile info for
678 // classes in ct.sym. This class does not have a class file.
679 profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
680 MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
681 profileType.tsym.members().enter(m);
682
683 // Enter a class for arrays.
684 // The class implements java.lang.Cloneable and java.io.Serializable.
685 // It has a final length field and a clone method.
686 ClassType arrayClassType = (ClassType)arrayClass.type;
687 arrayClassType.supertype_field = objectType;
|