src/share/classes/com/sun/tools/javac/code/Symbol.java

Sun, 17 Feb 2013 16:44:55 -0500

author
dholmes
date
Sun, 17 Feb 2013 16:44:55 -0500
changeset 1571
af8417e590f4
parent 1565
d04960f05593
child 1607
bd49e0304281
permissions
-rw-r--r--

Merge

duke@1 1 /*
jfranck@1491 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.javac.code;
duke@1 27
duke@1 28 import java.util.Set;
duke@1 29 import java.util.concurrent.Callable;
jjg@1357 30
duke@1 31 import javax.lang.model.element.*;
duke@1 32 import javax.tools.JavaFileObject;
duke@1 33
duke@1 34 import com.sun.tools.javac.code.Type.*;
duke@1 35 import com.sun.tools.javac.comp.Attr;
duke@1 36 import com.sun.tools.javac.comp.AttrContext;
duke@1 37 import com.sun.tools.javac.comp.Env;
duke@1 38 import com.sun.tools.javac.jvm.*;
duke@1 39 import com.sun.tools.javac.model.*;
duke@1 40 import com.sun.tools.javac.tree.JCTree;
jjg@1357 41 import com.sun.tools.javac.util.*;
jjg@1357 42 import com.sun.tools.javac.util.Name;
duke@1 43 import static com.sun.tools.javac.code.Flags.*;
duke@1 44 import static com.sun.tools.javac.code.Kinds.*;
jjg@1374 45 import static com.sun.tools.javac.code.TypeTag.CLASS;
jjg@1374 46 import static com.sun.tools.javac.code.TypeTag.FORALL;
jjg@1374 47 import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
duke@1 48
duke@1 49 /** Root class for Java symbols. It contains subclasses
duke@1 50 * for specific sorts of symbols, such as variables, methods and operators,
duke@1 51 * types, packages. Each subclass is represented as a static inner class
duke@1 52 * inside Symbol.
duke@1 53 *
jjg@581 54 * <p><b>This is NOT part of any supported API.
jjg@581 55 * If you write code that depends on this, you do so at your own risk.
duke@1 56 * This code and its internal interfaces are subject to change or
duke@1 57 * deletion without notice.</b>
duke@1 58 */
duke@1 59 public abstract class Symbol implements Element {
duke@1 60 // public Throwable debug = new Throwable();
duke@1 61
duke@1 62 /** The kind of this symbol.
duke@1 63 * @see Kinds
duke@1 64 */
duke@1 65 public int kind;
duke@1 66
duke@1 67 /** The flags of this symbol.
duke@1 68 */
duke@1 69 public long flags_field;
duke@1 70
duke@1 71 /** An accessor method for the flags of this symbol.
duke@1 72 * Flags of class symbols should be accessed through the accessor
duke@1 73 * method to make sure that the class symbol is loaded.
duke@1 74 */
duke@1 75 public long flags() { return flags_field; }
duke@1 76
jfranck@1313 77 /** The attributes of this symbol are contained in this
jfranck@1313 78 * Annotations. The Annotations instance is NOT immutable.
duke@1 79 */
jfranck@1313 80 public final Annotations annotations = new Annotations(this);
duke@1 81
duke@1 82 /** An accessor method for the attributes of this symbol.
duke@1 83 * Attributes of class symbols should be accessed through the accessor
duke@1 84 * method to make sure that the class symbol is loaded.
duke@1 85 */
jfranck@1464 86 public List<Attribute.Compound> getRawAttributes() {
jjg@1521 87 return annotations.getDeclarationAttributes();
jjg@1521 88 }
jjg@1521 89
jjg@1521 90 /** An accessor method for the type attributes of this symbol.
jjg@1521 91 * Attributes of class symbols should be accessed through the accessor
jjg@1521 92 * method to make sure that the class symbol is loaded.
jjg@1521 93 */
jjg@1521 94 public List<Attribute.TypeCompound> getRawTypeAttributes() {
jjg@1521 95 return annotations.getTypeAttributes();
duke@1 96 }
duke@1 97
duke@1 98 /** Fetch a particular annotation from a symbol. */
duke@1 99 public Attribute.Compound attribute(Symbol anno) {
jfranck@1464 100 for (Attribute.Compound a : getRawAttributes()) {
duke@1 101 if (a.type.tsym == anno) return a;
jfranck@1313 102 }
duke@1 103 return null;
duke@1 104 }
duke@1 105
duke@1 106 /** The name of this symbol in Utf8 representation.
duke@1 107 */
duke@1 108 public Name name;
duke@1 109
duke@1 110 /** The type of this symbol.
duke@1 111 */
duke@1 112 public Type type;
duke@1 113
duke@1 114 /** The owner of this symbol.
duke@1 115 */
duke@1 116 public Symbol owner;
duke@1 117
duke@1 118 /** The completer of this symbol.
duke@1 119 */
duke@1 120 public Completer completer;
duke@1 121
duke@1 122 /** A cache for the type erasure of this symbol.
duke@1 123 */
duke@1 124 public Type erasure_field;
duke@1 125
duke@1 126 /** Construct a symbol with given kind, flags, name, type and owner.
duke@1 127 */
duke@1 128 public Symbol(int kind, long flags, Name name, Type type, Symbol owner) {
duke@1 129 this.kind = kind;
duke@1 130 this.flags_field = flags;
duke@1 131 this.type = type;
duke@1 132 this.owner = owner;
duke@1 133 this.completer = null;
duke@1 134 this.erasure_field = null;
duke@1 135 this.name = name;
duke@1 136 }
duke@1 137
duke@1 138 /** Clone this symbol with new owner.
duke@1 139 * Legal only for fields and methods.
duke@1 140 */
duke@1 141 public Symbol clone(Symbol newOwner) {
duke@1 142 throw new AssertionError();
duke@1 143 }
duke@1 144
mcimadamore@121 145 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 146 return v.visitSymbol(this, p);
mcimadamore@121 147 }
mcimadamore@121 148
duke@1 149 /** The Java source which this symbol represents.
duke@1 150 * A description of this symbol; overrides Object.
duke@1 151 */
duke@1 152 public String toString() {
duke@1 153 return name.toString();
duke@1 154 }
duke@1 155
duke@1 156 /** A Java source description of the location of this symbol; used for
mcimadamore@80 157 * error reporting.
mcimadamore@80 158 *
mcimadamore@80 159 * @return null if the symbol is a package or a toplevel class defined in
mcimadamore@80 160 * the default package; otherwise, the owner symbol is returned
duke@1 161 */
mcimadamore@80 162 public Symbol location() {
mcimadamore@1085 163 if (owner.name == null || (owner.name.isEmpty() &&
mcimadamore@1085 164 (owner.flags() & BLOCK) == 0 && owner.kind != PCK && owner.kind != TYP)) {
mcimadamore@80 165 return null;
duke@1 166 }
mcimadamore@80 167 return owner;
duke@1 168 }
duke@1 169
mcimadamore@80 170 public Symbol location(Type site, Types types) {
jjg@113 171 if (owner.name == null || owner.name.isEmpty()) {
duke@1 172 return location();
duke@1 173 }
jjg@1374 174 if (owner.type.hasTag(CLASS)) {
duke@1 175 Type ownertype = types.asOuterSuper(site, owner);
mcimadamore@80 176 if (ownertype != null) return ownertype.tsym;
duke@1 177 }
mcimadamore@80 178 return owner;
duke@1 179 }
duke@1 180
mcimadamore@1341 181 public Symbol baseSymbol() {
mcimadamore@1341 182 return this;
mcimadamore@1341 183 }
mcimadamore@1341 184
duke@1 185 /** The symbol's erased type.
duke@1 186 */
duke@1 187 public Type erasure(Types types) {
duke@1 188 if (erasure_field == null)
duke@1 189 erasure_field = types.erasure(type);
duke@1 190 return erasure_field;
duke@1 191 }
duke@1 192
duke@1 193 /** The external type of a symbol. This is the symbol's erased type
duke@1 194 * except for constructors of inner classes which get the enclosing
duke@1 195 * instance class added as first argument.
duke@1 196 */
duke@1 197 public Type externalType(Types types) {
duke@1 198 Type t = erasure(types);
jjg@113 199 if (name == name.table.names.init && owner.hasOuterInstance()) {
duke@1 200 Type outerThisType = types.erasure(owner.type.getEnclosingType());
duke@1 201 return new MethodType(t.getParameterTypes().prepend(outerThisType),
duke@1 202 t.getReturnType(),
duke@1 203 t.getThrownTypes(),
duke@1 204 t.tsym);
duke@1 205 } else {
duke@1 206 return t;
duke@1 207 }
duke@1 208 }
duke@1 209
duke@1 210 public boolean isStatic() {
duke@1 211 return
duke@1 212 (flags() & STATIC) != 0 ||
duke@1 213 (owner.flags() & INTERFACE) != 0 && kind != MTH;
duke@1 214 }
duke@1 215
duke@1 216 public boolean isInterface() {
duke@1 217 return (flags() & INTERFACE) != 0;
duke@1 218 }
duke@1 219
mcimadamore@1565 220 public boolean isPrivate() {
mcimadamore@1565 221 return (flags_field & Flags.AccessFlags) == PRIVATE;
mcimadamore@1565 222 }
mcimadamore@1565 223
mcimadamore@1565 224 public boolean isEnum() {
mcimadamore@1565 225 return (flags() & ENUM) != 0;
mcimadamore@1565 226 }
mcimadamore@1565 227
duke@1 228 /** Is this symbol declared (directly or indirectly) local
duke@1 229 * to a method or variable initializer?
duke@1 230 * Also includes fields of inner classes which are in
duke@1 231 * turn local to a method or variable initializer.
duke@1 232 */
duke@1 233 public boolean isLocal() {
duke@1 234 return
duke@1 235 (owner.kind & (VAR | MTH)) != 0 ||
duke@1 236 (owner.kind == TYP && owner.isLocal());
duke@1 237 }
duke@1 238
mcimadamore@537 239 /** Has this symbol an empty name? This includes anonymous
mcimadamore@537 240 * inner classses.
mcimadamore@537 241 */
mcimadamore@537 242 public boolean isAnonymous() {
mcimadamore@537 243 return name.isEmpty();
mcimadamore@537 244 }
mcimadamore@537 245
duke@1 246 /** Is this symbol a constructor?
duke@1 247 */
duke@1 248 public boolean isConstructor() {
jjg@113 249 return name == name.table.names.init;
duke@1 250 }
duke@1 251
duke@1 252 /** The fully qualified name of this symbol.
duke@1 253 * This is the same as the symbol's name except for class symbols,
duke@1 254 * which are handled separately.
duke@1 255 */
duke@1 256 public Name getQualifiedName() {
duke@1 257 return name;
duke@1 258 }
duke@1 259
duke@1 260 /** The fully qualified name of this symbol after converting to flat
duke@1 261 * representation. This is the same as the symbol's name except for
duke@1 262 * class symbols, which are handled separately.
duke@1 263 */
duke@1 264 public Name flatName() {
duke@1 265 return getQualifiedName();
duke@1 266 }
duke@1 267
duke@1 268 /** If this is a class or package, its members, otherwise null.
duke@1 269 */
duke@1 270 public Scope members() {
duke@1 271 return null;
duke@1 272 }
duke@1 273
duke@1 274 /** A class is an inner class if it it has an enclosing instance class.
duke@1 275 */
duke@1 276 public boolean isInner() {
jjg@1374 277 return type.getEnclosingType().hasTag(CLASS);
duke@1 278 }
duke@1 279
duke@1 280 /** An inner class has an outer instance if it is not an interface
duke@1 281 * it has an enclosing instance class which might be referenced from the class.
duke@1 282 * Nested classes can see instance members of their enclosing class.
duke@1 283 * Their constructors carry an additional this$n parameter, inserted
duke@1 284 * implicitly by the compiler.
duke@1 285 *
duke@1 286 * @see #isInner
duke@1 287 */
duke@1 288 public boolean hasOuterInstance() {
duke@1 289 return
jjg@1374 290 type.getEnclosingType().hasTag(CLASS) && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
duke@1 291 }
duke@1 292
duke@1 293 /** The closest enclosing class of this symbol's declaration.
duke@1 294 */
duke@1 295 public ClassSymbol enclClass() {
duke@1 296 Symbol c = this;
duke@1 297 while (c != null &&
jjg@1374 298 ((c.kind & TYP) == 0 || !c.type.hasTag(CLASS))) {
duke@1 299 c = c.owner;
duke@1 300 }
duke@1 301 return (ClassSymbol)c;
duke@1 302 }
duke@1 303
duke@1 304 /** The outermost class which indirectly owns this symbol.
duke@1 305 */
duke@1 306 public ClassSymbol outermostClass() {
duke@1 307 Symbol sym = this;
duke@1 308 Symbol prev = null;
duke@1 309 while (sym.kind != PCK) {
duke@1 310 prev = sym;
duke@1 311 sym = sym.owner;
duke@1 312 }
duke@1 313 return (ClassSymbol) prev;
duke@1 314 }
duke@1 315
duke@1 316 /** The package which indirectly owns this symbol.
duke@1 317 */
duke@1 318 public PackageSymbol packge() {
duke@1 319 Symbol sym = this;
duke@1 320 while (sym.kind != PCK) {
duke@1 321 sym = sym.owner;
duke@1 322 }
duke@1 323 return (PackageSymbol) sym;
duke@1 324 }
duke@1 325
duke@1 326 /** Is this symbol a subclass of `base'? Only defined for ClassSymbols.
duke@1 327 */
duke@1 328 public boolean isSubClass(Symbol base, Types types) {
duke@1 329 throw new AssertionError("isSubClass " + this);
duke@1 330 }
duke@1 331
duke@1 332 /** Fully check membership: hierarchy, protection, and hiding.
duke@1 333 * Does not exclude methods not inherited due to overriding.
duke@1 334 */
duke@1 335 public boolean isMemberOf(TypeSymbol clazz, Types types) {
duke@1 336 return
duke@1 337 owner == clazz ||
duke@1 338 clazz.isSubClass(owner, types) &&
duke@1 339 isInheritedIn(clazz, types) &&
duke@1 340 !hiddenIn((ClassSymbol)clazz, types);
duke@1 341 }
duke@1 342
duke@1 343 /** Is this symbol the same as or enclosed by the given class? */
duke@1 344 public boolean isEnclosedBy(ClassSymbol clazz) {
duke@1 345 for (Symbol sym = this; sym.kind != PCK; sym = sym.owner)
duke@1 346 if (sym == clazz) return true;
duke@1 347 return false;
duke@1 348 }
duke@1 349
duke@1 350 /** Check for hiding. Note that this doesn't handle multiple
duke@1 351 * (interface) inheritance. */
duke@1 352 private boolean hiddenIn(ClassSymbol clazz, Types types) {
duke@1 353 if (kind == MTH && (flags() & STATIC) == 0) return false;
duke@1 354 while (true) {
duke@1 355 if (owner == clazz) return false;
duke@1 356 Scope.Entry e = clazz.members().lookup(name);
duke@1 357 while (e.scope != null) {
duke@1 358 if (e.sym == this) return false;
duke@1 359 if (e.sym.kind == kind &&
duke@1 360 (kind != MTH ||
duke@1 361 (e.sym.flags() & STATIC) != 0 &&
duke@1 362 types.isSubSignature(e.sym.type, type)))
duke@1 363 return true;
duke@1 364 e = e.next();
duke@1 365 }
duke@1 366 Type superType = types.supertype(clazz.type);
jjg@1374 367 if (!superType.hasTag(CLASS)) return false;
duke@1 368 clazz = (ClassSymbol)superType.tsym;
duke@1 369 }
duke@1 370 }
duke@1 371
duke@1 372 /** Is this symbol inherited into a given class?
duke@1 373 * PRE: If symbol's owner is a interface,
duke@1 374 * it is already assumed that the interface is a superinterface
duke@1 375 * of given class.
duke@1 376 * @param clazz The class for which we want to establish membership.
duke@1 377 * This must be a subclass of the member's owner.
duke@1 378 */
duke@1 379 public boolean isInheritedIn(Symbol clazz, Types types) {
duke@1 380 switch ((int)(flags_field & Flags.AccessFlags)) {
duke@1 381 default: // error recovery
duke@1 382 case PUBLIC:
duke@1 383 return true;
duke@1 384 case PRIVATE:
duke@1 385 return this.owner == clazz;
duke@1 386 case PROTECTED:
duke@1 387 // we model interfaces as extending Object
duke@1 388 return (clazz.flags() & INTERFACE) == 0;
duke@1 389 case 0:
duke@1 390 PackageSymbol thisPackage = this.packge();
duke@1 391 for (Symbol sup = clazz;
duke@1 392 sup != null && sup != this.owner;
duke@1 393 sup = types.supertype(sup.type).tsym) {
jjg@1374 394 while (sup.type.hasTag(TYPEVAR))
mcimadamore@155 395 sup = sup.type.getUpperBound().tsym;
duke@1 396 if (sup.type.isErroneous())
duke@1 397 return true; // error recovery
duke@1 398 if ((sup.flags() & COMPOUND) != 0)
duke@1 399 continue;
duke@1 400 if (sup.packge() != thisPackage)
duke@1 401 return false;
duke@1 402 }
duke@1 403 return (clazz.flags() & INTERFACE) == 0;
duke@1 404 }
duke@1 405 }
duke@1 406
duke@1 407 /** The (variable or method) symbol seen as a member of given
duke@1 408 * class type`site' (this might change the symbol's type).
duke@1 409 * This is used exclusively for producing diagnostics.
duke@1 410 */
duke@1 411 public Symbol asMemberOf(Type site, Types types) {
duke@1 412 throw new AssertionError();
duke@1 413 }
duke@1 414
duke@1 415 /** Does this method symbol override `other' symbol, when both are seen as
duke@1 416 * members of class `origin'? It is assumed that _other is a member
duke@1 417 * of origin.
duke@1 418 *
duke@1 419 * It is assumed that both symbols have the same name. The static
duke@1 420 * modifier is ignored for this test.
duke@1 421 *
duke@1 422 * See JLS 8.4.6.1 (without transitivity) and 8.4.6.4
duke@1 423 */
duke@1 424 public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean checkResult) {
duke@1 425 return false;
duke@1 426 }
duke@1 427
duke@1 428 /** Complete the elaboration of this symbol's definition.
duke@1 429 */
duke@1 430 public void complete() throws CompletionFailure {
duke@1 431 if (completer != null) {
duke@1 432 Completer c = completer;
duke@1 433 completer = null;
duke@1 434 c.complete(this);
duke@1 435 }
duke@1 436 }
duke@1 437
duke@1 438 /** True if the symbol represents an entity that exists.
duke@1 439 */
duke@1 440 public boolean exists() {
duke@1 441 return true;
duke@1 442 }
duke@1 443
duke@1 444 public Type asType() {
duke@1 445 return type;
duke@1 446 }
duke@1 447
duke@1 448 public Symbol getEnclosingElement() {
duke@1 449 return owner;
duke@1 450 }
duke@1 451
duke@1 452 public ElementKind getKind() {
duke@1 453 return ElementKind.OTHER; // most unkind
duke@1 454 }
duke@1 455
duke@1 456 public Set<Modifier> getModifiers() {
mcimadamore@1415 457 long flags = flags();
mcimadamore@1415 458 return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags);
duke@1 459 }
duke@1 460
duke@1 461 public Name getSimpleName() {
duke@1 462 return name;
duke@1 463 }
duke@1 464
duke@1 465 /**
jfranck@1464 466 * This is the implementation for {@code
jfranck@1464 467 * javax.lang.model.element.Element.getAnnotationMirrors()}.
jfranck@1464 468 */
jfranck@1491 469 public final List<? extends AnnotationMirror> getAnnotationMirrors() {
jfranck@1464 470 return getRawAttributes();
jfranck@1464 471 }
jfranck@1464 472
jfranck@1464 473 /**
jjg@1521 474 * TODO: Should there be a {@code
jjg@1521 475 * javax.lang.model.element.Element.getTypeAnnotationMirrors()}.
jjg@1521 476 */
jjg@1521 477 public final List<Attribute.TypeCompound> getTypeAnnotationMirrors() {
jjg@1521 478 return getRawTypeAttributes();
jjg@1521 479 }
jjg@1521 480
jjg@1521 481 /**
duke@1 482 * @deprecated this method should never be used by javac internally.
duke@1 483 */
duke@1 484 @Deprecated
duke@1 485 public <A extends java.lang.annotation.Annotation> A getAnnotation(Class<A> annoType) {
duke@1 486 return JavacElements.getAnnotation(this, annoType);
duke@1 487 }
duke@1 488
jfranck@1491 489 // This method is part of the javax.lang.model API, do not use this in javac code.
jfranck@1564 490 public <A extends java.lang.annotation.Annotation> A[] getAnnotationsByType(Class<A> annoType) {
jfranck@1491 491 return JavacElements.getAnnotations(this, annoType);
jfranck@1491 492 }
jfranck@1491 493
duke@1 494 // TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList
duke@1 495 public java.util.List<Symbol> getEnclosedElements() {
duke@1 496 return List.nil();
duke@1 497 }
duke@1 498
duke@1 499 public List<TypeSymbol> getTypeParameters() {
duke@1 500 ListBuffer<TypeSymbol> l = ListBuffer.lb();
duke@1 501 for (Type t : type.getTypeArguments()) {
duke@1 502 l.append(t.tsym);
duke@1 503 }
duke@1 504 return l.toList();
duke@1 505 }
duke@1 506
vromero@1541 507 public static class DelegatedSymbol<T extends Symbol> extends Symbol {
vromero@1541 508 protected T other;
vromero@1541 509 public DelegatedSymbol(T other) {
duke@1 510 super(other.kind, other.flags_field, other.name, other.type, other.owner);
duke@1 511 this.other = other;
duke@1 512 }
duke@1 513 public String toString() { return other.toString(); }
mcimadamore@80 514 public Symbol location() { return other.location(); }
mcimadamore@80 515 public Symbol location(Type site, Types types) { return other.location(site, types); }
mcimadamore@1415 516 public Symbol baseSymbol() { return other; }
duke@1 517 public Type erasure(Types types) { return other.erasure(types); }
duke@1 518 public Type externalType(Types types) { return other.externalType(types); }
duke@1 519 public boolean isLocal() { return other.isLocal(); }
duke@1 520 public boolean isConstructor() { return other.isConstructor(); }
duke@1 521 public Name getQualifiedName() { return other.getQualifiedName(); }
duke@1 522 public Name flatName() { return other.flatName(); }
duke@1 523 public Scope members() { return other.members(); }
duke@1 524 public boolean isInner() { return other.isInner(); }
duke@1 525 public boolean hasOuterInstance() { return other.hasOuterInstance(); }
duke@1 526 public ClassSymbol enclClass() { return other.enclClass(); }
duke@1 527 public ClassSymbol outermostClass() { return other.outermostClass(); }
duke@1 528 public PackageSymbol packge() { return other.packge(); }
duke@1 529 public boolean isSubClass(Symbol base, Types types) { return other.isSubClass(base, types); }
duke@1 530 public boolean isMemberOf(TypeSymbol clazz, Types types) { return other.isMemberOf(clazz, types); }
duke@1 531 public boolean isEnclosedBy(ClassSymbol clazz) { return other.isEnclosedBy(clazz); }
duke@1 532 public boolean isInheritedIn(Symbol clazz, Types types) { return other.isInheritedIn(clazz, types); }
duke@1 533 public Symbol asMemberOf(Type site, Types types) { return other.asMemberOf(site, types); }
duke@1 534 public void complete() throws CompletionFailure { other.complete(); }
duke@1 535
duke@1 536 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
duke@1 537 return other.accept(v, p);
duke@1 538 }
mcimadamore@121 539
mcimadamore@121 540 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 541 return v.visitSymbol(other, p);
mcimadamore@121 542 }
vromero@1541 543
vromero@1541 544 public T getUnderlyingSymbol() {
vromero@1541 545 return other;
vromero@1541 546 }
duke@1 547 }
duke@1 548
duke@1 549 /** A class for type symbols. Type variables are represented by instances
duke@1 550 * of this class, classes and packages by instances of subclasses.
duke@1 551 */
duke@1 552 public static class TypeSymbol
duke@1 553 extends Symbol implements TypeParameterElement {
duke@1 554 // Implements TypeParameterElement because type parameters don't
duke@1 555 // have their own TypeSymbol subclass.
duke@1 556 // TODO: type parameters should have their own TypeSymbol subclass
duke@1 557
duke@1 558 public TypeSymbol(long flags, Name name, Type type, Symbol owner) {
duke@1 559 super(TYP, flags, name, type, owner);
duke@1 560 }
duke@1 561
duke@1 562 /** form a fully qualified name from a name and an owner
duke@1 563 */
duke@1 564 static public Name formFullName(Name name, Symbol owner) {
duke@1 565 if (owner == null) return name;
duke@1 566 if (((owner.kind != ERR)) &&
duke@1 567 ((owner.kind & (VAR | MTH)) != 0
jjg@1374 568 || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
duke@1 569 )) return name;
duke@1 570 Name prefix = owner.getQualifiedName();
jjg@113 571 if (prefix == null || prefix == prefix.table.names.empty)
duke@1 572 return name;
duke@1 573 else return prefix.append('.', name);
duke@1 574 }
duke@1 575
duke@1 576 /** form a fully qualified name from a name and an owner, after
duke@1 577 * converting to flat representation
duke@1 578 */
duke@1 579 static public Name formFlatName(Name name, Symbol owner) {
duke@1 580 if (owner == null ||
duke@1 581 (owner.kind & (VAR | MTH)) != 0
jjg@1374 582 || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
duke@1 583 ) return name;
duke@1 584 char sep = owner.kind == TYP ? '$' : '.';
duke@1 585 Name prefix = owner.flatName();
jjg@113 586 if (prefix == null || prefix == prefix.table.names.empty)
duke@1 587 return name;
duke@1 588 else return prefix.append(sep, name);
duke@1 589 }
duke@1 590
duke@1 591 /**
duke@1 592 * A total ordering between type symbols that refines the
duke@1 593 * class inheritance graph.
duke@1 594 *
duke@1 595 * Typevariables always precede other kinds of symbols.
duke@1 596 */
duke@1 597 public final boolean precedes(TypeSymbol that, Types types) {
duke@1 598 if (this == that)
duke@1 599 return false;
duke@1 600 if (this.type.tag == that.type.tag) {
jjg@1374 601 if (this.type.hasTag(CLASS)) {
duke@1 602 return
duke@1 603 types.rank(that.type) < types.rank(this.type) ||
duke@1 604 types.rank(that.type) == types.rank(this.type) &&
duke@1 605 that.getQualifiedName().compareTo(this.getQualifiedName()) < 0;
jjg@1374 606 } else if (this.type.hasTag(TYPEVAR)) {
duke@1 607 return types.isSubtype(this.type, that.type);
duke@1 608 }
duke@1 609 }
jjg@1374 610 return this.type.hasTag(TYPEVAR);
duke@1 611 }
duke@1 612
duke@1 613 // For type params; overridden in subclasses.
duke@1 614 public ElementKind getKind() {
duke@1 615 return ElementKind.TYPE_PARAMETER;
duke@1 616 }
duke@1 617
duke@1 618 public java.util.List<Symbol> getEnclosedElements() {
duke@1 619 List<Symbol> list = List.nil();
jjg@1374 620 if (kind == TYP && type.hasTag(TYPEVAR)) {
sundar@666 621 return list;
sundar@666 622 }
duke@1 623 for (Scope.Entry e = members().elems; e != null; e = e.sibling) {
duke@1 624 if (e.sym != null && (e.sym.flags() & SYNTHETIC) == 0 && e.sym.owner == this)
duke@1 625 list = list.prepend(e.sym);
duke@1 626 }
duke@1 627 return list;
duke@1 628 }
duke@1 629
duke@1 630 // For type params.
duke@1 631 // Perhaps not needed if getEnclosingElement can be spec'ed
duke@1 632 // to do the same thing.
duke@1 633 // TODO: getGenericElement() might not be needed
duke@1 634 public Symbol getGenericElement() {
duke@1 635 return owner;
duke@1 636 }
duke@1 637
duke@1 638 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
jjg@1374 639 Assert.check(type.hasTag(TYPEVAR)); // else override will be invoked
duke@1 640 return v.visitTypeParameter(this, p);
duke@1 641 }
duke@1 642
mcimadamore@121 643 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 644 return v.visitTypeSymbol(this, p);
mcimadamore@121 645 }
mcimadamore@121 646
duke@1 647 public List<Type> getBounds() {
duke@1 648 TypeVar t = (TypeVar)type;
duke@1 649 Type bound = t.getUpperBound();
duke@1 650 if (!bound.isCompound())
duke@1 651 return List.of(bound);
duke@1 652 ClassType ct = (ClassType)bound;
duke@1 653 if (!ct.tsym.erasure_field.isInterface()) {
duke@1 654 return ct.interfaces_field.prepend(ct.supertype_field);
duke@1 655 } else {
duke@1 656 // No superclass was given in bounds.
duke@1 657 // In this case, supertype is Object, erasure is first interface.
duke@1 658 return ct.interfaces_field;
duke@1 659 }
duke@1 660 }
duke@1 661 }
duke@1 662
duke@1 663 /** A class for package symbols
duke@1 664 */
duke@1 665 public static class PackageSymbol extends TypeSymbol
duke@1 666 implements PackageElement {
duke@1 667
duke@1 668 public Scope members_field;
duke@1 669 public Name fullname;
duke@1 670 public ClassSymbol package_info; // see bug 6443073
duke@1 671
duke@1 672 public PackageSymbol(Name name, Type type, Symbol owner) {
duke@1 673 super(0, name, type, owner);
duke@1 674 this.kind = PCK;
duke@1 675 this.members_field = null;
duke@1 676 this.fullname = formFullName(name, owner);
duke@1 677 }
duke@1 678
duke@1 679 public PackageSymbol(Name name, Symbol owner) {
duke@1 680 this(name, null, owner);
duke@1 681 this.type = new PackageType(this);
duke@1 682 }
duke@1 683
duke@1 684 public String toString() {
duke@1 685 return fullname.toString();
duke@1 686 }
duke@1 687
duke@1 688 public Name getQualifiedName() {
duke@1 689 return fullname;
duke@1 690 }
duke@1 691
duke@1 692 public boolean isUnnamed() {
duke@1 693 return name.isEmpty() && owner != null;
duke@1 694 }
duke@1 695
duke@1 696 public Scope members() {
duke@1 697 if (completer != null) complete();
duke@1 698 return members_field;
duke@1 699 }
duke@1 700
duke@1 701 public long flags() {
duke@1 702 if (completer != null) complete();
duke@1 703 return flags_field;
duke@1 704 }
duke@1 705
jfranck@1464 706 @Override
jfranck@1464 707 public List<Attribute.Compound> getRawAttributes() {
duke@1 708 if (completer != null) complete();
jjg@483 709 if (package_info != null && package_info.completer != null) {
jjg@483 710 package_info.complete();
jfranck@1464 711 mergeAttributes();
jjg@483 712 }
jfranck@1464 713 return super.getRawAttributes();
jfranck@1464 714 }
jfranck@1464 715
jfranck@1464 716 private void mergeAttributes() {
jfranck@1464 717 if (annotations.isEmpty() &&
jfranck@1464 718 !package_info.annotations.isEmpty()) {
jfranck@1464 719 annotations.setAttributes(package_info.annotations);
jfranck@1313 720 }
duke@1 721 }
duke@1 722
duke@1 723 /** A package "exists" if a type or package that exists has
duke@1 724 * been seen within it.
duke@1 725 */
duke@1 726 public boolean exists() {
duke@1 727 return (flags_field & EXISTS) != 0;
duke@1 728 }
duke@1 729
duke@1 730 public ElementKind getKind() {
duke@1 731 return ElementKind.PACKAGE;
duke@1 732 }
duke@1 733
duke@1 734 public Symbol getEnclosingElement() {
duke@1 735 return null;
duke@1 736 }
duke@1 737
duke@1 738 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
duke@1 739 return v.visitPackage(this, p);
duke@1 740 }
mcimadamore@121 741
mcimadamore@121 742 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 743 return v.visitPackageSymbol(this, p);
mcimadamore@121 744 }
duke@1 745 }
duke@1 746
duke@1 747 /** A class for class symbols
duke@1 748 */
duke@1 749 public static class ClassSymbol extends TypeSymbol implements TypeElement {
duke@1 750
duke@1 751 /** a scope for all class members; variables, methods and inner classes
duke@1 752 * type parameters are not part of this scope
duke@1 753 */
duke@1 754 public Scope members_field;
duke@1 755
duke@1 756 /** the fully qualified name of the class, i.e. pck.outer.inner.
duke@1 757 * null for anonymous classes
duke@1 758 */
duke@1 759 public Name fullname;
duke@1 760
duke@1 761 /** the fully qualified name of the class after converting to flat
duke@1 762 * representation, i.e. pck.outer$inner,
duke@1 763 * set externally for local and anonymous classes
duke@1 764 */
duke@1 765 public Name flatname;
duke@1 766
duke@1 767 /** the sourcefile where the class came from
duke@1 768 */
duke@1 769 public JavaFileObject sourcefile;
duke@1 770
duke@1 771 /** the classfile from where to load this class
duke@1 772 * this will have extension .class or .java
duke@1 773 */
duke@1 774 public JavaFileObject classfile;
duke@1 775
mcimadamore@1086 776 /** the list of translated local classes (used for generating
mcimadamore@1086 777 * InnerClasses attribute)
mcimadamore@1086 778 */
mcimadamore@1086 779 public List<ClassSymbol> trans_local;
mcimadamore@1086 780
duke@1 781 /** the constant pool of the class
duke@1 782 */
duke@1 783 public Pool pool;
duke@1 784
duke@1 785 public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
duke@1 786 super(flags, name, type, owner);
duke@1 787 this.members_field = null;
duke@1 788 this.fullname = formFullName(name, owner);
duke@1 789 this.flatname = formFlatName(name, owner);
duke@1 790 this.sourcefile = null;
duke@1 791 this.classfile = null;
duke@1 792 this.pool = null;
duke@1 793 }
duke@1 794
duke@1 795 public ClassSymbol(long flags, Name name, Symbol owner) {
duke@1 796 this(
duke@1 797 flags,
duke@1 798 name,
duke@1 799 new ClassType(Type.noType, null, null),
duke@1 800 owner);
duke@1 801 this.type.tsym = this;
duke@1 802 }
duke@1 803
duke@1 804 /** The Java source which this symbol represents.
duke@1 805 */
duke@1 806 public String toString() {
duke@1 807 return className();
duke@1 808 }
duke@1 809
duke@1 810 public long flags() {
duke@1 811 if (completer != null) complete();
duke@1 812 return flags_field;
duke@1 813 }
duke@1 814
duke@1 815 public Scope members() {
duke@1 816 if (completer != null) complete();
duke@1 817 return members_field;
duke@1 818 }
duke@1 819
jfranck@1464 820 @Override
jfranck@1464 821 public List<Attribute.Compound> getRawAttributes() {
duke@1 822 if (completer != null) complete();
jfranck@1464 823 return super.getRawAttributes();
duke@1 824 }
duke@1 825
jjg@1521 826 @Override
jjg@1521 827 public List<Attribute.TypeCompound> getRawTypeAttributes() {
jjg@1521 828 if (completer != null) complete();
jjg@1521 829 return super.getRawTypeAttributes();
jjg@1521 830 }
jjg@1521 831
duke@1 832 public Type erasure(Types types) {
duke@1 833 if (erasure_field == null)
duke@1 834 erasure_field = new ClassType(types.erasure(type.getEnclosingType()),
duke@1 835 List.<Type>nil(), this);
duke@1 836 return erasure_field;
duke@1 837 }
duke@1 838
duke@1 839 public String className() {
jjg@113 840 if (name.isEmpty())
duke@1 841 return
duke@1 842 Log.getLocalizedString("anonymous.class", flatname);
duke@1 843 else
duke@1 844 return fullname.toString();
duke@1 845 }
duke@1 846
duke@1 847 public Name getQualifiedName() {
duke@1 848 return fullname;
duke@1 849 }
duke@1 850
duke@1 851 public Name flatName() {
duke@1 852 return flatname;
duke@1 853 }
duke@1 854
duke@1 855 public boolean isSubClass(Symbol base, Types types) {
duke@1 856 if (this == base) {
duke@1 857 return true;
duke@1 858 } else if ((base.flags() & INTERFACE) != 0) {
jjg@1374 859 for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
duke@1 860 for (List<Type> is = types.interfaces(t);
duke@1 861 is.nonEmpty();
duke@1 862 is = is.tail)
duke@1 863 if (is.head.tsym.isSubClass(base, types)) return true;
duke@1 864 } else {
jjg@1374 865 for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
duke@1 866 if (t.tsym == base) return true;
duke@1 867 }
duke@1 868 return false;
duke@1 869 }
duke@1 870
duke@1 871 /** Complete the elaboration of this symbol's definition.
duke@1 872 */
duke@1 873 public void complete() throws CompletionFailure {
duke@1 874 try {
duke@1 875 super.complete();
duke@1 876 } catch (CompletionFailure ex) {
duke@1 877 // quiet error recovery
duke@1 878 flags_field |= (PUBLIC|STATIC);
jjg@110 879 this.type = new ErrorType(this, Type.noType);
duke@1 880 throw ex;
duke@1 881 }
duke@1 882 }
duke@1 883
duke@1 884 public List<Type> getInterfaces() {
duke@1 885 complete();
duke@1 886 if (type instanceof ClassType) {
duke@1 887 ClassType t = (ClassType)type;
duke@1 888 if (t.interfaces_field == null) // FIXME: shouldn't be null
duke@1 889 t.interfaces_field = List.nil();
jjg@904 890 if (t.all_interfaces_field != null)
jjg@904 891 return Type.getModelTypes(t.all_interfaces_field);
duke@1 892 return t.interfaces_field;
duke@1 893 } else {
duke@1 894 return List.nil();
duke@1 895 }
duke@1 896 }
duke@1 897
duke@1 898 public Type getSuperclass() {
duke@1 899 complete();
duke@1 900 if (type instanceof ClassType) {
duke@1 901 ClassType t = (ClassType)type;
duke@1 902 if (t.supertype_field == null) // FIXME: shouldn't be null
duke@1 903 t.supertype_field = Type.noType;
duke@1 904 // An interface has no superclass; its supertype is Object.
duke@1 905 return t.isInterface()
duke@1 906 ? Type.noType
jjg@904 907 : t.supertype_field.getModelType();
duke@1 908 } else {
duke@1 909 return Type.noType;
duke@1 910 }
duke@1 911 }
duke@1 912
duke@1 913 public ElementKind getKind() {
duke@1 914 long flags = flags();
duke@1 915 if ((flags & ANNOTATION) != 0)
duke@1 916 return ElementKind.ANNOTATION_TYPE;
duke@1 917 else if ((flags & INTERFACE) != 0)
duke@1 918 return ElementKind.INTERFACE;
duke@1 919 else if ((flags & ENUM) != 0)
duke@1 920 return ElementKind.ENUM;
duke@1 921 else
duke@1 922 return ElementKind.CLASS;
duke@1 923 }
duke@1 924
duke@1 925 public NestingKind getNestingKind() {
duke@1 926 complete();
duke@1 927 if (owner.kind == PCK)
duke@1 928 return NestingKind.TOP_LEVEL;
duke@1 929 else if (name.isEmpty())
duke@1 930 return NestingKind.ANONYMOUS;
duke@1 931 else if (owner.kind == MTH)
duke@1 932 return NestingKind.LOCAL;
duke@1 933 else
duke@1 934 return NestingKind.MEMBER;
duke@1 935 }
duke@1 936
duke@1 937 /**
duke@1 938 * @deprecated this method should never be used by javac internally.
duke@1 939 */
duke@1 940 @Override @Deprecated
duke@1 941 public <A extends java.lang.annotation.Annotation> A getAnnotation(Class<A> annoType) {
duke@1 942 return JavacElements.getAnnotation(this, annoType);
duke@1 943 }
duke@1 944
duke@1 945 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
duke@1 946 return v.visitType(this, p);
duke@1 947 }
mcimadamore@121 948
mcimadamore@121 949 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 950 return v.visitClassSymbol(this, p);
mcimadamore@121 951 }
duke@1 952 }
duke@1 953
duke@1 954
duke@1 955 /** A class for variable symbols
duke@1 956 */
duke@1 957 public static class VarSymbol extends Symbol implements VariableElement {
duke@1 958
duke@1 959 /** The variable's declaration position.
duke@1 960 */
duke@1 961 public int pos = Position.NOPOS;
duke@1 962
duke@1 963 /** The variable's address. Used for different purposes during
duke@1 964 * flow analysis, translation and code generation.
duke@1 965 * Flow analysis:
duke@1 966 * If this is a blank final or local variable, its sequence number.
duke@1 967 * Translation:
duke@1 968 * If this is a private field, its access number.
duke@1 969 * Code generation:
duke@1 970 * If this is a local variable, its logical slot number.
duke@1 971 */
duke@1 972 public int adr = -1;
duke@1 973
duke@1 974 /** Construct a variable symbol, given its flags, name, type and owner.
duke@1 975 */
duke@1 976 public VarSymbol(long flags, Name name, Type type, Symbol owner) {
duke@1 977 super(VAR, flags, name, type, owner);
duke@1 978 }
duke@1 979
duke@1 980 /** Clone this symbol with new owner.
duke@1 981 */
duke@1 982 public VarSymbol clone(Symbol newOwner) {
mcimadamore@1352 983 VarSymbol v = new VarSymbol(flags_field, name, type, newOwner) {
mcimadamore@1352 984 @Override
mcimadamore@1352 985 public Symbol baseSymbol() {
mcimadamore@1352 986 return VarSymbol.this;
mcimadamore@1352 987 }
mcimadamore@1352 988 };
duke@1 989 v.pos = pos;
duke@1 990 v.adr = adr;
duke@1 991 v.data = data;
duke@1 992 // System.out.println("clone " + v + " in " + newOwner);//DEBUG
duke@1 993 return v;
duke@1 994 }
duke@1 995
duke@1 996 public String toString() {
duke@1 997 return name.toString();
duke@1 998 }
duke@1 999
duke@1 1000 public Symbol asMemberOf(Type site, Types types) {
duke@1 1001 return new VarSymbol(flags_field, name, types.memberType(site, this), owner);
duke@1 1002 }
duke@1 1003
duke@1 1004 public ElementKind getKind() {
duke@1 1005 long flags = flags();
duke@1 1006 if ((flags & PARAMETER) != 0) {
duke@1 1007 if (isExceptionParameter())
duke@1 1008 return ElementKind.EXCEPTION_PARAMETER;
duke@1 1009 else
duke@1 1010 return ElementKind.PARAMETER;
duke@1 1011 } else if ((flags & ENUM) != 0) {
duke@1 1012 return ElementKind.ENUM_CONSTANT;
duke@1 1013 } else if (owner.kind == TYP || owner.kind == ERR) {
duke@1 1014 return ElementKind.FIELD;
sundar@697 1015 } else if (isResourceVariable()) {
sundar@697 1016 return ElementKind.RESOURCE_VARIABLE;
duke@1 1017 } else {
duke@1 1018 return ElementKind.LOCAL_VARIABLE;
duke@1 1019 }
duke@1 1020 }
duke@1 1021
duke@1 1022 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
duke@1 1023 return v.visitVariable(this, p);
duke@1 1024 }
duke@1 1025
duke@1 1026 public Object getConstantValue() { // Mirror API
duke@1 1027 return Constants.decode(getConstValue(), type);
duke@1 1028 }
duke@1 1029
duke@1 1030 public void setLazyConstValue(final Env<AttrContext> env,
duke@1 1031 final Attr attr,
duke@1 1032 final JCTree.JCExpression initializer)
duke@1 1033 {
duke@1 1034 setData(new Callable<Object>() {
duke@1 1035 public Object call() {
jjg@841 1036 return attr.attribLazyConstantValue(env, initializer, type);
duke@1 1037 }
duke@1 1038 });
duke@1 1039 }
duke@1 1040
duke@1 1041 /**
duke@1 1042 * The variable's constant value, if this is a constant.
duke@1 1043 * Before the constant value is evaluated, it points to an
duke@1 1044 * initalizer environment. If this is not a constant, it can
duke@1 1045 * be used for other stuff.
duke@1 1046 */
duke@1 1047 private Object data;
duke@1 1048
duke@1 1049 public boolean isExceptionParameter() {
duke@1 1050 return data == ElementKind.EXCEPTION_PARAMETER;
duke@1 1051 }
duke@1 1052
darcy@609 1053 public boolean isResourceVariable() {
darcy@609 1054 return data == ElementKind.RESOURCE_VARIABLE;
darcy@609 1055 }
darcy@609 1056
duke@1 1057 public Object getConstValue() {
duke@1 1058 // TODO: Consider if getConstValue and getConstantValue can be collapsed
darcy@609 1059 if (data == ElementKind.EXCEPTION_PARAMETER ||
darcy@609 1060 data == ElementKind.RESOURCE_VARIABLE) {
duke@1 1061 return null;
duke@1 1062 } else if (data instanceof Callable<?>) {
darcy@609 1063 // In this case, this is a final variable, with an as
duke@1 1064 // yet unevaluated initializer.
duke@1 1065 Callable<?> eval = (Callable<?>)data;
duke@1 1066 data = null; // to make sure we don't evaluate this twice.
duke@1 1067 try {
duke@1 1068 data = eval.call();
duke@1 1069 } catch (Exception ex) {
duke@1 1070 throw new AssertionError(ex);
duke@1 1071 }
duke@1 1072 }
duke@1 1073 return data;
duke@1 1074 }
duke@1 1075
duke@1 1076 public void setData(Object data) {
jjg@816 1077 Assert.check(!(data instanceof Env<?>), this);
duke@1 1078 this.data = data;
duke@1 1079 }
mcimadamore@121 1080
mcimadamore@121 1081 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 1082 return v.visitVarSymbol(this, p);
mcimadamore@121 1083 }
duke@1 1084 }
duke@1 1085
duke@1 1086 /** A class for method symbols.
duke@1 1087 */
duke@1 1088 public static class MethodSymbol extends Symbol implements ExecutableElement {
duke@1 1089
duke@1 1090 /** The code of the method. */
duke@1 1091 public Code code = null;
duke@1 1092
mcimadamore@1565 1093 /** The extra (synthetic/mandated) parameters of the method. */
mcimadamore@1565 1094 public List<VarSymbol> extraParams = List.nil();
mcimadamore@1565 1095
duke@1 1096 /** The parameters of the method. */
duke@1 1097 public List<VarSymbol> params = null;
duke@1 1098
duke@1 1099 /** The names of the parameters */
duke@1 1100 public List<Name> savedParameterNames;
duke@1 1101
duke@1 1102 /** For an attribute field accessor, its default value if any.
duke@1 1103 * The value is null if none appeared in the method
duke@1 1104 * declaration.
duke@1 1105 */
duke@1 1106 public Attribute defaultValue = null;
duke@1 1107
duke@1 1108 /** Construct a method symbol, given its flags, name, type and owner.
duke@1 1109 */
duke@1 1110 public MethodSymbol(long flags, Name name, Type type, Symbol owner) {
duke@1 1111 super(MTH, flags, name, type, owner);
jjg@1374 1112 if (owner.type.hasTag(TYPEVAR)) Assert.error(owner + "." + name);
duke@1 1113 }
duke@1 1114
duke@1 1115 /** Clone this symbol with new owner.
duke@1 1116 */
duke@1 1117 public MethodSymbol clone(Symbol newOwner) {
mcimadamore@1352 1118 MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner) {
mcimadamore@1352 1119 @Override
mcimadamore@1352 1120 public Symbol baseSymbol() {
mcimadamore@1352 1121 return MethodSymbol.this;
mcimadamore@1352 1122 }
mcimadamore@1352 1123 };
duke@1 1124 m.code = code;
duke@1 1125 return m;
duke@1 1126 }
duke@1 1127
duke@1 1128 /** The Java source which this symbol represents.
duke@1 1129 */
duke@1 1130 public String toString() {
duke@1 1131 if ((flags() & BLOCK) != 0) {
duke@1 1132 return owner.name.toString();
duke@1 1133 } else {
jjg@113 1134 String s = (name == name.table.names.init)
duke@1 1135 ? owner.name.toString()
duke@1 1136 : name.toString();
duke@1 1137 if (type != null) {
jjg@1374 1138 if (type.hasTag(FORALL))
duke@1 1139 s = "<" + ((ForAll)type).getTypeArguments() + ">" + s;
duke@1 1140 s += "(" + type.argtypes((flags() & VARARGS) != 0) + ")";
duke@1 1141 }
duke@1 1142 return s;
duke@1 1143 }
duke@1 1144 }
duke@1 1145
mcimadamore@1336 1146 public boolean isDynamic() {
mcimadamore@1336 1147 return false;
mcimadamore@1336 1148 }
mcimadamore@1336 1149
duke@1 1150 /** find a symbol that this (proxy method) symbol implements.
duke@1 1151 * @param c The class whose members are searched for
duke@1 1152 * implementations
duke@1 1153 */
duke@1 1154 public Symbol implemented(TypeSymbol c, Types types) {
duke@1 1155 Symbol impl = null;
duke@1 1156 for (List<Type> is = types.interfaces(c.type);
duke@1 1157 impl == null && is.nonEmpty();
duke@1 1158 is = is.tail) {
duke@1 1159 TypeSymbol i = is.head.tsym;
mcimadamore@780 1160 impl = implementedIn(i, types);
mcimadamore@780 1161 if (impl == null)
mcimadamore@780 1162 impl = implemented(i, types);
mcimadamore@780 1163 }
mcimadamore@780 1164 return impl;
mcimadamore@780 1165 }
mcimadamore@780 1166
mcimadamore@780 1167 public Symbol implementedIn(TypeSymbol c, Types types) {
mcimadamore@780 1168 Symbol impl = null;
mcimadamore@780 1169 for (Scope.Entry e = c.members().lookup(name);
mcimadamore@780 1170 impl == null && e.scope != null;
mcimadamore@780 1171 e = e.next()) {
mcimadamore@780 1172 if (this.overrides(e.sym, (TypeSymbol)owner, types, true) &&
mcimadamore@780 1173 // FIXME: I suspect the following requires a
mcimadamore@780 1174 // subst() for a parametric return type.
mcimadamore@780 1175 types.isSameType(type.getReturnType(),
mcimadamore@780 1176 types.memberType(owner.type, e.sym).getReturnType())) {
mcimadamore@780 1177 impl = e.sym;
duke@1 1178 }
duke@1 1179 }
duke@1 1180 return impl;
duke@1 1181 }
duke@1 1182
duke@1 1183 /** Will the erasure of this method be considered by the VM to
duke@1 1184 * override the erasure of the other when seen from class `origin'?
duke@1 1185 */
duke@1 1186 public boolean binaryOverrides(Symbol _other, TypeSymbol origin, Types types) {
duke@1 1187 if (isConstructor() || _other.kind != MTH) return false;
duke@1 1188
duke@1 1189 if (this == _other) return true;
duke@1 1190 MethodSymbol other = (MethodSymbol)_other;
duke@1 1191
duke@1 1192 // check for a direct implementation
duke@1 1193 if (other.isOverridableIn((TypeSymbol)owner) &&
duke@1 1194 types.asSuper(owner.type, other.owner) != null &&
duke@1 1195 types.isSameType(erasure(types), other.erasure(types)))
duke@1 1196 return true;
duke@1 1197
duke@1 1198 // check for an inherited implementation
duke@1 1199 return
duke@1 1200 (flags() & ABSTRACT) == 0 &&
duke@1 1201 other.isOverridableIn(origin) &&
duke@1 1202 this.isMemberOf(origin, types) &&
duke@1 1203 types.isSameType(erasure(types), other.erasure(types));
duke@1 1204 }
duke@1 1205
duke@1 1206 /** The implementation of this (abstract) symbol in class origin,
duke@1 1207 * from the VM's point of view, null if method does not have an
duke@1 1208 * implementation in class.
duke@1 1209 * @param origin The class of which the implementation is a member.
duke@1 1210 */
duke@1 1211 public MethodSymbol binaryImplementation(ClassSymbol origin, Types types) {
duke@1 1212 for (TypeSymbol c = origin; c != null; c = types.supertype(c.type).tsym) {
duke@1 1213 for (Scope.Entry e = c.members().lookup(name);
duke@1 1214 e.scope != null;
duke@1 1215 e = e.next()) {
duke@1 1216 if (e.sym.kind == MTH &&
duke@1 1217 ((MethodSymbol)e.sym).binaryOverrides(this, origin, types))
duke@1 1218 return (MethodSymbol)e.sym;
duke@1 1219 }
duke@1 1220 }
duke@1 1221 return null;
duke@1 1222 }
duke@1 1223
duke@1 1224 /** Does this symbol override `other' symbol, when both are seen as
duke@1 1225 * members of class `origin'? It is assumed that _other is a member
duke@1 1226 * of origin.
duke@1 1227 *
duke@1 1228 * It is assumed that both symbols have the same name. The static
duke@1 1229 * modifier is ignored for this test.
duke@1 1230 *
duke@1 1231 * See JLS 8.4.6.1 (without transitivity) and 8.4.6.4
duke@1 1232 */
duke@1 1233 public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean checkResult) {
duke@1 1234 if (isConstructor() || _other.kind != MTH) return false;
duke@1 1235
duke@1 1236 if (this == _other) return true;
duke@1 1237 MethodSymbol other = (MethodSymbol)_other;
duke@1 1238
duke@1 1239 // check for a direct implementation
duke@1 1240 if (other.isOverridableIn((TypeSymbol)owner) &&
duke@1 1241 types.asSuper(owner.type, other.owner) != null) {
duke@1 1242 Type mt = types.memberType(owner.type, this);
duke@1 1243 Type ot = types.memberType(owner.type, other);
duke@1 1244 if (types.isSubSignature(mt, ot)) {
duke@1 1245 if (!checkResult)
duke@1 1246 return true;
duke@1 1247 if (types.returnTypeSubstitutable(mt, ot))
duke@1 1248 return true;
duke@1 1249 }
duke@1 1250 }
duke@1 1251
duke@1 1252 // check for an inherited implementation
duke@1 1253 if ((flags() & ABSTRACT) != 0 ||
mcimadamore@1415 1254 ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
mcimadamore@1393 1255 !other.isOverridableIn(origin) ||
mcimadamore@1393 1256 !this.isMemberOf(origin, types))
duke@1 1257 return false;
duke@1 1258
duke@1 1259 // assert types.asSuper(origin.type, other.owner) != null;
duke@1 1260 Type mt = types.memberType(origin.type, this);
duke@1 1261 Type ot = types.memberType(origin.type, other);
duke@1 1262 return
duke@1 1263 types.isSubSignature(mt, ot) &&
mcimadamore@1415 1264 (!checkResult || types.resultSubtype(mt, ot, types.noWarnings));
duke@1 1265 }
duke@1 1266
duke@1 1267 private boolean isOverridableIn(TypeSymbol origin) {
jjh@972 1268 // JLS 8.4.6.1
duke@1 1269 switch ((int)(flags_field & Flags.AccessFlags)) {
duke@1 1270 case Flags.PRIVATE:
duke@1 1271 return false;
duke@1 1272 case Flags.PUBLIC:
mcimadamore@1513 1273 return !this.owner.isInterface() ||
mcimadamore@1513 1274 (flags_field & STATIC) == 0;
duke@1 1275 case Flags.PROTECTED:
duke@1 1276 return (origin.flags() & INTERFACE) == 0;
duke@1 1277 case 0:
duke@1 1278 // for package private: can only override in the same
duke@1 1279 // package
duke@1 1280 return
duke@1 1281 this.packge() == origin.packge() &&
duke@1 1282 (origin.flags() & INTERFACE) == 0;
duke@1 1283 default:
duke@1 1284 return false;
duke@1 1285 }
duke@1 1286 }
duke@1 1287
mcimadamore@1513 1288 @Override
mcimadamore@1513 1289 public boolean isInheritedIn(Symbol clazz, Types types) {
mcimadamore@1513 1290 switch ((int)(flags_field & Flags.AccessFlags)) {
mcimadamore@1513 1291 case PUBLIC:
mcimadamore@1513 1292 return !this.owner.isInterface() ||
mcimadamore@1513 1293 clazz == owner ||
mcimadamore@1513 1294 (flags_field & STATIC) == 0;
mcimadamore@1513 1295 default:
mcimadamore@1513 1296 return super.isInheritedIn(clazz, types);
mcimadamore@1513 1297 }
mcimadamore@1513 1298 }
mcimadamore@1513 1299
duke@1 1300 /** The implementation of this (abstract) symbol in class origin;
duke@1 1301 * null if none exists. Synthetic methods are not considered
duke@1 1302 * as possible implementations.
duke@1 1303 */
duke@1 1304 public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) {
mcimadamore@673 1305 return implementation(origin, types, checkResult, implementation_filter);
mcimadamore@673 1306 }
mcimadamore@673 1307 // where
mcimadamore@673 1308 private static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
mcimadamore@673 1309 public boolean accepts(Symbol s) {
mcimadamore@673 1310 return s.kind == Kinds.MTH &&
mcimadamore@673 1311 (s.flags() & SYNTHETIC) == 0;
mcimadamore@673 1312 }
mcimadamore@673 1313 };
mcimadamore@673 1314
mcimadamore@673 1315 public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
mcimadamore@858 1316 MethodSymbol res = types.implementation(this, origin, checkResult, implFilter);
mcimadamore@341 1317 if (res != null)
mcimadamore@341 1318 return res;
duke@1 1319 // if origin is derived from a raw type, we might have missed
duke@1 1320 // an implementation because we do not know enough about instantiations.
duke@1 1321 // in this case continue with the supertype as origin.
mcimadamore@1222 1322 if (types.isDerivedRaw(origin.type) && !origin.isInterface())
duke@1 1323 return implementation(types.supertype(origin.type).tsym, types, checkResult);
duke@1 1324 else
duke@1 1325 return null;
duke@1 1326 }
duke@1 1327
duke@1 1328 public List<VarSymbol> params() {
duke@1 1329 owner.complete();
duke@1 1330 if (params == null) {
jjg@428 1331 // If ClassReader.saveParameterNames has been set true, then
jjg@428 1332 // savedParameterNames will be set to a list of names that
jjg@428 1333 // matches the types in type.getParameterTypes(). If any names
jjg@428 1334 // were not found in the class file, those names in the list will
jjg@428 1335 // be set to the empty name.
jjg@428 1336 // If ClassReader.saveParameterNames has been set false, then
jjg@428 1337 // savedParameterNames will be null.
jjg@428 1338 List<Name> paramNames = savedParameterNames;
duke@1 1339 savedParameterNames = null;
jjg@428 1340 // discard the provided names if the list of names is the wrong size.
jjg@1473 1341 if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
jjg@428 1342 paramNames = List.nil();
jjg@1473 1343 }
duke@1 1344 ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
jjg@428 1345 List<Name> remaining = paramNames;
jjg@428 1346 // assert: remaining and paramNames are both empty or both
jjg@428 1347 // have same cardinality as type.getParameterTypes()
jjg@428 1348 int i = 0;
duke@1 1349 for (Type t : type.getParameterTypes()) {
jjg@428 1350 Name paramName;
jjg@428 1351 if (remaining.isEmpty()) {
jjg@428 1352 // no names for any parameters available
jjg@428 1353 paramName = createArgName(i, paramNames);
jjg@428 1354 } else {
jjg@428 1355 paramName = remaining.head;
jjg@428 1356 remaining = remaining.tail;
jjg@428 1357 if (paramName.isEmpty()) {
jjg@428 1358 // no name for this specific parameter
jjg@428 1359 paramName = createArgName(i, paramNames);
jjg@428 1360 }
jjg@428 1361 }
jjg@428 1362 buf.append(new VarSymbol(PARAMETER, paramName, t, this));
jjg@428 1363 i++;
duke@1 1364 }
duke@1 1365 params = buf.toList();
duke@1 1366 }
duke@1 1367 return params;
duke@1 1368 }
duke@1 1369
jjg@428 1370 // Create a name for the argument at position 'index' that is not in
jjg@428 1371 // the exclude list. In normal use, either no names will have been
jjg@428 1372 // provided, in which case the exclude list is empty, or all the names
jjg@428 1373 // will have been provided, in which case this method will not be called.
jjg@428 1374 private Name createArgName(int index, List<Name> exclude) {
jjg@428 1375 String prefix = "arg";
jjg@428 1376 while (true) {
jjg@428 1377 Name argName = name.table.fromString(prefix + index);
jjg@428 1378 if (!exclude.contains(argName))
jjg@428 1379 return argName;
jjg@428 1380 prefix += "$";
jjg@428 1381 }
jjg@428 1382 }
jjg@428 1383
duke@1 1384 public Symbol asMemberOf(Type site, Types types) {
duke@1 1385 return new MethodSymbol(flags_field, name, types.memberType(site, this), owner);
duke@1 1386 }
duke@1 1387
duke@1 1388 public ElementKind getKind() {
jjg@113 1389 if (name == name.table.names.init)
duke@1 1390 return ElementKind.CONSTRUCTOR;
jjg@113 1391 else if (name == name.table.names.clinit)
duke@1 1392 return ElementKind.STATIC_INIT;
mcimadamore@1085 1393 else if ((flags() & BLOCK) != 0)
mcimadamore@1085 1394 return isStatic() ? ElementKind.STATIC_INIT : ElementKind.INSTANCE_INIT;
duke@1 1395 else
duke@1 1396 return ElementKind.METHOD;
duke@1 1397 }
duke@1 1398
mcimadamore@1085 1399 public boolean isStaticOrInstanceInit() {
mcimadamore@1085 1400 return getKind() == ElementKind.STATIC_INIT ||
mcimadamore@1085 1401 getKind() == ElementKind.INSTANCE_INIT;
mcimadamore@1085 1402 }
mcimadamore@1085 1403
mcimadamore@1239 1404 /**
mcimadamore@1239 1405 * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that
mcimadamore@1239 1406 * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes
mcimadamore@1239 1407 * a single variable arity parameter (iii) whose declared type is Object[],
mcimadamore@1239 1408 * (iv) has a return type of Object and (v) is native.
mcimadamore@1239 1409 */
mcimadamore@1239 1410 public boolean isSignaturePolymorphic(Types types) {
mcimadamore@1239 1411 List<Type> argtypes = type.getParameterTypes();
mcimadamore@1239 1412 Type firstElemType = argtypes.nonEmpty() ?
mcimadamore@1239 1413 types.elemtype(argtypes.head) :
mcimadamore@1239 1414 null;
mcimadamore@1239 1415 return owner == types.syms.methodHandleType.tsym &&
mcimadamore@1239 1416 argtypes.length() == 1 &&
mcimadamore@1239 1417 firstElemType != null &&
mcimadamore@1239 1418 types.isSameType(firstElemType, types.syms.objectType) &&
mcimadamore@1239 1419 types.isSameType(type.getReturnType(), types.syms.objectType) &&
mcimadamore@1239 1420 (flags() & NATIVE) != 0;
mcimadamore@1239 1421 }
mcimadamore@1239 1422
duke@1 1423 public Attribute getDefaultValue() {
duke@1 1424 return defaultValue;
duke@1 1425 }
duke@1 1426
jjg@1521 1427 public List<VarSymbol> getParameters() {
duke@1 1428 return params();
duke@1 1429 }
duke@1 1430
duke@1 1431 public boolean isVarArgs() {
duke@1 1432 return (flags() & VARARGS) != 0;
duke@1 1433 }
duke@1 1434
darcy@1459 1435 public boolean isDefault() {
darcy@1459 1436 return (flags() & DEFAULT) != 0;
darcy@1459 1437 }
darcy@1459 1438
duke@1 1439 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
duke@1 1440 return v.visitExecutable(this, p);
duke@1 1441 }
duke@1 1442
mcimadamore@121 1443 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 1444 return v.visitMethodSymbol(this, p);
mcimadamore@121 1445 }
mcimadamore@121 1446
duke@1 1447 public Type getReturnType() {
duke@1 1448 return asType().getReturnType();
duke@1 1449 }
duke@1 1450
duke@1 1451 public List<Type> getThrownTypes() {
duke@1 1452 return asType().getThrownTypes();
duke@1 1453 }
duke@1 1454 }
duke@1 1455
mcimadamore@1336 1456 /** A class for invokedynamic method calls.
mcimadamore@1336 1457 */
mcimadamore@1336 1458 public static class DynamicMethodSymbol extends MethodSymbol {
mcimadamore@1336 1459
mcimadamore@1336 1460 public Object[] staticArgs;
mcimadamore@1336 1461 public Symbol bsm;
mcimadamore@1336 1462 public int bsmKind;
mcimadamore@1336 1463
mcimadamore@1336 1464 public DynamicMethodSymbol(Name name, Symbol owner, int bsmKind, MethodSymbol bsm, Type type, Object[] staticArgs) {
mcimadamore@1336 1465 super(0, name, type, owner);
mcimadamore@1336 1466 this.bsm = bsm;
mcimadamore@1336 1467 this.bsmKind = bsmKind;
mcimadamore@1336 1468 this.staticArgs = staticArgs;
mcimadamore@1336 1469 }
mcimadamore@1336 1470
mcimadamore@1336 1471 @Override
mcimadamore@1336 1472 public boolean isDynamic() {
mcimadamore@1336 1473 return true;
mcimadamore@1336 1474 }
mcimadamore@1336 1475 }
mcimadamore@1336 1476
duke@1 1477 /** A class for predefined operators.
duke@1 1478 */
duke@1 1479 public static class OperatorSymbol extends MethodSymbol {
duke@1 1480
duke@1 1481 public int opcode;
duke@1 1482
duke@1 1483 public OperatorSymbol(Name name, Type type, int opcode, Symbol owner) {
duke@1 1484 super(PUBLIC | STATIC, name, type, owner);
duke@1 1485 this.opcode = opcode;
duke@1 1486 }
mcimadamore@121 1487
mcimadamore@121 1488 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
mcimadamore@121 1489 return v.visitOperatorSymbol(this, p);
mcimadamore@121 1490 }
duke@1 1491 }
duke@1 1492
duke@1 1493 /** Symbol completer interface.
duke@1 1494 */
duke@1 1495 public static interface Completer {
duke@1 1496 void complete(Symbol sym) throws CompletionFailure;
duke@1 1497 }
duke@1 1498
duke@1 1499 public static class CompletionFailure extends RuntimeException {
duke@1 1500 private static final long serialVersionUID = 0;
duke@1 1501 public Symbol sym;
duke@1 1502
jjg@12 1503 /** A diagnostic object describing the failure
jjg@12 1504 */
jjg@12 1505 public JCDiagnostic diag;
jjg@12 1506
duke@1 1507 /** A localized string describing the failure.
jjg@12 1508 * @deprecated Use {@code getDetail()} or {@code getMessage()}
duke@1 1509 */
jjg@12 1510 @Deprecated
duke@1 1511 public String errmsg;
duke@1 1512
duke@1 1513 public CompletionFailure(Symbol sym, String errmsg) {
duke@1 1514 this.sym = sym;
duke@1 1515 this.errmsg = errmsg;
duke@1 1516 // this.printStackTrace();//DEBUG
duke@1 1517 }
duke@1 1518
jjg@12 1519 public CompletionFailure(Symbol sym, JCDiagnostic diag) {
jjg@12 1520 this.sym = sym;
jjg@12 1521 this.diag = diag;
jjg@12 1522 // this.printStackTrace();//DEBUG
jjg@12 1523 }
jjg@12 1524
jjg@12 1525 public JCDiagnostic getDiagnostic() {
jjg@12 1526 return diag;
jjg@12 1527 }
jjg@12 1528
jjg@12 1529 @Override
duke@1 1530 public String getMessage() {
jjg@12 1531 if (diag != null)
jjg@12 1532 return diag.getMessage(null);
jjg@12 1533 else
jjg@12 1534 return errmsg;
jjg@12 1535 }
jjg@12 1536
jjg@12 1537 public Object getDetailValue() {
jjg@12 1538 return (diag != null ? diag : errmsg);
duke@1 1539 }
duke@1 1540
duke@1 1541 @Override
duke@1 1542 public CompletionFailure initCause(Throwable cause) {
duke@1 1543 super.initCause(cause);
duke@1 1544 return this;
duke@1 1545 }
duke@1 1546
duke@1 1547 }
mcimadamore@121 1548
mcimadamore@121 1549 /**
mcimadamore@121 1550 * A visitor for symbols. A visitor is used to implement operations
mcimadamore@121 1551 * (or relations) on symbols. Most common operations on types are
mcimadamore@121 1552 * binary relations and this interface is designed for binary
mcimadamore@121 1553 * relations, that is, operations on the form
mcimadamore@121 1554 * Symbol&nbsp;&times;&nbsp;P&nbsp;&rarr;&nbsp;R.
mcimadamore@121 1555 * <!-- In plain text: Type x P -> R -->
mcimadamore@121 1556 *
mcimadamore@121 1557 * @param <R> the return type of the operation implemented by this
mcimadamore@121 1558 * visitor; use Void if no return type is needed.
mcimadamore@121 1559 * @param <P> the type of the second argument (the first being the
mcimadamore@121 1560 * symbol itself) of the operation implemented by this visitor; use
mcimadamore@121 1561 * Void if a second argument is not needed.
mcimadamore@121 1562 */
mcimadamore@121 1563 public interface Visitor<R,P> {
mcimadamore@121 1564 R visitClassSymbol(ClassSymbol s, P arg);
mcimadamore@121 1565 R visitMethodSymbol(MethodSymbol s, P arg);
mcimadamore@121 1566 R visitPackageSymbol(PackageSymbol s, P arg);
mcimadamore@121 1567 R visitOperatorSymbol(OperatorSymbol s, P arg);
mcimadamore@121 1568 R visitVarSymbol(VarSymbol s, P arg);
mcimadamore@121 1569 R visitTypeSymbol(TypeSymbol s, P arg);
mcimadamore@121 1570 R visitSymbol(Symbol s, P arg);
mcimadamore@121 1571 }
duke@1 1572 }

mercurial