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