<s> package org . eclipse . jdt . internal . compiler . lookup ; import java . util . Arrays ; import java . util . Comparator ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; abstract public class ReferenceBinding extends TypeBinding { public char [ ] [ ] compoundName ; public char [ ] sourceName ; public int modifiers ; public PackageBinding fPackage ; char [ ] fileName ; char [ ] constantPoolName ; char [ ] signature ; private SimpleLookupTable compatibleCache ; public static final ReferenceBinding LUB_GENERIC = new ReferenceBinding ( ) { } ; private static final Comparator FIELD_COMPARATOR = new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { char [ ] n1 = ( ( FieldBinding ) o1 ) . name ; char [ ] n2 = ( ( FieldBinding ) o2 ) . name ; return ReferenceBinding . compare ( n1 , n2 , n1 . length , n2 . length ) ; } } ; private static final Comparator METHOD_COMPARATOR = new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { MethodBinding m1 = ( MethodBinding ) o1 ; MethodBinding m2 = ( MethodBinding ) o2 ; char [ ] s1 = m1 . selector ; char [ ] s2 = m2 . selector ; int c = ReferenceBinding . compare ( s1 , s2 , s1 . length , s2 . length ) ; return c == 0 ? m1 . parameters . length - m2 . parameters . length : c ; } } ; public static FieldBinding binarySearch ( char [ ] name , FieldBinding [ ] sortedFields ) { if ( sortedFields == null ) return null ; int max = sortedFields . length ; if ( max == 0 ) return null ; int left = 0 , right = max - 1 , nameLength = name . length ; int mid = 0 ; char [ ] midName ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; int compare = compare ( name , midName = sortedFields [ mid ] . name , nameLength , midName . length ) ; if ( compare < 0 ) { right = mid - 1 ; } else if ( compare > 0 ) { left = mid + 1 ; } else { return sortedFields [ mid ] ; } } return null ; } public static long binarySearch ( char [ ] selector , MethodBinding [ ] sortedMethods ) { if ( sortedMethods == null ) return - 1 ; int max = sortedMethods . length ; if ( max == 0 ) return - 1 ; int left = 0 , right = max - 1 , selectorLength = selector . length ; int mid = 0 ; char [ ] midSelector ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; int compare = compare ( selector , midSelector = sortedMethods [ mid ] . selector , selectorLength , midSelector . length ) ; if ( compare < 0 ) { right = mid - 1 ; } else if ( compare > 0 ) { left = mid + 1 ; } else { int start = mid , end = mid ; while ( start > left && CharOperation . equals ( sortedMethods [ start - 1 ] . selector , selector ) ) { start -- ; } while ( end < right && CharOperation . equals ( sortedMethods [ end + 1 ] . selector , selector ) ) { end ++ ; } return start + ( ( long ) end << 32 ) ; } } return - 1 ; } static int compare ( char [ ] str1 , char [ ] str2 , int len1 , int len2 ) { int n = Math . min ( len1 , len2 ) ; int i = 0 ; while ( n -- != 0 ) { char c1 = str1 [ i ] ; char c2 = str2 [ i ++ ] ; if ( c1 != c2 ) { return c1 - c2 ; } } return len1 - len2 ; } public static void sortFields ( FieldBinding [ ] sortedFields , int left , int right ) { Arrays . sort ( sortedFields , left , right , FIELD_COMPARATOR ) ; } public static void sortMethods ( MethodBinding [ ] sortedMethods , int left , int right ) { Arrays . sort ( sortedMethods , left , right , METHOD_COMPARATOR ) ; } public FieldBinding [ ] availableFields ( ) { return fields ( ) ; } public MethodBinding [ ] availableMethods ( ) { return methods ( ) ; } public boolean canBeInstantiated ( ) { return ( this . modifiers & ( ClassFileConstants . AccAbstract | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) == 0 ; } public final boolean canBeSeenBy ( PackageBinding invocationPackage ) { if ( isPublic ( ) ) return true ; if ( isPrivate ( ) ) return false ; return invocationPackage == this . fPackage ; } public final boolean canBeSeenBy ( ReferenceBinding receiverType , ReferenceBinding invocationType ) { if ( isPublic ( ) ) return true ; if ( invocationType == this && invocationType == receiverType ) return true ; if ( isProtected ( ) ) { if ( invocationType == this ) return true ; if ( invocationType . fPackage == this . fPackage ) return true ; TypeBinding currentType = invocationType . erasure ( ) ; TypeBinding declaringClass = enclosingType ( ) . erasure ( ) ; if ( declaringClass == invocationType ) return true ; if ( declaringClass == null ) return false ; do { if ( currentType . findSuperTypeOriginatingFrom ( declaringClass ) != null ) return true ; currentType = currentType . enclosingType ( ) ; } while ( currentType != null ) ; return false ; } if ( isPrivate ( ) ) { receiverCheck : { if ( ! ( receiverType == this || receiverType == enclosingType ( ) ) ) { if ( receiverType . isTypeVariable ( ) ) { TypeVariableBinding typeVariable = ( TypeVariableBinding ) receiverType ; if ( typeVariable . environment . globalOptions . complianceLevel <= ClassFileConstants . JDK1_6 && ( typeVariable . isErasureBoundTo ( erasure ( ) ) || typeVariable . isErasureBoundTo ( enclosingType ( ) . erasure ( ) ) ) ) break receiverCheck ; } return false ; } } if ( invocationType != this ) { ReferenceBinding outerInvocationType = invocationType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = ( ReferenceBinding ) erasure ( ) ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } if ( outerInvocationType != outerDeclaringClass ) return false ; } return true ; } if ( invocationType . fPackage != this . fPackage ) return false ; ReferenceBinding currentType = receiverType ; TypeBinding originalDeclaringClass = ( enclosingType ( ) == null ? this : enclosingType ( ) ) . original ( ) ; do { if ( currentType . isCapture ( ) ) { if ( originalDeclaringClass == currentType . erasure ( ) . original ( ) ) return true ; } else { if ( originalDeclaringClass == currentType . original ( ) ) return true ; } PackageBinding currentPackage = currentType . fPackage ; if ( currentPackage != null && currentPackage != this . fPackage ) return false ; } while ( ( currentType = currentType . superclass ( ) ) != null ) ; return false ; } public final boolean canBeSeenBy ( Scope scope ) { if ( scope . compilationUnitScope ( ) != null && scope . compilationUnitScope ( ) . canSeeEverything ( ) ) { return true ; } if ( isPublic ( ) ) return true ; SourceTypeBinding invocationType = scope . enclosingSourceType ( ) ; if ( invocationType == this ) return true ; if ( invocationType == null ) return ! isPrivate ( ) && scope . getCurrentPackage ( ) == this . fPackage ; if ( isProtected ( ) ) { if ( invocationType . fPackage == this . fPackage ) return true ; TypeBinding declaringClass = enclosingType ( ) ; if ( declaringClass == null ) return false ; declaringClass = declaringClass . erasure ( ) ; TypeBinding currentType = invocationType . erasure ( ) ; do { if ( declaringClass == invocationType ) return true ; if ( currentType . findSuperTypeOriginatingFrom ( declaringClass ) != null ) return true ; currentType = currentType . enclosingType ( ) ; } while ( currentType != null ) ; return false ; } if ( isPrivate ( ) ) { ReferenceBinding outerInvocationType = invocationType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = ( ReferenceBinding ) erasure ( ) ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } return outerInvocationType == outerDeclaringClass ; } return invocationType . fPackage == this . fPackage ; } public char [ ] computeGenericTypeSignature ( TypeVariableBinding [ ] typeVariables ) { boolean isMemberOfGeneric = isMemberType ( ) && ( enclosingType ( ) . modifiers & ExtraCompilerModifiers . AccGenericSignature ) != 0 ; if ( typeVariables == Binding . NO_TYPE_VARIABLES && ! isMemberOfGeneric ) { return signature ( ) ; } StringBuffer sig = new StringBuffer ( 10 ) ; if ( isMemberOfGeneric ) { char [ ] typeSig = enclosingType ( ) . genericTypeSignature ( ) ; sig . append ( typeSig , 0 , typeSig . length - 1 ) ; sig . append ( '.' ) ; sig . append ( this . sourceName ) ; } else { char [ ] typeSig = signature ( ) ; sig . append ( typeSig , 0 , typeSig . length - 1 ) ; } if ( typeVariables == Binding . NO_TYPE_VARIABLES ) { sig . append ( ';' ) ; } else { sig . append ( '<' ) ; for ( int i = 0 , length = typeVariables . length ; i < length ; i ++ ) { sig . append ( typeVariables [ i ] . genericTypeSignature ( ) ) ; } sig . append ( ">;" ) ; } int sigLength = sig . length ( ) ; char [ ] result = new char [ sigLength ] ; sig . getChars ( 0 , sigLength , result , 0 ) ; return result ; } public void computeId ( ) { switch ( this . compoundName . length ) { case 3 : if ( ! CharOperation . equals ( TypeConstants . JAVA , this . compoundName [ 0 ] ) ) return ; char [ ] packageName = this . compoundName [ 1 ] ; if ( packageName . length == 0 ) return ; char [ ] typeName = this . compoundName [ 2 ] ; if ( typeName . length == 0 ) return ; if ( ! CharOperation . equals ( TypeConstants . LANG , this . compoundName [ 1 ] ) ) { switch ( packageName [ 0 ] ) { case 'i' : if ( CharOperation . equals ( packageName , TypeConstants . IO ) ) { switch ( typeName [ 0 ] ) { case 'E' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_IO_EXTERNALIZABLE [ 2 ] ) ) this . id = TypeIds . T_JavaIoExternalizable ; return ; case 'I' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_IO_IOEXCEPTION [ 2 ] ) ) this . id = TypeIds . T_JavaIoException ; return ; case 'O' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_IO_OBJECTSTREAMEXCEPTION [ 2 ] ) ) this . id = TypeIds . T_JavaIoObjectStreamException ; return ; case 'P' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_IO_PRINTSTREAM [ 2 ] ) ) this . id = TypeIds . T_JavaIoPrintStream ; return ; case 'S' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_IO_SERIALIZABLE [ 2 ] ) ) this . id = TypeIds . T_JavaIoSerializable ; return ; } } return ; case 'u' : if ( CharOperation . equals ( packageName , TypeConstants . UTIL ) ) { switch ( typeName [ 0 ] ) { case 'C' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_UTIL_COLLECTION [ 2 ] ) ) this . id = TypeIds . T_JavaUtilCollection ; return ; case 'I' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_UTIL_ITERATOR [ 2 ] ) ) this . id = TypeIds . T_JavaUtilIterator ; return ; } } return ; } return ; } switch ( typeName [ 0 ] ) { case 'A' : switch ( typeName . length ) { case 13 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_AUTOCLOSEABLE [ 2 ] ) ) this . id = TypeIds . T_JavaLangAutoCloseable ; return ; case 14 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ASSERTIONERROR [ 2 ] ) ) this . id = TypeIds . T_JavaLangAssertionError ; return ; } return ; case 'B' : switch ( typeName . length ) { case 4 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_BYTE [ 2 ] ) ) this . id = TypeIds . T_JavaLangByte ; return ; case 7 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_BOOLEAN [ 2 ] ) ) this . id = TypeIds . T_JavaLangBoolean ; return ; } return ; case 'C' : switch ( typeName . length ) { case 5 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_CLASS [ 2 ] ) ) this . id = TypeIds . T_JavaLangClass ; return ; case 9 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_CHARACTER [ 2 ] ) ) this . id = TypeIds . T_JavaLangCharacter ; else if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_CLONEABLE [ 2 ] ) ) this . id = TypeIds . T_JavaLangCloneable ; return ; case 22 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_CLASSNOTFOUNDEXCEPTION [ 2 ] ) ) this . id = TypeIds . T_JavaLangClassNotFoundException ; return ; } return ; case 'D' : switch ( typeName . length ) { case 6 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_DOUBLE [ 2 ] ) ) this . id = TypeIds . T_JavaLangDouble ; return ; case 10 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_DEPRECATED [ 2 ] ) ) this . id = TypeIds . T_JavaLangDeprecated ; return ; } return ; case 'E' : switch ( typeName . length ) { case 4 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ENUM [ 2 ] ) ) this . id = TypeIds . T_JavaLangEnum ; return ; case 5 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ERROR [ 2 ] ) ) this . id = TypeIds . T_JavaLangError ; return ; case 9 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_EXCEPTION [ 2 ] ) ) this . id = TypeIds . T_JavaLangException ; return ; } return ; case 'F' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_FLOAT [ 2 ] ) ) this . id = TypeIds . T_JavaLangFloat ; return ; case 'I' : switch ( typeName . length ) { case 7 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_INTEGER [ 2 ] ) ) this . id = TypeIds . T_JavaLangInteger ; return ; case 8 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ITERABLE [ 2 ] ) ) this . id = TypeIds . T_JavaLangIterable ; return ; case 24 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ILLEGALARGUMENTEXCEPTION [ 2 ] ) ) this . id = TypeIds . T_JavaLangIllegalArgumentException ; return ; } return ; case 'L' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_LONG [ 2 ] ) ) this . id = TypeIds . T_JavaLangLong ; return ; case 'N' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_NOCLASSDEFERROR [ 2 ] ) ) this . id = TypeIds . T_JavaLangNoClassDefError ; return ; case 'O' : switch ( typeName . length ) { case 6 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_OBJECT [ 2 ] ) ) this . id = TypeIds . T_JavaLangObject ; return ; case 8 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_OVERRIDE [ 2 ] ) ) this . id = TypeIds . T_JavaLangOverride ; return ; } return ; case 'R' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_RUNTIMEEXCEPTION [ 2 ] ) ) this . id = TypeIds . T_JavaLangRuntimeException ; break ; case 'S' : switch ( typeName . length ) { case 5 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_SHORT [ 2 ] ) ) this . id = TypeIds . T_JavaLangShort ; return ; case 6 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_STRING [ 2 ] ) ) this . id = TypeIds . T_JavaLangString ; else if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_SYSTEM [ 2 ] ) ) this . id = TypeIds . T_JavaLangSystem ; return ; case 11 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_SAFEVARARGS [ 2 ] ) ) this . id = TypeIds . T_JavaLangSafeVarargs ; return ; case 12 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_STRINGBUFFER [ 2 ] ) ) this . id = TypeIds . T_JavaLangStringBuffer ; return ; case 13 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_STRINGBUILDER [ 2 ] ) ) this . id = TypeIds . T_JavaLangStringBuilder ; return ; case 16 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_SUPPRESSWARNINGS [ 2 ] ) ) this . id = TypeIds . T_JavaLangSuppressWarnings ; return ; } return ; case 'T' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_THROWABLE [ 2 ] ) ) this . id = TypeIds . T_JavaLangThrowable ; return ; case 'V' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_VOID [ 2 ] ) ) this . id = TypeIds . T_JavaLangVoid ; return ; } break ; case 4 : if ( ! CharOperation . equals ( TypeConstants . JAVA , this . compoundName [ 0 ] ) ) return ; packageName = this . compoundName [ 1 ] ; if ( packageName . length == 0 ) return ; packageName = this . compoundName [ 2 ] ; if ( packageName . length == 0 ) return ; typeName = this . compoundName [ 3 ] ; if ( typeName . length == 0 ) return ; switch ( packageName [ 0 ] ) { case 'a' : if ( CharOperation . equals ( packageName , TypeConstants . ANNOTATION ) ) { switch ( typeName [ 0 ] ) { case 'A' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_ANNOTATION [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationAnnotation ; return ; case 'D' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_DOCUMENTED [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationDocumented ; return ; case 'E' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationElementType ; return ; case 'I' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_INHERITED [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationInherited ; return ; case 'R' : switch ( typeName . length ) { case 9 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_RETENTION [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationRetention ; return ; case 15 : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_RETENTIONPOLICY [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationRetentionPolicy ; return ; } return ; case 'T' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_ANNOTATION_TARGET [ 3 ] ) ) this . id = TypeIds . T_JavaLangAnnotationTarget ; return ; } } return ; case 'i' : if ( CharOperation . equals ( packageName , TypeConstants . INVOKE ) ) { if ( typeName . length == 0 ) return ; switch ( typeName [ 0 ] ) { case 'M' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE [ 3 ] ) ) this . id = TypeIds . T_JavaLangInvokeMethodHandlePolymorphicSignature ; return ; } } return ; case 'r' : if ( CharOperation . equals ( packageName , TypeConstants . REFLECT ) ) { switch ( typeName [ 0 ] ) { case 'C' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_REFLECT_CONSTRUCTOR [ 2 ] ) ) this . id = TypeIds . T_JavaLangReflectConstructor ; return ; case 'F' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_REFLECT_FIELD [ 2 ] ) ) this . id = TypeIds . T_JavaLangReflectField ; return ; case 'M' : if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_REFLECT_METHOD [ 2 ] ) ) this . id = TypeIds . T_JavaLangReflectMethod ; return ; } } return ; } break ; case 5 : if ( ! CharOperation . equals ( TypeConstants . JAVA , this . compoundName [ 0 ] ) ) return ; packageName = this . compoundName [ 1 ] ; if ( packageName . length == 0 ) return ; if ( CharOperation . equals ( TypeConstants . LANG , packageName ) ) { packageName = this . compoundName [ 2 ] ; if ( packageName . length == 0 ) return ; switch ( packageName [ 0 ] ) { case 'i' : if ( CharOperation . equals ( packageName , TypeConstants . INVOKE ) ) { typeName = this . compoundName [ 3 ] ; if ( typeName . length == 0 ) return ; switch ( typeName [ 0 ] ) { case 'M' : char [ ] memberTypeName = this . compoundName [ 4 ] ; if ( memberTypeName . length == 0 ) return ; if ( CharOperation . equals ( typeName , TypeConstants . JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE [ 3 ] ) && CharOperation . equals ( memberTypeName , TypeConstants . JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE [ 4 ] ) ) this . id = TypeIds . T_JavaLangInvokeMethodHandlePolymorphicSignature ; return ; } } return ; } return ; } } } public char [ ] computeUniqueKey ( boolean isLeaf ) { if ( ! isLeaf ) return signature ( ) ; return genericTypeSignature ( ) ; } public char [ ] constantPoolName ( ) { if ( this . constantPoolName != null ) return this . constantPoolName ; return this . constantPoolName = CharOperation . concatWith ( this . compoundName , '/' ) ; } public String debugName ( ) { return ( this . compoundName != null ) ? new String ( readableName ( ) ) : "UNNAMED TYPE" ; } public final int depth ( ) { int depth = 0 ; ReferenceBinding current = this ; while ( ( current = current . enclosingType ( ) ) != null ) depth ++ ; return depth ; } public boolean detectAnnotationCycle ( ) { if ( ( this . tagBits & TagBits . EndAnnotationCheck ) != 0 ) return false ; if ( ( this . tagBits & TagBits . BeginAnnotationCheck ) != 0 ) return true ; this . tagBits |= TagBits . BeginAnnotationCheck ; MethodBinding [ ] currentMethods = methods ( ) ; boolean inCycle = false ; for ( int i = 0 , l = currentMethods . length ; i < l ; i ++ ) { TypeBinding returnType = currentMethods [ i ] . returnType . leafComponentType ( ) . erasure ( ) ; if ( this == returnType ) { if ( this instanceof SourceTypeBinding ) { MethodDeclaration decl = ( MethodDeclaration ) currentMethods [ i ] . sourceMethod ( ) ; ( ( SourceTypeBinding ) this ) . scope . problemReporter ( ) . annotationCircularity ( this , this , decl != null ? decl . returnType : null ) ; } } else if ( returnType . isAnnotationType ( ) && ( ( ReferenceBinding ) returnType ) . detectAnnotationCycle ( ) ) { if ( this instanceof SourceTypeBinding ) { MethodDeclaration decl = ( MethodDeclaration ) currentMethods [ i ] . sourceMethod ( ) ; ( ( SourceTypeBinding ) this ) . scope . problemReporter ( ) . annotationCircularity ( this , returnType , decl != null ? decl . returnType : null ) ; } inCycle = true ; } } if ( inCycle ) return true ; this . tagBits |= TagBits . EndAnnotationCheck ; return false ; } public final ReferenceBinding enclosingTypeAt ( int relativeDepth ) { ReferenceBinding current = this ; while ( relativeDepth -- > 0 && current != null ) current = current . enclosingType ( ) ; return current ; } public int enumConstantCount ( ) { int count = 0 ; FieldBinding [ ] fields = fields ( ) ; for ( int i = 0 , length = fields . length ; i < length ; i ++ ) { if ( ( fields [ i ] . modifiers & ClassFileConstants . AccEnum ) != 0 ) count ++ ; } return count ; } public int fieldCount ( ) { return fields ( ) . length ; } public FieldBinding [ ] fields ( ) { return Binding . NO_FIELDS ; } public final int getAccessFlags ( ) { return this . modifiers & ExtraCompilerModifiers . AccJustFlag ; } public AnnotationBinding [ ] getAnnotations ( ) { return retrieveAnnotations ( this ) ; } public long getAnnotationTagBits ( ) { return this . tagBits ; } public int getEnclosingInstancesSlotSize ( ) { if ( isStatic ( ) ) return 0 ; return enclosingType ( ) == null ? 0 : 1 ; } public MethodBinding getExactConstructor ( TypeBinding [ ] argumentTypes ) { return null ; } public MethodBinding getExactMethod ( char [ ] selector , TypeBinding [ ] argumentTypes , CompilationUnitScope refScope ) { return null ; } public FieldBinding getField ( char [ ] fieldName , boolean needResolve ) { return null ; } public char [ ] getFileName ( ) { return this . fileName ; } public ReferenceBinding getMemberType ( char [ ] typeName ) { ReferenceBinding [ ] memberTypes = memberTypes ( ) ; for ( int i = memberTypes . length ; -- i >= 0 ; ) if ( CharOperation . equals ( memberTypes [ i ] . sourceName , typeName ) ) return memberTypes [ i ] ; return null ; } public MethodBinding [ ] getMethods ( char [ ] selector ) { return Binding . NO_METHODS ; } public MethodBinding [ ] getMethods ( char [ ] selector , int suggestedParameterLength ) { return getMethods ( selector ) ; } public int getOuterLocalVariablesSlotSize ( ) { return 0 ; } public PackageBinding getPackage ( ) { return this . fPackage ; } public TypeVariableBinding getTypeVariable ( char [ ] variableName ) { TypeVariableBinding [ ] typeVariables = typeVariables ( ) ; for ( int i = typeVariables . length ; -- i >= 0 ; ) if ( CharOperation . equals ( typeVariables [ i ] . sourceName , variableName ) ) return typeVariables [ i ] ; return null ; } public int hashCode ( ) { return ( this . compoundName == null || this . compoundName . length == 0 ) ? super . hashCode ( ) : CharOperation . hashCode ( this . compoundName [ this . compoundName . length - 1 ] ) ; } public boolean hasIncompatibleSuperType ( ReferenceBinding otherType ) { if ( this == otherType ) return false ; ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = 0 ; ReferenceBinding currentType = this ; TypeBinding match ; do { match = otherType . findSuperTypeOriginatingFrom ( currentType ) ; if ( match != null && match . isProvablyDistinct ( currentType ) ) return true ; ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) { interfacesToVisit = itsInterfaces ; nextPosition = interfacesToVisit . length ; } else { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , 0 , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + 5 ] , 0 , nextPosition ) ; nextInterface : for ( int a = 0 ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = 0 ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } while ( ( currentType = currentType . superclass ( ) ) != null ) ; for ( int i = 0 ; i < nextPosition ; i ++ ) { currentType = interfacesToVisit [ i ] ; if ( currentType == otherType ) return false ; match = otherType . findSuperTypeOriginatingFrom ( currentType ) ; if ( match != null && match . isProvablyDistinct ( currentType ) ) return true ; ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , 0 , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + 5 ] , 0 , nextPosition ) ; nextInterface : for ( int a = 0 ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = 0 ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } return false ; } public boolean hasMemberTypes ( ) { return false ; } public final boolean hasRestrictedAccess ( ) { return ( this . modifiers & ExtraCompilerModifiers . AccRestrictedAccess ) != 0 ; } public boolean implementsInterface ( ReferenceBinding anInterface , boolean searchHierarchy ) { if ( this == anInterface ) return true ; ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = 0 ; ReferenceBinding currentType = this ; do { ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) { interfacesToVisit = itsInterfaces ; nextPosition = interfacesToVisit . length ; } else { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , 0 , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + 5 ] , 0 , nextPosition ) ; nextInterface : for ( int a = 0 ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = 0 ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } while ( searchHierarchy && ( currentType = currentType . superclass ( ) ) != null ) ; for ( int i = 0 ; i < nextPosition ; i ++ ) { currentType = interfacesToVisit [ i ] ; if ( currentType . isEquivalentTo ( anInterface ) ) return true ; ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , 0 , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + 5 ] , 0 , nextPosition ) ; nextInterface : for ( int a = 0 ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = 0 ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } return false ; } boolean implementsMethod ( MethodBinding method ) { char [ ] selector = method . selector ; ReferenceBinding type = this ; while ( type != null ) { MethodBinding [ ] methods = type . methods ( ) ; long range ; if ( ( range = ReferenceBinding . binarySearch ( selector , methods ) ) >= 0 ) { int start = ( int ) range , end = ( int ) ( range >> 32 ) ; for ( int i = start ; i <= end ; i ++ ) { if ( methods [ i ] . areParametersEqual ( method ) ) return true ; } } type = type . superclass ( ) ; } return false ; } public final boolean isAbstract ( ) { return ( this . modifiers & ClassFileConstants . AccAbstract ) != 0 ; } public boolean isAnnotationType ( ) { return ( this . modifiers & ClassFileConstants . AccAnnotation ) != 0 ; } public final boolean isBinaryBinding ( ) { return ( this . tagBits & TagBits . IsBinaryBinding ) != 0 ; } public boolean isClass ( ) { return ( this . modifiers & ( ClassFileConstants . AccInterface | ClassFileConstants . AccAnnotation | ClassFileConstants . AccEnum ) ) == 0 ; } public boolean isCompatibleWith ( TypeBinding otherType ) { if ( otherType == this ) return true ; if ( otherType . id == TypeIds . T_JavaLangObject ) return true ; Object result ; if ( this . compatibleCache == null ) { this . compatibleCache = new SimpleLookupTable ( 3 ) ; result = null ; } else { result = this . compatibleCache . get ( otherType ) ; if ( result != null ) { return result == Boolean . TRUE ; } } this . compatibleCache . put ( otherType , Boolean . FALSE ) ; if ( isCompatibleWith0 ( otherType ) ) { this . compatibleCache . put ( otherType , Boolean . TRUE ) ; return true ; } return false ; } private boolean isCompatibleWith0 ( TypeBinding otherType ) { if ( otherType == this ) return true ; if ( otherType . id == TypeIds . T_JavaLangObject ) return true ; if ( isEquivalentTo ( otherType ) ) return true ; switch ( otherType . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return false ; case Binding . TYPE_PARAMETER : if ( otherType . isCapture ( ) ) { CaptureBinding otherCapture = ( CaptureBinding ) otherType ; TypeBinding otherLowerBound ; if ( ( otherLowerBound = otherCapture . lowerBound ) != null ) { if ( otherLowerBound . isArrayType ( ) ) return false ; return isCompatibleWith ( otherLowerBound ) ; } } case Binding . GENERIC_TYPE : case Binding . TYPE : case Binding . PARAMETERIZED_TYPE : case Binding . RAW_TYPE : switch ( kind ( ) ) { case Binding . GENERIC_TYPE : case Binding . PARAMETERIZED_TYPE : case Binding . RAW_TYPE : if ( erasure ( ) == otherType . erasure ( ) ) return false ; } ReferenceBinding otherReferenceType = ( ReferenceBinding ) otherType ; if ( otherReferenceType . isInterface ( ) ) return implementsInterface ( otherReferenceType , true ) ; if ( isInterface ( ) ) return false ; return otherReferenceType . isSuperclassOf ( this ) ; default : return false ; } } public final boolean isDefault ( ) { return ( this . modifiers & ( ClassFileConstants . AccPublic | ClassFileConstants . AccProtected | ClassFileConstants . AccPrivate ) ) == 0 ; } public final boolean isDeprecated ( ) { return ( this . modifiers & ClassFileConstants . AccDeprecated ) != 0 ; } public boolean isEnum ( ) { return ( this . modifiers & ClassFileConstants . AccEnum ) != 0 ; } public final boolean isFinal ( ) { return ( this . modifiers & ClassFileConstants . AccFinal ) != 0 ; } public boolean isHierarchyBeingConnected ( ) { return ( this . tagBits & TagBits . EndHierarchyCheck ) == 0 && ( this . tagBits & TagBits . BeginHierarchyCheck ) != 0 ; } public boolean isHierarchyBeingActivelyConnected ( ) { return ( this . tagBits & TagBits . EndHierarchyCheck ) == 0 && ( this . tagBits & TagBits . BeginHierarchyCheck ) != 0 && ( this . tagBits & TagBits . PauseHierarchyCheck ) == 0 ; } public boolean isHierarchyConnected ( ) { return true ; } public boolean isInterface ( ) { return ( this . modifiers & ClassFileConstants . AccInterface ) != 0 ; } public final boolean isPrivate ( ) { return ( this . modifiers & ClassFileConstants . AccPrivate ) != 0 ; } public final boolean isOrEnclosedByPrivateType ( ) { if ( isLocalType ( ) ) return true ; ReferenceBinding type = this ; while ( type != null ) { if ( ( type . modifiers & ClassFileConstants . AccPrivate ) != 0 ) return true ; type = type . enclosingType ( ) ; } return false ; } public final boolean isProtected ( ) { return ( this . modifiers & ClassFileConstants . AccProtected ) != 0 ; } public final boolean isPublic ( ) { return ( this . modifiers & ClassFileConstants . AccPublic ) != 0 ; } public final boolean isStatic ( ) { return ( this . modifiers & ( ClassFileConstants . AccStatic | ClassFileConstants . AccInterface ) ) != 0 || ( this . tagBits & TagBits . IsNestedType ) == 0 ; } public final boolean isStrictfp ( ) { return ( this . modifiers & ClassFileConstants . AccStrictfp ) != 0 ; } public boolean isSuperclassOf ( ReferenceBinding otherType ) { while ( ( otherType = otherType . superclass ( ) ) != null ) { if ( otherType . isEquivalentTo ( this ) ) return true ; } return false ; } public boolean isThrowable ( ) { ReferenceBinding current = this ; do { switch ( current . id ) { case TypeIds . T_JavaLangThrowable : case TypeIds . T_JavaLangError : case TypeIds . T_JavaLangRuntimeException : case TypeIds . T_JavaLangException : return true ; } } while ( ( current = current . superclass ( ) ) != null ) ; return false ; } public boolean isUncheckedException ( boolean includeSupertype ) { switch ( this . id ) { case TypeIds . T_JavaLangError : case TypeIds . T_JavaLangRuntimeException : return true ; case TypeIds . T_JavaLangThrowable : case TypeIds . T_JavaLangException : return includeSupertype ; } ReferenceBinding current = this ; while ( ( current = current . superclass ( ) ) != null ) { switch ( current . id ) { case TypeIds . T_JavaLangError : case TypeIds . T_JavaLangRuntimeException : return true ; case TypeIds . T_JavaLangThrowable : case TypeIds . T_JavaLangException : return false ; } } return false ; } public final boolean isUsed ( ) { return ( this . modifiers & ExtraCompilerModifiers . AccLocallyUsed ) != 0 ; } public final boolean isViewedAsDeprecated ( ) { return ( this . modifiers & ( ClassFileConstants . AccDeprecated | ExtraCompilerModifiers . AccDeprecatedImplicitly ) ) != 0 || getPackage ( ) . isViewedAsDeprecated ( ) ; } public ReferenceBinding [ ] memberTypes ( ) { return Binding . NO_MEMBER_TYPES ; } public MethodBinding [ ] methods ( ) { return Binding . NO_METHODS ; } public final ReferenceBinding outermostEnclosingType ( ) { ReferenceBinding current = this ; while ( true ) { ReferenceBinding last = current ; if ( ( current = current . enclosingType ( ) ) == null ) return last ; } } public char [ ] qualifiedSourceName ( ) { if ( isMemberType ( ) ) return CharOperation . concat ( enclosingType ( ) . qualifiedSourceName ( ) , sourceName ( ) , '.' ) ; return sourceName ( ) ; } public char [ ] readableName ( ) { char [ ] readableName ; if ( isMemberType ( ) ) { readableName = CharOperation . concat ( enclosingType ( ) . readableName ( ) , this . sourceName , '.' ) ; } else { readableName = CharOperation . concatWith ( this . compoundName , '.' ) ; } TypeVariableBinding [ ] typeVars ; if ( ( typeVars = typeVariables ( ) ) != Binding . NO_TYPE_VARIABLES ) { StringBuffer nameBuffer = new StringBuffer ( 10 ) ; nameBuffer . append ( readableName ) . append ( '<' ) ; for ( int i = 0 , length = typeVars . length ; i < length ; i ++ ) { if ( i > 0 ) nameBuffer . append ( ',' ) ; nameBuffer . append ( typeVars [ i ] . readableName ( ) ) ; } nameBuffer . append ( '>' ) ; int nameLength = nameBuffer . length ( ) ; readableName = new char [ nameLength ] ; nameBuffer . getChars ( 0 , nameLength , readableName , 0 ) ; } return readableName ; } public AnnotationHolder retrieveAnnotationHolder ( Binding binding , boolean forceInitialization ) { SimpleLookupTable store = storedAnnotations ( forceInitialization ) ; return store == null ? null : ( AnnotationHolder ) store . get ( binding ) ; } AnnotationBinding [ ] retrieveAnnotations ( Binding binding ) { AnnotationHolder holder = retrieveAnnotationHolder ( binding , true ) ; return holder == null ? Binding . NO_ANNOTATIONS : holder . getAnnotations ( ) ; } public void setAnnotations ( AnnotationBinding [ ] annotations ) { storeAnnotations ( this , annotations ) ; } public char [ ] shortReadableName ( ) { char [ ] shortReadableName ; if ( isMemberType ( ) ) { shortReadableName = CharOperation . concat ( enclosingType ( ) . shortReadableName ( ) , this . sourceName , '.' ) ; } else { shortReadableName = this . sourceName ; } TypeVariableBinding [ ] typeVars ; if ( ( typeVars = typeVariables ( ) ) != Binding . NO_TYPE_VARIABLES ) { StringBuffer nameBuffer = new StringBuffer ( 10 ) ; nameBuffer . append ( shortReadableName ) . append ( '<' ) ; for ( int i = 0 , length = typeVars . length ; i < length ; i ++ ) { if ( i > 0 ) nameBuffer . append ( ',' ) ; nameBuffer . append ( typeVars [ i ] . shortReadableName ( ) ) ; } nameBuffer . append ( '>' ) ; int nameLength = nameBuffer . length ( ) ; shortReadableName = new char [ nameLength ] ; nameBuffer . getChars ( 0 , nameLength , shortReadableName , 0 ) ; } return shortReadableName ; } public char [ ] signature ( ) { if ( this . signature != null ) return this . signature ; return this . signature = CharOperation . concat ( 'L' , constantPoolName ( ) , ';' ) ; } public char [ ] sourceName ( ) { return this . sourceName ; } void storeAnnotationHolder ( Binding binding , AnnotationHolder holder ) { if ( holder == null ) { SimpleLookupTable store = storedAnnotations ( false ) ; if ( store != null ) store . removeKey ( binding ) ; } else { SimpleLookupTable store = storedAnnotations ( true ) ; if ( store != null ) store . put ( binding , holder ) ; } } void storeAnnotations ( Binding binding , AnnotationBinding [ ] annotations ) { AnnotationHolder holder = null ; if ( annotations == null || annotations . length == 0 ) { SimpleLookupTable store = storedAnnotations ( false ) ; if ( store != null ) holder = ( AnnotationHolder ) store . get ( binding ) ; if ( holder == null ) return ; } else { SimpleLookupTable store = storedAnnotations ( true ) ; if ( store == null ) return ; holder = ( AnnotationHolder ) store . get ( binding ) ; if ( holder == null ) holder = new AnnotationHolder ( ) ; } storeAnnotationHolder ( binding , holder . setAnnotations ( annotations ) ) ; } SimpleLookupTable storedAnnotations ( boolean forceInitialize ) { return null ; } public ReferenceBinding superclass ( ) { return null ; } public ReferenceBinding [ ] superInterfaces ( ) { return Binding . NO_SUPERINTERFACES ; } public ReferenceBinding [ ] syntheticEnclosingInstanceTypes ( ) { if ( isStatic ( ) ) return null ; ReferenceBinding enclosingType = enclosingType ( ) ; if ( enclosingType == null ) return null ; return new ReferenceBinding [ ] { enclosingType } ; } public SyntheticArgumentBinding [ ] syntheticOuterLocalVariables ( ) { return null ; } MethodBinding [ ] unResolvedMethods ( ) { return methods ( ) ; } public FieldBinding [ ] unResolvedFields ( ) { return Binding . NO_FIELDS ; } public MethodBinding [ ] getAnyExtraMethods ( char [ ] selector ) { return null ; } } </s>