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