1 /*
2 * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
209 public final Type inheritedType;
210 public final Type profileType;
211 public final Type proprietaryType;
212 public final Type systemType;
213 public final Type autoCloseableType;
214 public final Type trustMeType;
215 public final Type lambdaMetafactory;
216 public final Type stringConcatFactory;
217 public final Type repeatableType;
218 public final Type documentedType;
219 public final Type elementTypeType;
220 public final Type functionalInterfaceType;
221 public final Type previewFeatureType;
222 public final Type previewFeatureInternalType;
223 public final Type restrictedType;
224 public final Type restrictedInternalType;
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 requiresIdentityType;
232 public final Type requiresIdentityInternalType;
233 public final Type classDescType;
234 public final Type enumDescType;
235
236 // For serialization lint checking
237 public final Type objectStreamFieldType;
238 public final Type objectInputStreamType;
239 public final Type objectOutputStreamType;
240 public final Type ioExceptionType;
241 public final Type objectStreamExceptionType;
242 // For externalization lint checking
243 public final Type externalizableType;
244 public final Type objectInputType;
245 public final Type objectOutputType;
246
247 /** The symbol representing the length field of an array.
248 */
249 public final VarSymbol lengthVar;
250
251 /** The symbol representing the final finalize method on enums */
252 public final MethodSymbol enumFinalFinalize;
253
254 /** The symbol representing the close method on TWR AutoCloseable type */
255 public final MethodSymbol autoCloseableClose;
256
257 /** The predefined type that belongs to a tag.
258 */
259 public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
260
261 /** The name of the class that belongs to a basic type tag.
262 */
263 public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
264
265 /** A hashtable containing the encountered top-level and member classes,
266 * indexed by flat names. The table does not contain local classes.
525
526 // Enter symbols for basic types.
527 scope.enter(byteType.tsym);
528 scope.enter(shortType.tsym);
529 scope.enter(charType.tsym);
530 scope.enter(intType.tsym);
531 scope.enter(longType.tsym);
532 scope.enter(floatType.tsym);
533 scope.enter(doubleType.tsym);
534 scope.enter(booleanType.tsym);
535 scope.enter(errType.tsym);
536
537 // Enter symbol for the errSymbol
538 scope.enter(errSymbol);
539
540 // Get the initial completer for ModuleSymbols from Modules
541 moduleCompleter = Modules.instance(context).getCompleter();
542
543 // Enter predefined classes. All are assumed to be in the java.base module.
544 objectType = enterClass("java.lang.Object");
545 objectMethodsType = enterClass("java.lang.runtime.ObjectMethods");
546 exactConversionsSupportType = enterClass("java.lang.runtime.ExactConversionsSupport");
547 objectsType = enterClass("java.util.Objects");
548 classType = enterClass("java.lang.Class");
549 stringType = enterClass("java.lang.String");
550 stringBufferType = enterClass("java.lang.StringBuffer");
551 stringBuilderType = enterClass("java.lang.StringBuilder");
552 cloneableType = enterClass("java.lang.Cloneable");
553 throwableType = enterClass("java.lang.Throwable");
554 serializableType = enterClass("java.io.Serializable");
555 serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
556 varHandleType = enterClass("java.lang.invoke.VarHandle");
557 methodHandleType = enterClass("java.lang.invoke.MethodHandle");
558 methodHandlesType = enterClass("java.lang.invoke.MethodHandles");
559 methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
560 methodTypeType = enterClass("java.lang.invoke.MethodType");
561 errorType = enterClass("java.lang.Error");
562 illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
563 interruptedExceptionType = enterClass("java.lang.InterruptedException");
564 exceptionType = enterClass("java.lang.Exception");
565 runtimeExceptionType = enterClass("java.lang.RuntimeException");
566 classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
567 noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
568 noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
569 assertionErrorType = enterClass("java.lang.AssertionError");
570 incompatibleClassChangeErrorType = enterClass("java.lang.IncompatibleClassChangeError");
571 cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
572 matchExceptionType = enterClass("java.lang.MatchException");
573 annotationType = enterClass("java.lang.annotation.Annotation");
624 enumDescType = enterClass("java.lang.Enum$EnumDesc");
625 // For serialization lint checking
626 objectStreamFieldType = enterClass("java.io.ObjectStreamField");
627 objectInputStreamType = enterClass("java.io.ObjectInputStream");
628 objectOutputStreamType = enterClass("java.io.ObjectOutputStream");
629 ioExceptionType = enterClass("java.io.IOException");
630 objectStreamExceptionType = enterClass("java.io.ObjectStreamException");
631 externalizableType = enterClass("java.io.Externalizable");
632 objectInputType = enterClass("java.io.ObjectInput");
633 objectOutputType = enterClass("java.io.ObjectOutput");
634 synthesizeEmptyInterfaceIfMissing(autoCloseableType);
635 synthesizeEmptyInterfaceIfMissing(cloneableType);
636 synthesizeEmptyInterfaceIfMissing(serializableType);
637 synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
638 synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
639 synthesizeEmptyInterfaceIfMissing(stringConcatFactory);
640 synthesizeBoxTypeIfMissing(doubleType);
641 synthesizeBoxTypeIfMissing(floatType);
642 synthesizeBoxTypeIfMissing(voidType);
643
644 // Enter a synthetic class that is used to mark internal
645 // proprietary classes in ct.sym. This class does not have a
646 // class file.
647 proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
648
649 // Enter a synthetic class that is used to provide profile info for
650 // classes in ct.sym. This class does not have a class file.
651 profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
652 MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
653 profileType.tsym.members().enter(m);
654
655 // Enter a class for arrays.
656 // The class implements java.lang.Cloneable and java.io.Serializable.
657 // It has a final length field and a clone method.
658 ClassType arrayClassType = (ClassType)arrayClass.type;
659 arrayClassType.supertype_field = objectType;
660 arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
661 arrayClass.members_field = WriteableScope.create(arrayClass);
662 lengthVar = new VarSymbol(
663 PUBLIC | FINAL,
|
1 /*
2 * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
209 public final Type inheritedType;
210 public final Type profileType;
211 public final Type proprietaryType;
212 public final Type systemType;
213 public final Type autoCloseableType;
214 public final Type trustMeType;
215 public final Type lambdaMetafactory;
216 public final Type stringConcatFactory;
217 public final Type repeatableType;
218 public final Type documentedType;
219 public final Type elementTypeType;
220 public final Type functionalInterfaceType;
221 public final Type previewFeatureType;
222 public final Type previewFeatureInternalType;
223 public final Type restrictedType;
224 public final Type restrictedInternalType;
225 public final Type typeDescriptorType;
226 public final Type recordType;
227 public final Type switchBootstrapsType;
228 public final Type constantBootstrapsType;
229 public final Type requiresIdentityType;
230 public final Type requiresIdentityInternalType;
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 // valhalla
246 public final Type valueBasedType;
247 public final Type valueBasedInternalType;
248 /** The symbol representing the finalize method on Object */
249 public final MethodSymbol objectFinalize;
250 public final Type numberType;
251
252 /** The symbol representing the length field of an array.
253 */
254 public final VarSymbol lengthVar;
255
256 /** The symbol representing the final finalize method on enums */
257 public final MethodSymbol enumFinalFinalize;
258
259 /** The symbol representing the close method on TWR AutoCloseable type */
260 public final MethodSymbol autoCloseableClose;
261
262 /** The predefined type that belongs to a tag.
263 */
264 public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
265
266 /** The name of the class that belongs to a basic type tag.
267 */
268 public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
269
270 /** A hashtable containing the encountered top-level and member classes,
271 * indexed by flat names. The table does not contain local classes.
530
531 // Enter symbols for basic types.
532 scope.enter(byteType.tsym);
533 scope.enter(shortType.tsym);
534 scope.enter(charType.tsym);
535 scope.enter(intType.tsym);
536 scope.enter(longType.tsym);
537 scope.enter(floatType.tsym);
538 scope.enter(doubleType.tsym);
539 scope.enter(booleanType.tsym);
540 scope.enter(errType.tsym);
541
542 // Enter symbol for the errSymbol
543 scope.enter(errSymbol);
544
545 // Get the initial completer for ModuleSymbols from Modules
546 moduleCompleter = Modules.instance(context).getCompleter();
547
548 // Enter predefined classes. All are assumed to be in the java.base module.
549 objectType = enterClass("java.lang.Object");
550 throwableType = enterClass("java.lang.Throwable");
551 objectFinalize = new MethodSymbol(PROTECTED,
552 names.finalize,
553 new MethodType(List.nil(), voidType,
554 List.of(throwableType), methodClass),
555 objectType.tsym);
556 objectMethodsType = enterClass("java.lang.runtime.ObjectMethods");
557 exactConversionsSupportType = enterClass("java.lang.runtime.ExactConversionsSupport");
558 objectsType = enterClass("java.util.Objects");
559 classType = enterClass("java.lang.Class");
560 stringType = enterClass("java.lang.String");
561 stringBufferType = enterClass("java.lang.StringBuffer");
562 stringBuilderType = enterClass("java.lang.StringBuilder");
563 cloneableType = enterClass("java.lang.Cloneable");
564 serializableType = enterClass("java.io.Serializable");
565 serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
566 varHandleType = enterClass("java.lang.invoke.VarHandle");
567 methodHandleType = enterClass("java.lang.invoke.MethodHandle");
568 methodHandlesType = enterClass("java.lang.invoke.MethodHandles");
569 methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
570 methodTypeType = enterClass("java.lang.invoke.MethodType");
571 errorType = enterClass("java.lang.Error");
572 illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
573 interruptedExceptionType = enterClass("java.lang.InterruptedException");
574 exceptionType = enterClass("java.lang.Exception");
575 runtimeExceptionType = enterClass("java.lang.RuntimeException");
576 classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
577 noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
578 noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
579 assertionErrorType = enterClass("java.lang.AssertionError");
580 incompatibleClassChangeErrorType = enterClass("java.lang.IncompatibleClassChangeError");
581 cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
582 matchExceptionType = enterClass("java.lang.MatchException");
583 annotationType = enterClass("java.lang.annotation.Annotation");
634 enumDescType = enterClass("java.lang.Enum$EnumDesc");
635 // For serialization lint checking
636 objectStreamFieldType = enterClass("java.io.ObjectStreamField");
637 objectInputStreamType = enterClass("java.io.ObjectInputStream");
638 objectOutputStreamType = enterClass("java.io.ObjectOutputStream");
639 ioExceptionType = enterClass("java.io.IOException");
640 objectStreamExceptionType = enterClass("java.io.ObjectStreamException");
641 externalizableType = enterClass("java.io.Externalizable");
642 objectInputType = enterClass("java.io.ObjectInput");
643 objectOutputType = enterClass("java.io.ObjectOutput");
644 synthesizeEmptyInterfaceIfMissing(autoCloseableType);
645 synthesizeEmptyInterfaceIfMissing(cloneableType);
646 synthesizeEmptyInterfaceIfMissing(serializableType);
647 synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
648 synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
649 synthesizeEmptyInterfaceIfMissing(stringConcatFactory);
650 synthesizeBoxTypeIfMissing(doubleType);
651 synthesizeBoxTypeIfMissing(floatType);
652 synthesizeBoxTypeIfMissing(voidType);
653
654 numberType = enterClass("java.lang.Number");
655
656 // Enter a synthetic class that is used to mark internal
657 // proprietary classes in ct.sym. This class does not have a
658 // class file.
659 proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
660
661 // Enter a synthetic class that is used to provide profile info for
662 // classes in ct.sym. This class does not have a class file.
663 profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
664 MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
665 profileType.tsym.members().enter(m);
666
667 // Enter a class for arrays.
668 // The class implements java.lang.Cloneable and java.io.Serializable.
669 // It has a final length field and a clone method.
670 ClassType arrayClassType = (ClassType)arrayClass.type;
671 arrayClassType.supertype_field = objectType;
672 arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
673 arrayClass.members_field = WriteableScope.create(arrayClass);
674 lengthVar = new VarSymbol(
675 PUBLIC | FINAL,
|