<s> package org . eclipse . jdt . internal . compiler . lookup ; import java . util . List ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; abstract public class TypeBinding extends Binding { public int id = TypeIds . NoId ; public long tagBits = 0 ; public final static BaseTypeBinding INT = new BaseTypeBinding ( TypeIds . T_int , TypeConstants . INT , new char [ ] { 'I' } ) ; public final static BaseTypeBinding BYTE = new BaseTypeBinding ( TypeIds . T_byte , TypeConstants . BYTE , new char [ ] { 'B' } ) ; public final static BaseTypeBinding SHORT = new BaseTypeBinding ( TypeIds . T_short , TypeConstants . SHORT , new char [ ] { 'S' } ) ; public final static BaseTypeBinding CHAR = new BaseTypeBinding ( TypeIds . T_char , TypeConstants . CHAR , new char [ ] { 'C' } ) ; public final static BaseTypeBinding LONG = new BaseTypeBinding ( TypeIds . T_long , TypeConstants . LONG , new char [ ] { 'J' } ) ; public final static BaseTypeBinding FLOAT = new BaseTypeBinding ( TypeIds . T_float , TypeConstants . FLOAT , new char [ ] { 'F' } ) ; public final static BaseTypeBinding DOUBLE = new BaseTypeBinding ( TypeIds . T_double , TypeConstants . DOUBLE , new char [ ] { 'D' } ) ; public final static BaseTypeBinding BOOLEAN = new BaseTypeBinding ( TypeIds . T_boolean , TypeConstants . BOOLEAN , new char [ ] { 'Z' } ) ; public final static BaseTypeBinding NULL = new BaseTypeBinding ( TypeIds . T_null , TypeConstants . NULL , new char [ ] { 'N' } ) ; public final static BaseTypeBinding VOID = new BaseTypeBinding ( TypeIds . T_void , TypeConstants . VOID , new char [ ] { 'V' } ) ; public static final TypeBinding wellKnownType ( Scope scope , int id ) { switch ( id ) { case TypeIds . T_boolean : return TypeBinding . BOOLEAN ; case TypeIds . T_byte : return TypeBinding . BYTE ; case TypeIds . T_char : return TypeBinding . CHAR ; case TypeIds . T_short : return TypeBinding . SHORT ; case TypeIds . T_double : return TypeBinding . DOUBLE ; case TypeIds . T_float : return TypeBinding . FLOAT ; case TypeIds . T_int : return TypeBinding . INT ; case TypeIds . T_long : return TypeBinding . LONG ; case TypeIds . T_JavaLangObject : return scope . getJavaLangObject ( ) ; case TypeIds . T_JavaLangString : return scope . getJavaLangString ( ) ; default : return null ; } } public boolean canBeInstantiated ( ) { return ! isBaseType ( ) ; } public TypeBinding capture ( Scope scope , int position ) { return this ; } public TypeBinding closestMatch ( ) { return this ; } public List collectMissingTypes ( List missingTypes ) { return missingTypes ; } public void collectSubstitutes ( Scope scope , TypeBinding actualType , InferenceContext inferenceContext , int constraint ) { } public abstract char [ ] constantPoolName ( ) ; public String debugName ( ) { return new String ( readableName ( ) ) ; } public int dimensions ( ) { return 0 ; } public ReferenceBinding enclosingType ( ) { return null ; } public TypeBinding erasure ( ) { return this ; } public ReferenceBinding findSuperTypeOriginatingFrom ( int wellKnownOriginalID , boolean originalIsClass ) { if ( ! ( this instanceof ReferenceBinding ) ) return null ; ReferenceBinding reference = ( ReferenceBinding ) this ; if ( reference . id == wellKnownOriginalID || ( original ( ) . id == wellKnownOriginalID ) ) return reference ; ReferenceBinding currentType = reference ; if ( originalIsClass ) { while ( ( currentType = currentType . superclass ( ) ) != null ) { if ( currentType . id == wellKnownOriginalID ) return currentType ; if ( currentType . original ( ) . id == wellKnownOriginalID ) return currentType ; } return null ; } ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = 0 ; 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 ( ( currentType = currentType . superclass ( ) ) != null ) ; for ( int i = 0 ; i < nextPosition ; i ++ ) { currentType = interfacesToVisit [ i ] ; if ( currentType . id == wellKnownOriginalID ) return currentType ; if ( currentType . original ( ) . id == wellKnownOriginalID ) return currentType ; 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 null ; } public TypeBinding findSuperTypeOriginatingFrom ( TypeBinding otherType ) { if ( this == otherType ) return this ; if ( otherType == null ) return null ; switch ( kind ( ) ) { case Binding . ARRAY_TYPE : ArrayBinding arrayType = ( ArrayBinding ) this ; int otherDim = otherType . dimensions ( ) ; if ( arrayType . dimensions != otherDim ) { switch ( otherType . id ) { case TypeIds . T_JavaLangObject : case TypeIds . T_JavaIoSerializable : case TypeIds . T_JavaLangCloneable : return otherType ; } if ( otherDim < arrayType . dimensions && otherType . leafComponentType ( ) . id == TypeIds . T_JavaLangObject ) { return otherType ; } return null ; } if ( ! ( arrayType . leafComponentType instanceof ReferenceBinding ) ) return null ; TypeBinding leafSuperType = arrayType . leafComponentType . findSuperTypeOriginatingFrom ( otherType . leafComponentType ( ) ) ; if ( leafSuperType == null ) return null ; return arrayType . environment ( ) . createArrayType ( leafSuperType , arrayType . dimensions ) ; case Binding . TYPE_PARAMETER : if ( isCapture ( ) ) { CaptureBinding capture = ( CaptureBinding ) this ; TypeBinding captureBound = capture . firstBound ; if ( captureBound instanceof ArrayBinding ) { TypeBinding match = captureBound . findSuperTypeOriginatingFrom ( otherType ) ; if ( match != null ) return match ; } } case Binding . TYPE : case Binding . PARAMETERIZED_TYPE : case Binding . GENERIC_TYPE : case Binding . RAW_TYPE : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : otherType = otherType . original ( ) ; if ( this == otherType ) return this ; if ( original ( ) == otherType ) return this ; ReferenceBinding currentType = ( ReferenceBinding ) this ; if ( ! otherType . isInterface ( ) ) { while ( ( currentType = currentType . superclass ( ) ) != null ) { if ( currentType == otherType ) return currentType ; if ( currentType . original ( ) == otherType ) return currentType ; } return null ; } ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = 0 ; 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 ( ( currentType = currentType . superclass ( ) ) != null ) ; for ( int i = 0 ; i < nextPosition ; i ++ ) { currentType = interfacesToVisit [ i ] ; if ( currentType == otherType ) return currentType ; if ( currentType . original ( ) == otherType ) return currentType ; 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 null ; } public TypeBinding genericCast ( TypeBinding targetType ) { if ( this == targetType ) return null ; TypeBinding targetErasure = targetType . erasure ( ) ; if ( erasure ( ) . findSuperTypeOriginatingFrom ( targetErasure ) != null ) return null ; return targetErasure ; } public char [ ] genericTypeSignature ( ) { return signature ( ) ; } public TypeBinding getErasureCompatibleType ( TypeBinding declaringClass ) { switch ( kind ( ) ) { case Binding . TYPE_PARAMETER : TypeVariableBinding variable = ( TypeVariableBinding ) this ; if ( variable . erasure ( ) . findSuperTypeOriginatingFrom ( declaringClass ) != null ) { return this ; } if ( variable . superclass != null && variable . superclass . findSuperTypeOriginatingFrom ( declaringClass ) != null ) { return variable . superclass . getErasureCompatibleType ( declaringClass ) ; } for ( int i = 0 , otherLength = variable . superInterfaces . length ; i < otherLength ; i ++ ) { ReferenceBinding superInterface = variable . superInterfaces [ i ] ; if ( superInterface . findSuperTypeOriginatingFrom ( declaringClass ) != null ) { return superInterface . getErasureCompatibleType ( declaringClass ) ; } } return this ; case Binding . INTERSECTION_TYPE : WildcardBinding intersection = ( WildcardBinding ) this ; if ( intersection . erasure ( ) . findSuperTypeOriginatingFrom ( declaringClass ) != null ) { return this ; } if ( intersection . superclass != null && intersection . superclass . findSuperTypeOriginatingFrom ( declaringClass ) != null ) { return intersection . superclass . getErasureCompatibleType ( declaringClass ) ; } for ( int i = 0 , otherLength = intersection . superInterfaces . length ; i < otherLength ; i ++ ) { ReferenceBinding superInterface = intersection . superInterfaces [ i ] ; if ( superInterface . findSuperTypeOriginatingFrom ( declaringClass ) != null ) { return superInterface . getErasureCompatibleType ( declaringClass ) ; } } return this ; default : return this ; } } public abstract PackageBinding getPackage ( ) ; void initializeForStaticImports ( ) { } public boolean isAnnotationType ( ) { return false ; } public final boolean isAnonymousType ( ) { return ( this . tagBits & TagBits . IsAnonymousType ) != 0 ; } public final boolean isArrayType ( ) { return ( this . tagBits & TagBits . IsArrayType ) != 0 ; } public final boolean isBaseType ( ) { return ( this . tagBits & TagBits . IsBaseType ) != 0 ; } public boolean isBoundParameterizedType ( ) { return ( this . tagBits & TagBits . IsBoundParameterizedType ) != 0 ; } public boolean isCapture ( ) { return false ; } public boolean isClass ( ) { return false ; } public abstract boolean isCompatibleWith ( TypeBinding right ) ; public boolean isEnum ( ) { return false ; } public boolean isEquivalentTo ( TypeBinding otherType ) { if ( this == otherType ) return true ; if ( otherType == null ) return false ; switch ( otherType . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return ( ( WildcardBinding ) otherType ) . boundCheck ( this ) ; } return false ; } public boolean isGenericType ( ) { return false ; } public final boolean isHierarchyInconsistent ( ) { return ( this . tagBits & TagBits . HierarchyHasProblems ) != 0 ; } public boolean isInterface ( ) { return false ; } public boolean isIntersectionType ( ) { return false ; } public final boolean isLocalType ( ) { return ( this . tagBits & TagBits . IsLocalType ) != 0 ; } public final boolean isMemberType ( ) { return ( this . tagBits & TagBits . IsMemberType ) != 0 ; } public final boolean isNestedType ( ) { return ( this . tagBits & TagBits . IsNestedType ) != 0 ; } public final boolean isNumericType ( ) { switch ( this . id ) { case TypeIds . T_int : case TypeIds . T_float : case TypeIds . T_double : case TypeIds . T_short : case TypeIds . T_byte : case TypeIds . T_long : case TypeIds . T_char : return true ; default : return false ; } } public final boolean isParameterizedType ( ) { return kind ( ) == Binding . PARAMETERIZED_TYPE ; } public final boolean isParameterizedTypeWithActualArguments ( ) { return ( kind ( ) == Binding . PARAMETERIZED_TYPE ) && ( ( ParameterizedTypeBinding ) this ) . arguments != null ; } public boolean isParameterizedWithOwnVariables ( ) { if ( kind ( ) != Binding . PARAMETERIZED_TYPE ) return false ; ParameterizedTypeBinding paramType = ( ParameterizedTypeBinding ) this ; if ( paramType . arguments == null ) return false ; TypeVariableBinding [ ] variables = erasure ( ) . typeVariables ( ) ; for ( int i = 0 , length = variables . length ; i < length ; i ++ ) { if ( variables [ i ] != paramType . arguments [ i ] ) return false ; } ReferenceBinding enclosing = paramType . enclosingType ( ) ; if ( enclosing != null && enclosing . erasure ( ) . isGenericType ( ) && ! enclosing . isParameterizedWithOwnVariables ( ) ) { return false ; } return true ; } private boolean isProvableDistinctSubType ( TypeBinding otherType ) { if ( otherType . isInterface ( ) ) { if ( isInterface ( ) ) return false ; if ( isArrayType ( ) || ( ( this instanceof ReferenceBinding ) && ( ( ReferenceBinding ) this ) . isFinal ( ) ) || ( isTypeVariable ( ) && ( ( TypeVariableBinding ) this ) . superclass ( ) . isFinal ( ) ) ) { return ! isCompatibleWith ( otherType ) ; } return false ; } else { if ( isInterface ( ) ) { if ( otherType . isArrayType ( ) || ( ( otherType instanceof ReferenceBinding ) && ( ( ReferenceBinding ) otherType ) . isFinal ( ) ) || ( otherType . isTypeVariable ( ) && ( ( TypeVariableBinding ) otherType ) . superclass ( ) . isFinal ( ) ) ) { return ! isCompatibleWith ( otherType ) ; } } else { if ( ! isTypeVariable ( ) && ! otherType . isTypeVariable ( ) ) { return ! isCompatibleWith ( otherType ) ; } } } return false ; } public boolean isProvablyDistinct ( TypeBinding otherType ) { if ( this == otherType ) return false ; if ( otherType == null ) return true ; switch ( kind ( ) ) { case Binding . PARAMETERIZED_TYPE : ParameterizedTypeBinding paramType = ( ParameterizedTypeBinding ) this ; switch ( otherType . kind ( ) ) { case Binding . PARAMETERIZED_TYPE : ParameterizedTypeBinding otherParamType = ( ParameterizedTypeBinding ) otherType ; if ( paramType . genericType ( ) != otherParamType . genericType ( ) ) return true ; if ( ! paramType . isStatic ( ) ) { ReferenceBinding enclosing = enclosingType ( ) ; if ( enclosing != null ) { ReferenceBinding otherEnclosing = otherParamType . enclosingType ( ) ; if ( otherEnclosing == null ) return true ; if ( ( otherEnclosing . tagBits & TagBits . HasDirectWildcard ) == 0 ) { if ( enclosing . isProvablyDistinct ( otherEnclosing ) ) return true ; } else { if ( ! enclosing . isEquivalentTo ( otherParamType . enclosingType ( ) ) ) return true ; } } } int length = paramType . arguments == null ? 0 : paramType . arguments . length ; TypeBinding [ ] otherArguments = otherParamType . arguments ; int otherLength = otherArguments == null ? 0 : otherArguments . length ; if ( otherLength != length ) return true ; for ( int i = 0 ; i < length ; i ++ ) { if ( paramType . arguments [ i ] . isProvablyDistinctTypeArgument ( otherArguments [ i ] , paramType , i ) ) return true ; } return false ; case Binding . GENERIC_TYPE : if ( paramType . genericType ( ) != otherType ) return true ; if ( ! paramType . isStatic ( ) ) { ReferenceBinding enclosing = enclosingType ( ) ; if ( enclosing != null ) { ReferenceBinding otherEnclosing = otherType . enclosingType ( ) ; if ( otherEnclosing == null ) return true ; if ( ( otherEnclosing . tagBits & TagBits . HasDirectWildcard ) == 0 ) { if ( enclosing != otherEnclosing ) return true ; } else { if ( ! enclosing . isEquivalentTo ( otherType . enclosingType ( ) ) ) return true ; } } } length = paramType . arguments == null ? 0 : paramType . arguments . length ; otherArguments = otherType . typeVariables ( ) ; otherLength = otherArguments == null ? 0 : otherArguments . length ; if ( otherLength != length ) return true ; for ( int i = 0 ; i < length ; i ++ ) { if ( paramType . arguments [ i ] . isProvablyDistinctTypeArgument ( otherArguments [ i ] , paramType , i ) ) return true ; } return false ; case Binding . RAW_TYPE : return erasure ( ) != otherType . erasure ( ) ; case Binding . TYPE : return erasure ( ) != otherType ; } return true ; case Binding . RAW_TYPE : switch ( otherType . kind ( ) ) { case Binding . GENERIC_TYPE : case Binding . PARAMETERIZED_TYPE : case Binding . RAW_TYPE : case Binding . TYPE : return erasure ( ) != otherType . erasure ( ) ; } return true ; case Binding . TYPE : switch ( otherType . kind ( ) ) { case Binding . PARAMETERIZED_TYPE : case Binding . RAW_TYPE : return this != otherType . erasure ( ) ; } break ; default : break ; } return true ; } private boolean isProvablyDistinctTypeArgument ( TypeBinding otherArgument , final ParameterizedTypeBinding paramType , final int rank ) { if ( this == otherArgument ) return false ; TypeBinding upperBound1 = null ; TypeBinding lowerBound1 = null ; ReferenceBinding genericType = paramType . genericType ( ) ; switch ( kind ( ) ) { case Binding . WILDCARD_TYPE : WildcardBinding wildcard = ( WildcardBinding ) this ; switch ( wildcard . boundKind ) { case Wildcard . EXTENDS : upperBound1 = wildcard . bound ; break ; case Wildcard . SUPER : lowerBound1 = wildcard . bound ; break ; case Wildcard . UNBOUND : return false ; } break ; case Binding . INTERSECTION_TYPE : break ; case Binding . TYPE_PARAMETER : final TypeVariableBinding variable = ( TypeVariableBinding ) this ; if ( variable . isCapture ( ) ) { CaptureBinding capture = ( CaptureBinding ) variable ; switch ( capture . wildcard . boundKind ) { case Wildcard . EXTENDS : upperBound1 = capture . wildcard . bound ; break ; case Wildcard . SUPER : lowerBound1 = capture . wildcard . bound ; break ; case Wildcard . UNBOUND : return false ; } break ; } if ( variable . firstBound == null ) return false ; TypeBinding eliminatedType = Scope . convertEliminatingTypeVariables ( variable , genericType , rank , null ) ; switch ( eliminatedType . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : wildcard = ( WildcardBinding ) eliminatedType ; switch ( wildcard . boundKind ) { case Wildcard . EXTENDS : upperBound1 = wildcard . bound ; break ; case Wildcard . SUPER : lowerBound1 = wildcard . bound ; break ; case Wildcard . UNBOUND : return false ; } break ; } break ; } TypeBinding upperBound2 = null ; TypeBinding lowerBound2 = null ; switch ( otherArgument . kind ( ) ) { case Binding . WILDCARD_TYPE : WildcardBinding otherWildcard = ( WildcardBinding ) otherArgument ; switch ( otherWildcard . boundKind ) { case Wildcard . EXTENDS : upperBound2 = otherWildcard . bound ; break ; case Wildcard . SUPER : lowerBound2 = otherWildcard . bound ; break ; case Wildcard . UNBOUND : return false ; } break ; case Binding . INTERSECTION_TYPE : break ; case Binding . TYPE_PARAMETER : TypeVariableBinding otherVariable = ( TypeVariableBinding ) otherArgument ; if ( otherVariable . isCapture ( ) ) { CaptureBinding otherCapture = ( CaptureBinding ) otherVariable ; switch ( otherCapture . wildcard . boundKind ) { case Wildcard . EXTENDS : upperBound2 = otherCapture . wildcard . bound ; break ; case Wildcard . SUPER : lowerBound2 = otherCapture . wildcard . bound ; break ; case Wildcard . UNBOUND : return false ; } break ; } if ( otherVariable . firstBound == null ) return false ; TypeBinding otherEliminatedType = Scope . convertEliminatingTypeVariables ( otherVariable , genericType , rank , null ) ; switch ( otherEliminatedType . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : otherWildcard = ( WildcardBinding ) otherEliminatedType ; switch ( otherWildcard . boundKind ) { case Wildcard . EXTENDS : upperBound2 = otherWildcard . bound ; break ; case Wildcard . SUPER : lowerBound2 = otherWildcard . bound ; break ; case Wildcard . UNBOUND : return false ; } break ; } break ; } if ( lowerBound1 != null ) { if ( lowerBound2 != null ) { return false ; } else if ( upperBound2 != null ) { if ( lowerBound1 . isTypeVariable ( ) || upperBound2 . isTypeVariable ( ) ) { return false ; } return ! lowerBound1 . isCompatibleWith ( upperBound2 ) ; } else { if ( lowerBound1 . isTypeVariable ( ) || otherArgument . isTypeVariable ( ) ) { return false ; } return ! lowerBound1 . isCompatibleWith ( otherArgument ) ; } } else if ( upperBound1 != null ) { if ( lowerBound2 != null ) { return ! lowerBound2 . isCompatibleWith ( upperBound1 ) ; } else if ( upperBound2 != null ) { return upperBound1 . isProvableDistinctSubType ( upperBound2 ) && upperBound2 . isProvableDistinctSubType ( upperBound1 ) ; } else { return otherArgument . isProvableDistinctSubType ( upperBound1 ) ; } } else { if ( lowerBound2 != null ) { if ( lowerBound2 . isTypeVariable ( ) || isTypeVariable ( ) ) { return false ; } return ! lowerBound2 . isCompatibleWith ( this ) ; } else if ( upperBound2 != null ) { return isProvableDistinctSubType ( upperBound2 ) ; } else { return true ; } } } public final boolean isRawType ( ) { return kind ( ) == Binding . RAW_TYPE ; } public boolean isReifiable ( ) { TypeBinding leafType = leafComponentType ( ) ; if ( ! ( leafType instanceof ReferenceBinding ) ) return true ; ReferenceBinding current = ( ReferenceBinding ) leafType ; do { switch ( current . kind ( ) ) { case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : case Binding . GENERIC_TYPE : return false ; case Binding . PARAMETERIZED_TYPE : if ( current . isBoundParameterizedType ( ) ) return false ; break ; case Binding . RAW_TYPE : return true ; } if ( current . isStatic ( ) ) { return true ; } if ( current . isLocalType ( ) ) { LocalTypeBinding localTypeBinding = ( LocalTypeBinding ) current . erasure ( ) ; MethodBinding enclosingMethod = localTypeBinding . enclosingMethod ; if ( enclosingMethod != null && enclosingMethod . isStatic ( ) ) { return true ; } } } while ( ( current = current . enclosingType ( ) ) != null ) ; return true ; } public boolean isThrowable ( ) { return false ; } public boolean isTypeArgumentContainedBy ( TypeBinding otherType ) { if ( this == otherType ) return true ; switch ( otherType . kind ( ) ) { case Binding . TYPE_PARAMETER : { if ( ! isParameterizedType ( ) || ! otherType . isCapture ( ) ) { return false ; } CaptureBinding capture = ( CaptureBinding ) otherType ; WildcardBinding wildcard = capture . wildcard ; TypeBinding upperBound = null ; TypeBinding [ ] otherBounds = null ; switch ( wildcard . boundKind ) { case Wildcard . SUPER : return false ; case Wildcard . UNBOUND : TypeVariableBinding variable = wildcard . genericType . typeVariables ( ) [ wildcard . rank ] ; upperBound = variable . upperBound ( ) ; otherBounds = variable . boundsCount ( ) > 1 ? variable . otherUpperBounds ( ) : null ; break ; case Wildcard . EXTENDS : upperBound = wildcard . bound ; otherBounds = wildcard . otherBounds ; break ; } if ( upperBound . id == TypeIds . T_JavaLangObject && otherBounds == null ) { return false ; } otherType = capture . environment . createWildcard ( null , 0 , upperBound , otherBounds , Wildcard . EXTENDS ) ; return isTypeArgumentContainedBy ( otherType ) ; } case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : TypeBinding lowerBound = this ; TypeBinding upperBound = this ; switch ( kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcard = ( WildcardBinding ) this ; switch ( wildcard . boundKind ) { case Wildcard . EXTENDS : if ( wildcard . otherBounds != null ) break ; upperBound = wildcard . bound ; lowerBound = null ; break ; case Wildcard . SUPER : upperBound = wildcard ; lowerBound = wildcard . bound ; break ; case Wildcard . UNBOUND : upperBound = wildcard ; lowerBound = null ; } break ; case Binding . TYPE_PARAMETER : if ( isCapture ( ) ) { CaptureBinding capture = ( CaptureBinding ) this ; if ( capture . lowerBound != null ) lowerBound = capture . lowerBound ; } } WildcardBinding otherWildcard = ( WildcardBinding ) otherType ; if ( otherWildcard . otherBounds != null ) return false ; TypeBinding otherBound = otherWildcard . bound ; switch ( otherWildcard . boundKind ) { case Wildcard . EXTENDS : if ( otherBound == this ) return true ; if ( upperBound == null ) return false ; TypeBinding match = upperBound . findSuperTypeOriginatingFrom ( otherBound ) ; if ( match != null && ( match = match . leafComponentType ( ) ) . isRawType ( ) ) { return match == otherBound . leafComponentType ( ) ; } return upperBound . isCompatibleWith ( otherBound ) ; case Wildcard . SUPER : if ( otherBound == this ) return true ; if ( lowerBound == null ) return false ; match = otherBound . findSuperTypeOriginatingFrom ( lowerBound ) ; if ( match != null && ( match = match . leafComponentType ( ) ) . isRawType ( ) ) { return match == lowerBound . leafComponentType ( ) ; } return otherBound . isCompatibleWith ( lowerBound ) ; case Wildcard . UNBOUND : default : return true ; } case Binding . PARAMETERIZED_TYPE : if ( ! isParameterizedType ( ) ) return false ; ParameterizedTypeBinding paramType = ( ParameterizedTypeBinding ) this ; ParameterizedTypeBinding otherParamType = ( ParameterizedTypeBinding ) otherType ; if ( paramType . actualType ( ) != otherParamType . actualType ( ) ) return false ; if ( ! paramType . isStatic ( ) ) { ReferenceBinding enclosing = enclosingType ( ) ; if ( enclosing != null ) { ReferenceBinding otherEnclosing = otherParamType . enclosingType ( ) ; if ( otherEnclosing == null ) return false ; if ( ( otherEnclosing . tagBits & TagBits . HasDirectWildcard ) == 0 ) { if ( enclosing != otherEnclosing ) return false ; } else { if ( ! enclosing . isEquivalentTo ( otherParamType . enclosingType ( ) ) ) return false ; } } } int length = paramType . arguments == null ? 0 : paramType . arguments . length ; TypeBinding [ ] otherArguments = otherParamType . arguments ; int otherLength = otherArguments == null ? 0 : otherArguments . length ; if ( otherLength != length ) return false ; nextArgument : for ( int i = 0 ; i < length ; i ++ ) { TypeBinding argument = paramType . arguments [ i ] ; TypeBinding otherArgument = otherArguments [ i ] ; if ( argument == otherArgument ) continue nextArgument ; int kind = argument . kind ( ) ; if ( otherArgument . kind ( ) != kind ) return false ; switch ( kind ) { case Binding . PARAMETERIZED_TYPE : if ( argument . isTypeArgumentContainedBy ( otherArgument ) ) continue nextArgument ; break ; case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcard = ( WildcardBinding ) argument ; otherWildcard = ( WildcardBinding ) otherArgument ; switch ( wildcard . boundKind ) { case Wildcard . EXTENDS : if ( otherWildcard . boundKind == Wildcard . UNBOUND && wildcard . bound == wildcard . typeVariable ( ) . upperBound ( ) ) continue nextArgument ; break ; case Wildcard . SUPER : break ; case Wildcard . UNBOUND : if ( otherWildcard . boundKind == Wildcard . EXTENDS && otherWildcard . bound == otherWildcard . typeVariable ( ) . upperBound ( ) ) continue nextArgument ; break ; } break ; } return false ; } return true ; } if ( otherType . id == TypeIds . T_JavaLangObject ) { switch ( kind ( ) ) { case Binding . WILDCARD_TYPE : WildcardBinding wildcard = ( WildcardBinding ) this ; if ( wildcard . boundKind == Wildcard . SUPER && wildcard . bound . id == TypeIds . T_JavaLangObject ) { return true ; } break ; } } return false ; } public boolean isTypeVariable ( ) { return false ; } public boolean isUnboundWildcard ( ) { return false ; } public boolean isUncheckedException ( boolean includeSupertype ) { return false ; } public boolean isWildcard ( ) { return false ; } public int kind ( ) { return Binding . TYPE ; } public TypeBinding leafComponentType ( ) { return this ; } public boolean needsUncheckedConversion ( TypeBinding targetType ) { if ( this == targetType ) return false ; targetType = targetType . leafComponentType ( ) ; if ( ! ( targetType instanceof ReferenceBinding ) ) return false ; TypeBinding currentType = leafComponentType ( ) ; TypeBinding match = currentType . findSuperTypeOriginatingFrom ( targetType ) ; if ( ! ( match instanceof ReferenceBinding ) ) return false ; ReferenceBinding compatible = ( ReferenceBinding ) match ; while ( compatible . isRawType ( ) ) { if ( targetType . isBoundParameterizedType ( ) ) return true ; if ( compatible . isStatic ( ) ) break ; if ( ( compatible = compatible . enclosingType ( ) ) == null ) break ; if ( ( targetType = targetType . enclosingType ( ) ) == null ) break ; } return false ; } public TypeBinding original ( ) { switch ( kind ( ) ) { case Binding . PARAMETERIZED_TYPE : case Binding . RAW_TYPE : case Binding . ARRAY_TYPE : return erasure ( ) ; default : return this ; } } public char [ ] qualifiedPackageName ( ) { PackageBinding packageBinding = getPackage ( ) ; return packageBinding == null || packageBinding . compoundName == CharOperation . NO_CHAR_CHAR ? CharOperation . NO_CHAR : packageBinding . readableName ( ) ; } public abstract char [ ] qualifiedSourceName ( ) ; public char [ ] signature ( ) { return constantPoolName ( ) ; } public abstract char [ ] sourceName ( ) ; public void swapUnresolved ( UnresolvedReferenceBinding unresolvedType , ReferenceBinding resolvedType , LookupEnvironment environment ) { } public TypeVariableBinding [ ] typeVariables ( ) { return Binding . NO_TYPE_VARIABLES ; } } </s>