<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 . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . Constant ; public final class ArrayBinding extends TypeBinding { public static final FieldBinding ArrayLength = new FieldBinding ( TypeConstants . LENGTH , TypeBinding . INT , ClassFileConstants . AccPublic | ClassFileConstants . AccFinal , null , Constant . NotAConstant ) ; public TypeBinding leafComponentType ; public int dimensions ; LookupEnvironment environment ; char [ ] constantPoolName ; char [ ] genericTypeSignature ; public ArrayBinding ( TypeBinding type , int dimensions , LookupEnvironment environment ) { this . tagBits |= TagBits . IsArrayType ; this . leafComponentType = type ; this . dimensions = dimensions ; this . environment = environment ; if ( type instanceof UnresolvedReferenceBinding ) ( ( UnresolvedReferenceBinding ) type ) . addWrapper ( this , environment ) ; else this . tagBits |= type . tagBits & ( TagBits . HasTypeVariable | TagBits . HasDirectWildcard | TagBits . HasMissingType | TagBits . ContainsNestedTypeReferences ) ; } public TypeBinding closestMatch ( ) { if ( isValidBinding ( ) ) { return this ; } TypeBinding leafClosestMatch = this . leafComponentType . closestMatch ( ) ; if ( leafClosestMatch == null ) { return null ; } return this . environment . createArrayType ( this . leafComponentType . closestMatch ( ) , this . dimensions ) ; } public List collectMissingTypes ( List missingTypes ) { if ( ( this . tagBits & TagBits . HasMissingType ) != 0 ) { missingTypes = this . leafComponentType . collectMissingTypes ( missingTypes ) ; } return missingTypes ; } public void collectSubstitutes ( Scope scope , TypeBinding actualType , InferenceContext inferenceContext , int constraint ) { if ( ( this . tagBits & TagBits . HasTypeVariable ) == 0 ) return ; if ( actualType == TypeBinding . NULL ) return ; switch ( actualType . kind ( ) ) { case Binding . ARRAY_TYPE : int actualDim = actualType . dimensions ( ) ; if ( actualDim == this . dimensions ) { this . leafComponentType . collectSubstitutes ( scope , actualType . leafComponentType ( ) , inferenceContext , constraint ) ; } else if ( actualDim > this . dimensions ) { ArrayBinding actualReducedType = this . environment . createArrayType ( actualType . leafComponentType ( ) , actualDim - this . dimensions ) ; this . leafComponentType . collectSubstitutes ( scope , actualReducedType , inferenceContext , constraint ) ; } break ; case Binding . TYPE_PARAMETER : break ; } } public char [ ] computeUniqueKey ( boolean isLeaf ) { char [ ] brackets = new char [ this . dimensions ] ; for ( int i = this . dimensions - 1 ; i >= 0 ; i -- ) brackets [ i ] = '[' ; return CharOperation . concat ( brackets , this . leafComponentType . computeUniqueKey ( isLeaf ) ) ; } public char [ ] constantPoolName ( ) { if ( this . constantPoolName != null ) return this . constantPoolName ; char [ ] brackets = new char [ this . dimensions ] ; for ( int i = this . dimensions - 1 ; i >= 0 ; i -- ) brackets [ i ] = '[' ; return this . constantPoolName = CharOperation . concat ( brackets , this . leafComponentType . signature ( ) ) ; } public String debugName ( ) { StringBuffer brackets = new StringBuffer ( this . dimensions * 2 ) ; for ( int i = this . dimensions ; -- i >= 0 ; ) brackets . append ( "[]" ) ; return this . leafComponentType . debugName ( ) + brackets . toString ( ) ; } public int dimensions ( ) { return this . dimensions ; } public TypeBinding elementsType ( ) { if ( this . dimensions == 1 ) return this . leafComponentType ; return this . environment . createArrayType ( this . leafComponentType , this . dimensions - 1 ) ; } public TypeBinding erasure ( ) { TypeBinding erasedType = this . leafComponentType . erasure ( ) ; if ( this . leafComponentType != erasedType ) return this . environment . createArrayType ( erasedType , this . dimensions ) ; return this ; } public LookupEnvironment environment ( ) { return this . environment ; } public char [ ] genericTypeSignature ( ) { if ( this . genericTypeSignature == null ) { char [ ] brackets = new char [ this . dimensions ] ; for ( int i = this . dimensions - 1 ; i >= 0 ; i -- ) brackets [ i ] = '[' ; this . genericTypeSignature = CharOperation . concat ( brackets , this . leafComponentType . genericTypeSignature ( ) ) ; } return this . genericTypeSignature ; } public PackageBinding getPackage ( ) { return this . leafComponentType . getPackage ( ) ; } public int hashCode ( ) { return this . leafComponentType == null ? super . hashCode ( ) : this . leafComponentType . hashCode ( ) ; } public boolean isCompatibleWith ( TypeBinding otherType ) { if ( this == otherType ) return true ; switch ( otherType . kind ( ) ) { case Binding . ARRAY_TYPE : ArrayBinding otherArray = ( ArrayBinding ) otherType ; if ( otherArray . leafComponentType . isBaseType ( ) ) return false ; if ( this . dimensions == otherArray . dimensions ) return this . leafComponentType . isCompatibleWith ( otherArray . leafComponentType ) ; if ( this . dimensions < otherArray . dimensions ) return false ; break ; case Binding . BASE_TYPE : return false ; case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return ( ( WildcardBinding ) otherType ) . boundCheck ( this ) ; 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 ) ; } } return false ; } switch ( otherType . leafComponentType ( ) . id ) { case TypeIds . T_JavaLangObject : case TypeIds . T_JavaLangCloneable : case TypeIds . T_JavaIoSerializable : return true ; } return false ; } public int kind ( ) { return ARRAY_TYPE ; } public TypeBinding leafComponentType ( ) { return this . leafComponentType ; } public int problemId ( ) { return this . leafComponentType . problemId ( ) ; } public char [ ] qualifiedSourceName ( ) { char [ ] brackets = new char [ this . dimensions * 2 ] ; for ( int i = this . dimensions * 2 - 1 ; i >= 0 ; i -= 2 ) { brackets [ i ] = ']' ; brackets [ i - 1 ] = '[' ; } return CharOperation . concat ( this . leafComponentType . qualifiedSourceName ( ) , brackets ) ; } public char [ ] readableName ( ) { char [ ] brackets = new char [ this . dimensions * 2 ] ; for ( int i = this . dimensions * 2 - 1 ; i >= 0 ; i -= 2 ) { brackets [ i ] = ']' ; brackets [ i - 1 ] = '[' ; } return CharOperation . concat ( this . leafComponentType . readableName ( ) , brackets ) ; } public char [ ] shortReadableName ( ) { char [ ] brackets = new char [ this . dimensions * 2 ] ; for ( int i = this . dimensions * 2 - 1 ; i >= 0 ; i -= 2 ) { brackets [ i ] = ']' ; brackets [ i - 1 ] = '[' ; } return CharOperation . concat ( this . leafComponentType . shortReadableName ( ) , brackets ) ; } public char [ ] sourceName ( ) { char [ ] brackets = new char [ this . dimensions * 2 ] ; for ( int i = this . dimensions * 2 - 1 ; i >= 0 ; i -= 2 ) { brackets [ i ] = ']' ; brackets [ i - 1 ] = '[' ; } return CharOperation . concat ( this . leafComponentType . sourceName ( ) , brackets ) ; } public void swapUnresolved ( UnresolvedReferenceBinding unresolvedType , ReferenceBinding resolvedType , LookupEnvironment env ) { if ( this . leafComponentType == unresolvedType ) { this . leafComponentType = env . convertUnresolvedBinaryToRawType ( resolvedType ) ; this . tagBits |= this . leafComponentType . tagBits & ( TagBits . HasTypeVariable | TagBits . HasDirectWildcard | TagBits . HasMissingType ) ; } } public String toString ( ) { return this . leafComponentType != null ? debugName ( ) : "" ; } } </s>