1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.lookup;
13 import org.eclipse.jdt.core.compiler.CharOperation;
14 import org.eclipse.jdt.internal.compiler.env.IDependent;
17 Not all fields defined by this type (& its subclasses) are initialized when it is created.
18 Some are initialized only when needed.
20 Accessors have been provided for some public fields so all TypeBindings have the same API...
21 but access public fields directly whenever possible.
22 Non-public fields have accessors which should be used everywhere you expect the field to be initialized.
24 null is NOT a valid value for a non-public field... it just means the field is not initialized.
27 abstract public class ReferenceBinding extends TypeBinding implements IDependent {
28 public char[][] compoundName;
29 public char[] sourceName;
31 public PackageBinding fPackage;
34 char[] constantPoolName;
37 public FieldBinding[] availableFields() {
41 public MethodBinding[] availableMethods() {
44 /* Answer true if the receiver can be instantiated
47 public boolean canBeInstantiated() {
48 return (this.modifiers & (AccAbstract | AccInterface | AccEnum | AccAnnotation)) == 0;
50 /* Answer true if the receiver is visible to the invocationPackage.
53 public final boolean canBeSeenBy(PackageBinding invocationPackage) {
54 if (isPublic()) return true;
55 if (isPrivate()) return false;
57 // isProtected() or isDefault()
58 return invocationPackage == fPackage;
60 /* Answer true if the receiver is visible to the receiverType and the invocationType.
63 public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBinding invocationType) {
64 if (isPublic()) return true;
66 if (invocationType == this && invocationType == receiverType) return true;
70 // answer true if the invocationType is the declaringClass or they are in the same package
71 // OR the invocationType is a subclass of the declaringClass
72 // AND the invocationType is the invocationType or its subclass
73 // OR the type is a static method accessed directly through a type
74 // OR previous assertions are true for one of the enclosing type
75 if (invocationType == this) return true;
76 if (invocationType.fPackage == fPackage) return true;
78 ReferenceBinding currentType = invocationType;
79 ReferenceBinding declaringClass = enclosingType(); // protected types always have an enclosing one
80 if (declaringClass == null) return false; // could be null if incorrect top-level protected type
83 if (declaringClass == invocationType) return true;
84 if (declaringClass.isSuperclassOf(currentType)) return true;
86 currentType = currentType.enclosingType();
87 } while (currentType != null);
92 // answer true if the receiverType is the receiver or its enclosingType
93 // AND the invocationType and the receiver have a common enclosingType
95 if (!(receiverType == this || receiverType == enclosingType())) {
96 // special tolerance for type variable direct bounds
97 if (receiverType.isTypeVariable()) {
98 TypeVariableBinding typeVariable = (TypeVariableBinding) receiverType;
99 if (typeVariable.isErasureBoundTo(this.erasure()) || typeVariable.isErasureBoundTo(enclosingType().erasure())) {
108 if (invocationType != this) {
109 ReferenceBinding outerInvocationType = invocationType;
110 ReferenceBinding temp = outerInvocationType.enclosingType();
111 while (temp != null) {
112 outerInvocationType = temp;
113 temp = temp.enclosingType();
116 ReferenceBinding outerDeclaringClass = (ReferenceBinding)this.erasure();
117 temp = outerDeclaringClass.enclosingType();
118 while (temp != null) {
119 outerDeclaringClass = temp;
120 temp = temp.enclosingType();
122 if (outerInvocationType != outerDeclaringClass) return false;
128 if (invocationType.fPackage != fPackage) return false;
130 ReferenceBinding type = receiverType;
131 ReferenceBinding declaringClass = enclosingType() == null ? this : enclosingType();
133 if (declaringClass == type) return true;
134 if (fPackage != type.fPackage) return false;
135 } while ((type = type.superclass()) != null);
139 * Answer true if the receiver is visible to the type provided by the scope.
142 public final boolean canBeSeenBy(Scope scope) {
144 if (isPublic()) return true;
146 if (scope.kind == Scope.COMPILATION_UNIT_SCOPE){
147 return this.canBeSeenBy(((CompilationUnitScope)scope).fPackage);
150 SourceTypeBinding invocationType = scope.enclosingSourceType();
151 if (invocationType == this) return true;
154 // answer true if the invocationType is the declaringClass or they are in the same package
155 // OR the invocationType is a subclass of the declaringClass
156 // AND the invocationType is the invocationType or its subclass
157 // OR the type is a static method accessed directly through a type
158 // OR previous assertions are true for one of the enclosing type
159 if (invocationType.fPackage == fPackage) return true;
161 ReferenceBinding currentType = invocationType;
162 ReferenceBinding declaringClass = enclosingType(); // protected types always have an enclosing one
163 if (declaringClass == null) return false; // could be null if incorrect top-level protected type
166 if (declaringClass == invocationType) return true;
167 if (declaringClass.isSuperclassOf(currentType)) return true;
169 currentType = currentType.enclosingType();
170 } while (currentType != null);
174 // answer true if the receiver and the invocationType have a common enclosingType
175 // already know they are not the identical type
176 ReferenceBinding outerInvocationType = invocationType;
177 ReferenceBinding temp = outerInvocationType.enclosingType();
178 while (temp != null) {
179 outerInvocationType = temp;
180 temp = temp.enclosingType();
183 ReferenceBinding outerDeclaringClass = (ReferenceBinding)this.erasure();
184 temp = outerDeclaringClass.enclosingType();
185 while (temp != null) {
186 outerDeclaringClass = temp;
187 temp = temp.enclosingType();
189 return outerInvocationType == outerDeclaringClass;
193 return invocationType.fPackage == fPackage;
195 public void computeId() {
197 switch (compoundName.length) {
200 if (!CharOperation.equals(JAVA, compoundName[0]))
203 // remaining types MUST be in java.*.*
204 if (!CharOperation.equals(LANG, compoundName[1])) {
205 if (CharOperation.equals(JAVA_IO_PRINTSTREAM, compoundName))
206 id = T_JavaIoPrintStream;
207 else if (CharOperation.equals(JAVA_UTIL_ITERATOR, compoundName))
208 id = T_JavaUtilIterator;
209 else if (CharOperation.equals(JAVA_IO_SERIALIZABLE, compoundName))
210 id = T_JavaIoSerializable;
214 // remaining types MUST be in java.lang.*
215 char[] typeName = compoundName[2];
216 if (typeName.length == 0) return; // just to be safe
217 switch (typeName[0]) {
219 if (CharOperation.equals(typeName, JAVA_LANG_ASSERTIONERROR[2]))
220 id = T_JavaLangAssertionError;
223 if (CharOperation.equals(typeName, JAVA_LANG_BOOLEAN[2]))
224 id = T_JavaLangBoolean;
225 else if (CharOperation.equals(typeName, JAVA_LANG_BYTE[2]))
229 if (CharOperation.equals(typeName, JAVA_LANG_CHARACTER[2]))
230 id = T_JavaLangCharacter;
231 else if (CharOperation.equals(typeName, JAVA_LANG_CLASS[2]))
232 id = T_JavaLangClass;
233 else if (CharOperation.equals(typeName, JAVA_LANG_CLASSNOTFOUNDEXCEPTION[2]))
234 id = T_JavaLangClassNotFoundException;
235 else if (CharOperation.equals(typeName, JAVA_LANG_CLONEABLE[2]))
236 id = T_JavaLangCloneable;
239 if (CharOperation.equals(typeName, JAVA_LANG_DOUBLE[2]))
240 id = T_JavaLangDouble;
241 else if (CharOperation.equals(typeName, JAVA_LANG_DEPRECATED[2]))
242 id = T_JavaLangDeprecated;
245 if (CharOperation.equals(typeName, JAVA_LANG_ERROR[2]))
246 id = T_JavaLangError;
247 else if (CharOperation.equals(typeName, JAVA_LANG_EXCEPTION[2]))
248 id = T_JavaLangException;
249 else if (CharOperation.equals(typeName, JAVA_LANG_ENUM[2]))
253 if (CharOperation.equals(typeName, JAVA_LANG_FLOAT[2]))
254 id = T_JavaLangFloat;
257 if (CharOperation.equals(typeName, JAVA_LANG_INTEGER[2]))
258 id = T_JavaLangInteger;
259 else if (CharOperation.equals(typeName, JAVA_LANG_ITERABLE[2]))
260 id = T_JavaLangIterable;
261 else if (CharOperation.equals(typeName, JAVA_LANG_ILLEGALARGUMENTEXCEPTION[2]))
262 id = T_JavaLangIllegalArgumentException;
265 if (CharOperation.equals(typeName, JAVA_LANG_LONG[2]))
269 if (CharOperation.equals(typeName, JAVA_LANG_NOCLASSDEFERROR[2]))
270 id = T_JavaLangNoClassDefError;
273 if (CharOperation.equals(typeName, JAVA_LANG_OBJECT[2]))
274 id = T_JavaLangObject;
275 else if (CharOperation.equals(typeName, JAVA_LANG_OVERRIDE[2]))
276 id = T_JavaLangOverride;
279 if (CharOperation.equals(typeName, JAVA_LANG_STRING[2]))
280 id = T_JavaLangString;
281 else if (CharOperation.equals(typeName, JAVA_LANG_STRINGBUFFER[2]))
282 id = T_JavaLangStringBuffer;
283 else if (CharOperation.equals(typeName, JAVA_LANG_STRINGBUILDER[2]))
284 id = T_JavaLangStringBuilder;
285 else if (CharOperation.equals(typeName, JAVA_LANG_SYSTEM[2]))
286 id = T_JavaLangSystem;
287 else if (CharOperation.equals(typeName, JAVA_LANG_SHORT[2]))
288 id = T_JavaLangShort;
289 else if (CharOperation.equals(typeName, JAVA_LANG_SUPPRESSWARNINGS[2]))
290 id = T_JavaLangSuppressWarnings;
293 if (CharOperation.equals(typeName, JAVA_LANG_THROWABLE[2]))
294 id = T_JavaLangThrowable;
297 if (CharOperation.equals(typeName, JAVA_LANG_VOID[2]))
304 if (!CharOperation.equals(JAVA, compoundName[0]))
306 if (!CharOperation.equals(LANG, compoundName[1]))
308 char[] packageName = compoundName[2];
309 if (packageName.length == 0) return; // just to be safe
310 typeName = compoundName[3];
311 if (typeName.length == 0) return; // just to be safe
312 if (CharOperation.equals(packageName, REFLECT)) {
313 if (CharOperation.equals(typeName, JAVA_LANG_REFLECT_CONSTRUCTOR[3]))
314 id = T_JavaLangReflectConstructor;
316 } else if (CharOperation.equals(packageName, ANNOTATION)) {
317 switch (typeName[0]) {
319 if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_ANNOTATION[3]))
320 id = T_JavaLangAnnotationAnnotation;
323 if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_DOCUMENTED[3]))
324 id = T_JavaLangAnnotationDocumented;
327 if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_ELEMENTTYPE[3]))
328 id = T_JavaLangAnnotationElementType;
331 if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_INHERITED[3]))
332 id = T_JavaLangAnnotationInherited;
335 if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_RETENTION[3]))
336 id = T_JavaLangAnnotationRetention;
337 else if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_RETENTIONPOLICY[3]))
338 id = T_JavaLangAnnotationRetentionPolicy;
341 if (CharOperation.equals(typeName, JAVA_LANG_ANNOTATION_TARGET[3]))
342 id = T_JavaLangAnnotationTarget;
349 /* Answer the receiver's constant pool name.
351 * NOTE: This method should only be used during/after code gen.
354 public char[] constantPoolName() /* java/lang/Object */ {
355 if (constantPoolName != null) return constantPoolName;
356 return constantPoolName = CharOperation.concatWith(compoundName, '/');
358 public String debugName() {
359 return (compoundName != null) ? new String(readableName()) : "UNNAMED TYPE"; //$NON-NLS-1$
361 public final int depth() {
363 ReferenceBinding current = this;
364 while ((current = current.enclosingType()) != null)
368 public final ReferenceBinding enclosingTypeAt(int relativeDepth) {
369 ReferenceBinding current = this;
370 while (relativeDepth-- > 0 && current != null)
371 current = current.enclosingType();
374 public int fieldCount() {
375 return fields().length;
377 public FieldBinding[] fields() {
381 * Find supertype which erases to a given well-known type, or null if not found
382 * (using id avoids triggering the load of well-known type: 73740)
383 * NOTE: only works for erasures of well-known types, as random other types may share
384 * same id though being distincts.
387 public ReferenceBinding findSuperTypeErasingTo(int erasureId, boolean erasureIsClass) {
389 if (erasure().id == erasureId) return this;
390 ReferenceBinding currentType = this;
391 // iterate superclass to avoid recording interfaces if searched supertype is class
392 if (erasureIsClass) {
393 while ((currentType = currentType.superclass()) != null) {
394 if (currentType.erasure().id == erasureId) return currentType;
398 ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
399 int lastPosition = -1;
401 ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
402 if (itsInterfaces != NoSuperInterfaces) {
403 if (++lastPosition == interfacesToVisit.length)
404 System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
405 interfacesToVisit[lastPosition] = itsInterfaces;
407 } while ((currentType = currentType.superclass()) != null);
409 for (int i = 0; i <= lastPosition; i++) {
410 ReferenceBinding[] interfaces = interfacesToVisit[i];
411 for (int j = 0, length = interfaces.length; j < length; j++) {
412 if ((currentType = interfaces[j]).erasure().id == erasureId)
415 ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
416 if (itsInterfaces != NoSuperInterfaces) {
417 if (++lastPosition == interfacesToVisit.length)
418 System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
419 interfacesToVisit[lastPosition] = itsInterfaces;
426 * Find supertype which erases to a given type, or null if not found
428 public ReferenceBinding findSuperTypeErasingTo(ReferenceBinding erasure) {
430 if (erasure() == erasure) return this;
431 ReferenceBinding currentType = this;
432 if (erasure.isClass()) {
433 while ((currentType = currentType.superclass()) != null) {
434 if (currentType.erasure() == erasure) return currentType;
438 ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
439 int lastPosition = -1;
441 ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
442 if (itsInterfaces != NoSuperInterfaces) {
443 if (++lastPosition == interfacesToVisit.length)
444 System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
445 interfacesToVisit[lastPosition] = itsInterfaces;
447 } while ((currentType = currentType.superclass()) != null);
449 for (int i = 0; i <= lastPosition; i++) {
450 ReferenceBinding[] interfaces = interfacesToVisit[i];
451 for (int j = 0, length = interfaces.length; j < length; j++) {
452 if ((currentType = interfaces[j]).erasure() == erasure)
455 ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
456 if (itsInterfaces != NoSuperInterfaces) {
457 if (++lastPosition == interfacesToVisit.length)
458 System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
459 interfacesToVisit[lastPosition] = itsInterfaces;
466 public final int getAccessFlags() {
467 return modifiers & AccJustFlag;
469 public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
472 public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes) {
473 return getExactMethod(selector, argumentTypes, null);
475 public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes, CompilationUnitScope refScope) {
478 public FieldBinding getField(char[] fieldName, boolean needResolve) {
482 * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
484 public char[] getFileName() {
487 public ReferenceBinding getMemberType(char[] typeName) {
488 ReferenceBinding[] memberTypes = memberTypes();
489 for (int i = memberTypes.length; --i >= 0;)
490 if (CharOperation.equals(memberTypes[i].sourceName, typeName))
491 return memberTypes[i];
494 public MethodBinding[] getMethods(char[] selector) {
497 public PackageBinding getPackage() {
500 public boolean hasMemberTypes() {
503 public TypeVariableBinding getTypeVariable(char[] variableName) {
504 TypeVariableBinding[] typeVariables = typeVariables();
505 for (int i = typeVariables.length; --i >= 0;)
506 if (CharOperation.equals(typeVariables[i].sourceName, variableName))
507 return typeVariables[i];
510 public int hashCode() {
511 // ensure ReferenceBindings hash to the same posiiton as UnresolvedReferenceBindings so they can be replaced without rehashing
512 // ALL ReferenceBindings are unique when created so equals() is the same as ==
513 return (this.compoundName == null || this.compoundName.length == 0)
515 : CharOperation.hashCode(this.compoundName[this.compoundName.length - 1]);
518 public final boolean hasRestrictedAccess() {
519 return (modifiers & AccRestrictedAccess) != 0;
522 /* Answer true if the receiver implements anInterface or is identical to anInterface.
523 * If searchHierarchy is true, then also search the receiver's superclasses.
525 * NOTE: Assume that anInterface is an interface.
527 public boolean implementsInterface(ReferenceBinding anInterface, boolean searchHierarchy) {
528 if (this == anInterface)
531 ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
532 int lastPosition = -1;
533 ReferenceBinding currentType = this;
535 ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
536 if (itsInterfaces != NoSuperInterfaces) {
537 if (++lastPosition == interfacesToVisit.length)
538 System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
539 interfacesToVisit[lastPosition] = itsInterfaces;
541 } while (searchHierarchy && (currentType = currentType.superclass()) != null);
543 for (int i = 0; i <= lastPosition; i++) {
544 ReferenceBinding[] interfaces = interfacesToVisit[i];
545 for (int j = 0, length = interfaces.length; j < length; j++) {
546 if ((currentType = interfaces[j]).isEquivalentTo(anInterface))
549 ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
550 if (itsInterfaces != NoSuperInterfaces) {
551 if (++lastPosition == interfacesToVisit.length)
552 System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
553 interfacesToVisit[lastPosition] = itsInterfaces;
559 // Internal method... assume its only sent to classes NOT interfaces
561 boolean implementsMethod(MethodBinding method) {
562 ReferenceBinding type = this;
563 while (type != null) {
564 MethodBinding[] methods = type.getMethods(method.selector);
565 for (int i = methods.length; --i >= 0;)
566 if (methods[i].areParametersEqual(method))
568 type = type.superclass();
572 /* Answer true if the receiver is an abstract type
575 public final boolean isAbstract() {
576 return (modifiers & AccAbstract) != 0;
578 public boolean isAnnotationType() {
579 return (modifiers & AccAnnotation) != 0;
581 public final boolean isAnonymousType() {
582 return (tagBits & IsAnonymousType) != 0;
584 public final boolean isBinaryBinding() {
585 return (tagBits & IsBinaryBinding) != 0;
587 public boolean isClass() {
588 return (modifiers & (AccInterface | AccAnnotation | AccEnum)) == 0;
591 * Returns true if the type hierarchy is being connected
593 public boolean isHierarchyBeingConnected() {
594 return (this.tagBits & EndHierarchyCheck) == 0 && (this.tagBits & BeginHierarchyCheck) != 0;
596 /* Answer true if the receiver type can be assigned to the argument type (right)
598 public boolean isCompatibleWith(TypeBinding otherType) {
600 if (otherType == this)
602 if (otherType.id == T_JavaLangObject)
604 if (!(otherType instanceof ReferenceBinding))
606 ReferenceBinding otherReferenceType = (ReferenceBinding) otherType;
607 if (this.isEquivalentTo(otherReferenceType)) return true;
608 if (otherReferenceType.isWildcard()) {
609 return false; // should have passed equivalence check above if wildcard
611 if (otherReferenceType.isInterface())
612 return implementsInterface(otherReferenceType, true);
613 if (isInterface()) // Explicit conversion from an interface to a class is not allowed
615 return otherReferenceType.isSuperclassOf(this);
618 /* Answer true if the receiver has default visibility
620 public final boolean isDefault() {
621 return (modifiers & (AccPublic | AccProtected | AccPrivate)) == 0;
624 /* Answer true if the receiver is a deprecated type
626 public final boolean isDeprecated() {
627 return (modifiers & AccDeprecated) != 0;
629 public boolean isEnum() {
630 return (modifiers & AccEnum) != 0;
632 /* Answer true if the receiver is final and cannot be subclassed
634 public final boolean isFinal() {
635 return (modifiers & AccFinal) != 0;
637 public boolean isInterface() {
638 // only consider strict interfaces
639 return (modifiers & (AccInterface | AccAnnotation)) == AccInterface;
642 /* Answer true if the receiver has private visibility
644 public final boolean isPrivate() {
645 return (modifiers & AccPrivate) != 0;
647 /* Answer true if the receiver has private visibility and is used locally
650 public final boolean isPrivateUsed() {
651 return (modifiers & AccPrivateUsed) != 0;
653 /* Answer true if the receiver has protected visibility
656 public final boolean isProtected() {
657 return (modifiers & AccProtected) != 0;
659 /* Answer true if the receiver has public visibility
662 public final boolean isPublic() {
663 return (modifiers & AccPublic) != 0;
665 /* Answer true if the receiver is a static member type (or toplevel)
668 public final boolean isStatic() {
669 return (modifiers & (AccStatic | AccInterface)) != 0 ||
670 (tagBits & IsNestedType) == 0;
672 /* Answer true if all float operations must adher to IEEE 754 float/double rules
675 public final boolean isStrictfp() {
676 return (modifiers & AccStrictfp) != 0;
678 /* Answer true if the receiver is in the superclass hierarchy of aType
680 * NOTE: Object.isSuperclassOf(Object) -> false
683 public boolean isSuperclassOf(ReferenceBinding otherType) {
684 while ((otherType = otherType.superclass()) != null) {
685 if (otherType.isEquivalentTo(this)) return true;
690 /* Answer true if the receiver is deprecated (or any of its enclosing types)
693 public final boolean isViewedAsDeprecated() {
694 return (modifiers & AccDeprecated) != 0 ||
695 (modifiers & AccDeprecatedImplicitly) != 0;
697 public ReferenceBinding[] memberTypes() {
698 return NoMemberTypes;
702 * Meant to be invoked on compatible types, to figure if unchecked conversion is necessary
704 public boolean needsUncheckedConversion(TypeBinding targetType) {
705 if (this == targetType) return false;
706 if (!this.isPartOfRawType()) return false;
707 if (!(targetType instanceof ReferenceBinding))
709 TypeBinding compatible = this.findSuperTypeErasingTo((ReferenceBinding)targetType.erasure());
710 if (compatible == null)
713 if (compatible.isRawType() && (targetType.isBoundParameterizedType() || targetType.isGenericType())) {
716 } while ((compatible = compatible.enclosingType()) != null && (targetType = targetType.enclosingType()) != null);
720 public MethodBinding[] methods() {
724 * Answer the source name for the type.
725 * In the case of member types, as the qualified name from its top level type.
726 * For example, for a member type N defined inside M & A: "A.M.N".
729 public char[] qualifiedSourceName() {
731 return CharOperation.concat(enclosingType().qualifiedSourceName(), sourceName(), '.');
735 public char[] readableName() /*java.lang.Object, p.X<T> */ {
737 if (isMemberType()) {
738 readableName = CharOperation.concat(enclosingType().readableName(), sourceName, '.');
740 readableName = CharOperation.concatWith(compoundName, '.');
742 TypeVariableBinding[] typeVars;
743 if ((typeVars = this.typeVariables()) != NoTypeVariables) {
744 StringBuffer nameBuffer = new StringBuffer(10);
745 nameBuffer.append(readableName).append('<');
746 for (int i = 0, length = typeVars.length; i < length; i++) {
747 if (i > 0) nameBuffer.append(',');
748 nameBuffer.append(typeVars[i].readableName());
750 nameBuffer.append('>');
751 int nameLength = nameBuffer.length();
752 readableName = new char[nameLength];
753 nameBuffer.getChars(0, nameLength, readableName, 0);
758 public char[] shortReadableName() /*Object*/ {
759 char[] shortReadableName;
760 if (isMemberType()) {
761 shortReadableName = CharOperation.concat(enclosingType().shortReadableName(), sourceName, '.');
763 shortReadableName = this.sourceName;
765 TypeVariableBinding[] typeVars;
766 if ((typeVars = this.typeVariables()) != NoTypeVariables) {
767 StringBuffer nameBuffer = new StringBuffer(10);
768 nameBuffer.append(shortReadableName).append('<');
769 for (int i = 0, length = typeVars.length; i < length; i++) {
770 if (i > 0) nameBuffer.append(',');
771 nameBuffer.append(typeVars[i].shortReadableName());
773 nameBuffer.append('>');
774 int nameLength = nameBuffer.length();
775 shortReadableName = new char[nameLength];
776 nameBuffer.getChars(0, nameLength, shortReadableName, 0);
778 return shortReadableName;
781 /* Answer the receiver's signature.
783 * NOTE: This method should only be used during/after code gen.
786 public char[] signature() /* Ljava/lang/Object; */ {
787 if (signature != null)
790 return signature = CharOperation.concat('L', constantPoolName(), ';');
792 public char[] sourceName() {
796 public ReferenceBinding superclass() {
799 public ReferenceBinding[] superInterfaces() {
800 return NoSuperInterfaces;
802 public ReferenceBinding[] syntheticEnclosingInstanceTypes() {
803 if (isStatic()) return null;
805 ReferenceBinding enclosingType = enclosingType();
806 if (enclosingType == null)
808 return new ReferenceBinding[] {enclosingType};
810 public SyntheticArgumentBinding[] syntheticOuterLocalVariables() {
811 return null; // is null if no enclosing instances are required
814 MethodBinding[] unResolvedMethods() { // for the MethodVerifier so it doesn't resolve types