Symtab.java revision 2840:84849fdb360b
1/*
2 * Copyright (c) 1999, 2014, 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
23 * questions.
24 */
25
26package com.sun.tools.javac.code;
27
28import java.util.HashMap;
29import java.util.HashSet;
30import java.util.Map;
31import java.util.Set;
32
33import javax.lang.model.element.ElementVisitor;
34import javax.tools.JavaFileObject;
35
36
37import com.sun.tools.javac.code.Scope.WriteableScope;
38import com.sun.tools.javac.code.Symbol.ClassSymbol;
39import com.sun.tools.javac.code.Symbol.Completer;
40import com.sun.tools.javac.code.Symbol.CompletionFailure;
41import com.sun.tools.javac.code.Symbol.MethodSymbol;
42import com.sun.tools.javac.code.Symbol.OperatorSymbol;
43import com.sun.tools.javac.code.Symbol.PackageSymbol;
44import com.sun.tools.javac.code.Symbol.TypeSymbol;
45import com.sun.tools.javac.code.Symbol.VarSymbol;
46import com.sun.tools.javac.code.Type.BottomType;
47import com.sun.tools.javac.code.Type.ClassType;
48import com.sun.tools.javac.code.Type.ErrorType;
49import com.sun.tools.javac.code.Type.JCPrimitiveType;
50import com.sun.tools.javac.code.Type.JCVoidType;
51import com.sun.tools.javac.code.Type.MethodType;
52import com.sun.tools.javac.code.Type.UnknownType;
53import com.sun.tools.javac.jvm.ByteCodes;
54import com.sun.tools.javac.jvm.Target;
55import com.sun.tools.javac.util.Assert;
56import com.sun.tools.javac.util.Context;
57import com.sun.tools.javac.util.Convert;
58import com.sun.tools.javac.util.DefinedBy;
59import com.sun.tools.javac.util.DefinedBy.Api;
60import com.sun.tools.javac.util.JavacMessages;
61import com.sun.tools.javac.util.List;
62import com.sun.tools.javac.util.Log;
63import com.sun.tools.javac.util.Name;
64import com.sun.tools.javac.util.Names;
65
66import static com.sun.tools.javac.code.Flags.*;
67import static com.sun.tools.javac.code.Kinds.Kind.*;
68import static com.sun.tools.javac.jvm.ByteCodes.*;
69import static com.sun.tools.javac.code.TypeTag.*;
70
71/** A class that defines all predefined constants and operators
72 *  as well as special classes such as java.lang.Object, which need
73 *  to be known to the compiler. All symbols are held in instance
74 *  fields. This makes it possible to work in multiple concurrent
75 *  projects, which might use different class files for library classes.
76 *
77 *  <p><b>This is NOT part of any supported API.
78 *  If you write code that depends on this, you do so at your own risk.
79 *  This code and its internal interfaces are subject to change or
80 *  deletion without notice.</b>
81 */
82public class Symtab {
83    /** The context key for the symbol table. */
84    protected static final Context.Key<Symtab> symtabKey = new Context.Key<>();
85
86    /** Get the symbol table instance. */
87    public static Symtab instance(Context context) {
88        Symtab instance = context.get(symtabKey);
89        if (instance == null)
90            instance = new Symtab(context);
91        return instance;
92    }
93
94    /** Builtin types.
95     */
96    public final JCPrimitiveType byteType = new JCPrimitiveType(BYTE, null);
97    public final JCPrimitiveType charType = new JCPrimitiveType(CHAR, null);
98    public final JCPrimitiveType shortType = new JCPrimitiveType(SHORT, null);
99    public final JCPrimitiveType intType = new JCPrimitiveType(INT, null);
100    public final JCPrimitiveType longType = new JCPrimitiveType(LONG, null);
101    public final JCPrimitiveType floatType = new JCPrimitiveType(FLOAT, null);
102    public final JCPrimitiveType doubleType = new JCPrimitiveType(DOUBLE, null);
103    public final JCPrimitiveType booleanType = new JCPrimitiveType(BOOLEAN, null);
104    public final Type botType = new BottomType();
105    public final JCVoidType voidType = new JCVoidType();
106
107    private final Names names;
108    private final Completer initialCompleter;
109    private final Target target;
110
111    /** A symbol for the root package.
112     */
113    public final PackageSymbol rootPackage;
114
115    /** A symbol for the unnamed package.
116     */
117    public final PackageSymbol unnamedPackage;
118
119    /** A symbol that stands for a missing symbol.
120     */
121    public final TypeSymbol noSymbol;
122
123    /** The error symbol.
124     */
125    public final ClassSymbol errSymbol;
126
127    /** The unknown symbol.
128     */
129    public final ClassSymbol unknownSymbol;
130
131    /** A value for the errType, with a originalType of noType */
132    public final Type errType;
133
134    /** A value for the unknown type. */
135    public final Type unknownType;
136
137    /** The builtin type of all arrays. */
138    public final ClassSymbol arrayClass;
139    public final MethodSymbol arrayCloneMethod;
140
141    /** VGJ: The (singleton) type of all bound types. */
142    public final ClassSymbol boundClass;
143
144    /** The builtin type of all methods. */
145    public final ClassSymbol methodClass;
146
147    /** Predefined types.
148     */
149    public final Type objectType;
150    public final Type classType;
151    public final Type classLoaderType;
152    public final Type stringType;
153    public final Type stringBufferType;
154    public final Type stringBuilderType;
155    public final Type cloneableType;
156    public final Type serializableType;
157    public final Type serializedLambdaType;
158    public final Type methodHandleType;
159    public final Type methodHandleLookupType;
160    public final Type methodTypeType;
161    public final Type nativeHeaderType;
162    public final Type throwableType;
163    public final Type errorType;
164    public final Type interruptedExceptionType;
165    public final Type illegalArgumentExceptionType;
166    public final Type exceptionType;
167    public final Type runtimeExceptionType;
168    public final Type classNotFoundExceptionType;
169    public final Type noClassDefFoundErrorType;
170    public final Type noSuchFieldErrorType;
171    public final Type assertionErrorType;
172    public final Type cloneNotSupportedExceptionType;
173    public final Type annotationType;
174    public final TypeSymbol enumSym;
175    public final Type listType;
176    public final Type collectionsType;
177    public final Type comparableType;
178    public final Type comparatorType;
179    public final Type arraysType;
180    public final Type iterableType;
181    public final Type iteratorType;
182    public final Type annotationTargetType;
183    public final Type overrideType;
184    public final Type retentionType;
185    public final Type deprecatedType;
186    public final Type suppressWarningsType;
187    public final Type supplierType;
188    public final Type inheritedType;
189    public final Type profileType;
190    public final Type proprietaryType;
191    public final Type systemType;
192    public final Type autoCloseableType;
193    public final Type trustMeType;
194    public final Type lambdaMetafactory;
195    public final Type repeatableType;
196    public final Type documentedType;
197    public final Type elementTypeType;
198    public final Type functionalInterfaceType;
199
200    /** The symbol representing the length field of an array.
201     */
202    public final VarSymbol lengthVar;
203
204    /** The symbol representing the final finalize method on enums */
205    public final MethodSymbol enumFinalFinalize;
206
207    /** The symbol representing the close method on TWR AutoCloseable type */
208    public final MethodSymbol autoCloseableClose;
209
210    /** The predefined type that belongs to a tag.
211     */
212    public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
213
214    /** The name of the class that belongs to a basix type tag.
215     */
216    public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
217
218    /** A hashtable containing the encountered top-level and member classes,
219     *  indexed by flat names. The table does not contain local classes.
220     *  It should be updated from the outside to reflect classes defined
221     *  by compiled source files.
222     */
223    public final Map<Name, ClassSymbol> classes = new HashMap<>();
224
225    /** A hashtable containing the encountered packages.
226     *  the table should be updated from outside to reflect packages defined
227     *  by compiled source files.
228     */
229    public final Map<Name, PackageSymbol> packages = new HashMap<>();
230
231    public void initType(Type type, ClassSymbol c) {
232        type.tsym = c;
233        typeOfTag[type.getTag().ordinal()] = type;
234    }
235
236    public void initType(Type type, String name) {
237        initType(
238            type,
239            new ClassSymbol(
240                PUBLIC, names.fromString(name), type, rootPackage));
241    }
242
243    public void initType(Type type, String name, String bname) {
244        initType(type, name);
245            boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname);
246    }
247
248    /** The class symbol that owns all predefined symbols.
249     */
250    public final ClassSymbol predefClass;
251
252    /** Enter a class into symbol table.
253     *  @param s The name of the class.
254     */
255    private Type enterClass(String s) {
256        return enterClass(names.fromString(s)).type;
257    }
258
259    public void synthesizeEmptyInterfaceIfMissing(final Type type) {
260        final Completer completer = type.tsym.completer;
261        if (completer != null) {
262            type.tsym.completer = new Completer() {
263                public void complete(Symbol sym) throws CompletionFailure {
264                    try {
265                        completer.complete(sym);
266                    } catch (CompletionFailure e) {
267                        sym.flags_field |= (PUBLIC | INTERFACE);
268                        ((ClassType) sym.type).supertype_field = objectType;
269                    }
270                }
271            };
272        }
273    }
274
275    public void synthesizeBoxTypeIfMissing(final Type type) {
276        ClassSymbol sym = enterClass(boxedName[type.getTag().ordinal()]);
277        final Completer completer = sym.completer;
278        if (completer != null) {
279            sym.completer = new Completer() {
280                public void complete(Symbol sym) throws CompletionFailure {
281                    try {
282                        completer.complete(sym);
283                    } catch (CompletionFailure e) {
284                        sym.flags_field |= PUBLIC;
285                        ((ClassType) sym.type).supertype_field = objectType;
286                        MethodSymbol boxMethod =
287                            new MethodSymbol(PUBLIC | STATIC, names.valueOf,
288                                             new MethodType(List.of(type), sym.type,
289                                    List.<Type>nil(), methodClass),
290                                sym);
291                        sym.members().enter(boxMethod);
292                        MethodSymbol unboxMethod =
293                            new MethodSymbol(PUBLIC,
294                                type.tsym.name.append(names.Value), // x.intValue()
295                                new MethodType(List.<Type>nil(), type,
296                                    List.<Type>nil(), methodClass),
297                                sym);
298                        sym.members().enter(unboxMethod);
299                    }
300                }
301            };
302        }
303
304    }
305
306    // Enter a synthetic class that is used to mark classes in ct.sym.
307    // This class does not have a class file.
308    private Type enterSyntheticAnnotation(String name) {
309        ClassType type = (ClassType)enterClass(name);
310        ClassSymbol sym = (ClassSymbol)type.tsym;
311        sym.completer = null;
312        sym.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
313        sym.erasure_field = type;
314        sym.members_field = WriteableScope.create(sym);
315        type.typarams_field = List.nil();
316        type.allparams_field = List.nil();
317        type.supertype_field = annotationType;
318        type.interfaces_field = List.nil();
319        return type;
320    }
321
322    /** Constructor; enters all predefined identifiers and operators
323     *  into symbol table.
324     */
325    protected Symtab(Context context) throws CompletionFailure {
326        context.put(symtabKey, this);
327
328        names = Names.instance(context);
329        target = Target.instance(context);
330
331        // Create the unknown type
332        unknownType = new UnknownType();
333
334        // create the basic builtin symbols
335        rootPackage = new PackageSymbol(names.empty, null);
336        packages.put(names.empty, rootPackage);
337        final JavacMessages messages = JavacMessages.instance(context);
338        unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
339                public String toString() {
340                    return messages.getLocalizedString("compiler.misc.unnamed.package");
341                }
342            };
343        noSymbol = new TypeSymbol(NIL, 0, names.empty, Type.noType, rootPackage) {
344            @DefinedBy(Api.LANGUAGE_MODEL)
345            public <R, P> R accept(ElementVisitor<R, P> v, P p) {
346                return v.visitUnknown(this, p);
347            }
348        };
349
350        // create the error symbols
351        errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
352        errType = new ErrorType(errSymbol, Type.noType);
353
354        unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
355        unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol);
356        unknownSymbol.type = unknownType;
357
358        // initialize builtin types
359        initType(byteType, "byte", "Byte");
360        initType(shortType, "short", "Short");
361        initType(charType, "char", "Character");
362        initType(intType, "int", "Integer");
363        initType(longType, "long", "Long");
364        initType(floatType, "float", "Float");
365        initType(doubleType, "double", "Double");
366        initType(booleanType, "boolean", "Boolean");
367        initType(voidType, "void", "Void");
368        initType(botType, "<nulltype>");
369        initType(errType, errSymbol);
370        initType(unknownType, unknownSymbol);
371
372        // the builtin class of all arrays
373        arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
374
375        // VGJ
376        boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
377        boundClass.members_field = new Scope.ErrorScope(boundClass);
378
379        // the builtin class of all methods
380        methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
381        methodClass.members_field = new Scope.ErrorScope(boundClass);
382
383        // Create class to hold all predefined constants and operations.
384        predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
385        WriteableScope scope = WriteableScope.create(predefClass);
386        predefClass.members_field = scope;
387
388        // Get the initial completer for Symbols from the ClassFinder
389        initialCompleter = ClassFinder.instance(context).getCompleter();
390        rootPackage.completer = initialCompleter;
391        unnamedPackage.completer = initialCompleter;
392
393        // Enter symbols for basic types.
394        scope.enter(byteType.tsym);
395        scope.enter(shortType.tsym);
396        scope.enter(charType.tsym);
397        scope.enter(intType.tsym);
398        scope.enter(longType.tsym);
399        scope.enter(floatType.tsym);
400        scope.enter(doubleType.tsym);
401        scope.enter(booleanType.tsym);
402        scope.enter(errType.tsym);
403
404        // Enter symbol for the errSymbol
405        scope.enter(errSymbol);
406
407        classes.put(predefClass.fullname, predefClass);
408
409        // Enter predefined classes.
410        objectType = enterClass("java.lang.Object");
411        classType = enterClass("java.lang.Class");
412        stringType = enterClass("java.lang.String");
413        stringBufferType = enterClass("java.lang.StringBuffer");
414        stringBuilderType = enterClass("java.lang.StringBuilder");
415        cloneableType = enterClass("java.lang.Cloneable");
416        throwableType = enterClass("java.lang.Throwable");
417        serializableType = enterClass("java.io.Serializable");
418        serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
419        methodHandleType = enterClass("java.lang.invoke.MethodHandle");
420        methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
421        methodTypeType = enterClass("java.lang.invoke.MethodType");
422        errorType = enterClass("java.lang.Error");
423        illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
424        interruptedExceptionType = enterClass("java.lang.InterruptedException");
425        exceptionType = enterClass("java.lang.Exception");
426        runtimeExceptionType = enterClass("java.lang.RuntimeException");
427        classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
428        noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
429        noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
430        assertionErrorType = enterClass("java.lang.AssertionError");
431        cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
432        annotationType = enterClass("java.lang.annotation.Annotation");
433        classLoaderType = enterClass("java.lang.ClassLoader");
434        enumSym = enterClass(names.java_lang_Enum);
435        enumFinalFinalize =
436            new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
437                             names.finalize,
438                             new MethodType(List.<Type>nil(), voidType,
439                                            List.<Type>nil(), methodClass),
440                             enumSym);
441        listType = enterClass("java.util.List");
442        collectionsType = enterClass("java.util.Collections");
443        comparableType = enterClass("java.lang.Comparable");
444        comparatorType = enterClass("java.util.Comparator");
445        arraysType = enterClass("java.util.Arrays");
446        iterableType = enterClass("java.lang.Iterable");
447        iteratorType = enterClass("java.util.Iterator");
448        annotationTargetType = enterClass("java.lang.annotation.Target");
449        overrideType = enterClass("java.lang.Override");
450        retentionType = enterClass("java.lang.annotation.Retention");
451        deprecatedType = enterClass("java.lang.Deprecated");
452        suppressWarningsType = enterClass("java.lang.SuppressWarnings");
453        supplierType = enterClass("java.util.function.Supplier");
454        inheritedType = enterClass("java.lang.annotation.Inherited");
455        repeatableType = enterClass("java.lang.annotation.Repeatable");
456        documentedType = enterClass("java.lang.annotation.Documented");
457        elementTypeType = enterClass("java.lang.annotation.ElementType");
458        systemType = enterClass("java.lang.System");
459        autoCloseableType = enterClass("java.lang.AutoCloseable");
460        autoCloseableClose = new MethodSymbol(PUBLIC,
461                             names.close,
462                             new MethodType(List.<Type>nil(), voidType,
463                                            List.of(exceptionType), methodClass),
464                             autoCloseableType.tsym);
465        trustMeType = enterClass("java.lang.SafeVarargs");
466        nativeHeaderType = enterClass("java.lang.annotation.Native");
467        lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
468        functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
469
470        synthesizeEmptyInterfaceIfMissing(autoCloseableType);
471        synthesizeEmptyInterfaceIfMissing(cloneableType);
472        synthesizeEmptyInterfaceIfMissing(serializableType);
473        synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
474        synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
475        synthesizeBoxTypeIfMissing(doubleType);
476        synthesizeBoxTypeIfMissing(floatType);
477        synthesizeBoxTypeIfMissing(voidType);
478
479        // Enter a synthetic class that is used to mark internal
480        // proprietary classes in ct.sym.  This class does not have a
481        // class file.
482        proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
483
484        // Enter a synthetic class that is used to provide profile info for
485        // classes in ct.sym.  This class does not have a class file.
486        profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
487        MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
488        profileType.tsym.members().enter(m);
489
490        // Enter a class for arrays.
491        // The class implements java.lang.Cloneable and java.io.Serializable.
492        // It has a final length field and a clone method.
493        ClassType arrayClassType = (ClassType)arrayClass.type;
494        arrayClassType.supertype_field = objectType;
495        arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
496        arrayClass.members_field = WriteableScope.create(arrayClass);
497        lengthVar = new VarSymbol(
498            PUBLIC | FINAL,
499            names.length,
500            intType,
501            arrayClass);
502        arrayClass.members().enter(lengthVar);
503        arrayCloneMethod = new MethodSymbol(
504            PUBLIC,
505            names.clone,
506            new MethodType(List.<Type>nil(), objectType,
507                           List.<Type>nil(), methodClass),
508            arrayClass);
509        arrayClass.members().enter(arrayCloneMethod);
510    }
511
512    /** Define a new class given its name and owner.
513     */
514    public ClassSymbol defineClass(Name name, Symbol owner) {
515        ClassSymbol c = new ClassSymbol(0, name, owner);
516        if (owner.kind == PCK)
517            Assert.checkNull(classes.get(c.flatname), c);
518        c.completer = initialCompleter;
519        return c;
520    }
521
522    /** Create a new toplevel or member class symbol with given name
523     *  and owner and enter in `classes' unless already there.
524     */
525    public ClassSymbol enterClass(Name name, TypeSymbol owner) {
526        Name flatname = TypeSymbol.formFlatName(name, owner);
527        ClassSymbol c = classes.get(flatname);
528        if (c == null) {
529            c = defineClass(name, owner);
530            classes.put(flatname, c);
531        } else if ((c.name != name || c.owner != owner) && owner.kind == TYP && c.owner.kind == PCK) {
532            // reassign fields of classes that might have been loaded with
533            // their flat names.
534            c.owner.members().remove(c);
535            c.name = name;
536            c.owner = owner;
537            c.fullname = ClassSymbol.formFullName(name, owner);
538        }
539        return c;
540    }
541
542    /**
543     * Creates a new toplevel class symbol with given flat name and
544     * given class (or source) file.
545     *
546     * @param flatName a fully qualified binary class name
547     * @param classFile the class file or compilation unit defining
548     * the class (may be {@code null})
549     * @return a newly created class symbol
550     * @throws AssertionError if the class symbol already exists
551     */
552    public ClassSymbol enterClass(Name flatName, JavaFileObject classFile) {
553        ClassSymbol cs = classes.get(flatName);
554        if (cs != null) {
555            String msg = Log.format("%s: completer = %s; class file = %s; source file = %s",
556                                    cs.fullname,
557                                    cs.completer,
558                                    cs.classfile,
559                                    cs.sourcefile);
560            throw new AssertionError(msg);
561        }
562        Name packageName = Convert.packagePart(flatName);
563        PackageSymbol owner = packageName.isEmpty()
564                                ? unnamedPackage
565                                : enterPackage(packageName);
566        cs = defineClass(Convert.shortName(flatName), owner);
567        cs.classfile = classFile;
568        classes.put(flatName, cs);
569        return cs;
570    }
571
572    /** Create a new member or toplevel class symbol with given flat name
573     *  and enter in `classes' unless already there.
574     */
575    public ClassSymbol enterClass(Name flatname) {
576        ClassSymbol c = classes.get(flatname);
577        if (c == null)
578            return enterClass(flatname, (JavaFileObject)null);
579        else
580            return c;
581    }
582
583    /** Check to see if a package exists, given its fully qualified name.
584     */
585    public boolean packageExists(Name fullname) {
586        return enterPackage(fullname).exists();
587    }
588
589    /** Make a package, given its fully qualified name.
590     */
591    public PackageSymbol enterPackage(Name fullname) {
592        PackageSymbol p = packages.get(fullname);
593        if (p == null) {
594            Assert.check(!fullname.isEmpty(), "rootPackage missing!");
595            p = new PackageSymbol(
596                Convert.shortName(fullname),
597                enterPackage(Convert.packagePart(fullname)));
598            p.completer = initialCompleter;
599            packages.put(fullname, p);
600        }
601        return p;
602    }
603
604    /** Make a package, given its unqualified name and enclosing package.
605     */
606    public PackageSymbol enterPackage(Name name, PackageSymbol owner) {
607        return enterPackage(TypeSymbol.formFullName(name, owner));
608    }
609}
610