<s> package org . eclipse . jdt . internal . compiler . lookup ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ClassFilePool ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . impl . ITypeRequestor ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . compiler . util . HashtableOfPackage ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; public class LookupEnvironment implements ProblemReasons , TypeConstants { private Map accessRestrictions ; ImportBinding [ ] defaultImports ; public PackageBinding defaultPackage ; HashtableOfPackage knownPackages ; private int lastCompletedUnitIndex = - 1 ; private int lastUnitIndex = - 1 ; public INameEnvironment nameEnvironment ; public CompilerOptions globalOptions ; public ProblemReporter problemReporter ; public ClassFilePool classFilePool ; private int stepCompleted ; public ITypeRequestor typeRequestor ; private ArrayBinding [ ] [ ] uniqueArrayBindings ; private SimpleLookupTable uniqueParameterizedTypeBindings ; private SimpleLookupTable uniqueRawTypeBindings ; private SimpleLookupTable uniqueWildcardBindings ; private SimpleLookupTable uniqueParameterizedGenericMethodBindings ; private SimpleLookupTable uniqueGetClassMethodBinding ; public CompilationUnitDeclaration unitBeingCompleted = null ; public Object missingClassFileLocation = null ; private CompilationUnitDeclaration [ ] units = new CompilationUnitDeclaration [ 4 ] ; private MethodVerifier verifier ; public MethodBinding arrayClone ; private ArrayList missingTypes ; public boolean isProcessingAnnotations = false ; final static int BUILD_FIELDS_AND_METHODS = 4 ; final static int BUILD_TYPE_HIERARCHY = 1 ; final static int CHECK_AND_SET_IMPORTS = 2 ; final static int CONNECT_TYPE_HIERARCHY = 3 ; static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding ( CharOperation . NO_CHAR , NotFound ) ; static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding ( CharOperation . NO_CHAR_CHAR , null , NotFound ) ; public LookupEnvironment ( ITypeRequestor typeRequestor , CompilerOptions globalOptions , ProblemReporter problemReporter , INameEnvironment nameEnvironment ) { this . typeRequestor = typeRequestor ; this . globalOptions = globalOptions ; this . problemReporter = problemReporter ; this . defaultPackage = new PackageBinding ( this ) ; this . defaultImports = null ; this . nameEnvironment = nameEnvironment ; this . knownPackages = new HashtableOfPackage ( ) ; this . uniqueArrayBindings = new ArrayBinding [ 5 ] [ ] ; this . uniqueArrayBindings [ 0 ] = new ArrayBinding [ 50 ] ; this . uniqueParameterizedTypeBindings = new SimpleLookupTable ( 3 ) ; this . uniqueRawTypeBindings = new SimpleLookupTable ( 3 ) ; this . uniqueWildcardBindings = new SimpleLookupTable ( 3 ) ; this . uniqueParameterizedGenericMethodBindings = new SimpleLookupTable ( 3 ) ; this . missingTypes = null ; this . accessRestrictions = new HashMap ( 3 ) ; this . classFilePool = ClassFilePool . newInstance ( ) ; } public ReferenceBinding askForType ( char [ ] [ ] compoundName ) { NameEnvironmentAnswer answer = this . nameEnvironment . findType ( compoundName ) ; if ( answer == null ) return null ; if ( answer . isBinaryType ( ) ) { this . typeRequestor . accept ( answer . getBinaryType ( ) , computePackageFrom ( compoundName , false ) , answer . getAccessRestriction ( ) ) ; } else if ( answer . isCompilationUnit ( ) ) { this . typeRequestor . accept ( answer . getCompilationUnit ( ) , answer . getAccessRestriction ( ) ) ; } else if ( answer . isSourceType ( ) ) { this . typeRequestor . accept ( answer . getSourceTypes ( ) , computePackageFrom ( compoundName , false ) , answer . getAccessRestriction ( ) ) ; } return getCachedType ( compoundName ) ; } ReferenceBinding askForType ( PackageBinding packageBinding , char [ ] name ) { if ( packageBinding == null ) { if ( this . defaultPackage == null ) return null ; packageBinding = this . defaultPackage ; } NameEnvironmentAnswer answer = this . nameEnvironment . findType ( name , packageBinding . compoundName ) ; if ( answer == null ) return null ; if ( answer . isBinaryType ( ) ) { this . typeRequestor . accept ( answer . getBinaryType ( ) , packageBinding , answer . getAccessRestriction ( ) ) ; } else if ( answer . isCompilationUnit ( ) ) { this . typeRequestor . accept ( answer . getCompilationUnit ( ) , answer . getAccessRestriction ( ) ) ; } else if ( answer . isSourceType ( ) ) { this . typeRequestor . accept ( answer . getSourceTypes ( ) , packageBinding , answer . getAccessRestriction ( ) ) ; } return packageBinding . getType0 ( name ) ; } public void buildTypeBindings ( CompilationUnitDeclaration unit , AccessRestriction accessRestriction ) { CompilationUnitScope scope = unit . buildCompilationUnitScope ( this ) ; scope . buildTypeBindings ( accessRestriction ) ; int unitsLength = this . units . length ; if ( ++ this . lastUnitIndex >= unitsLength ) System . arraycopy ( this . units , 0 , this . units = new CompilationUnitDeclaration [ 2 * unitsLength ] , 0 , unitsLength ) ; this . units [ this . lastUnitIndex ] = unit ; } public BinaryTypeBinding cacheBinaryType ( IBinaryType binaryType , AccessRestriction accessRestriction ) { return cacheBinaryType ( binaryType , true , accessRestriction ) ; } public BinaryTypeBinding cacheBinaryType ( IBinaryType binaryType , boolean needFieldsAndMethods , AccessRestriction accessRestriction ) { char [ ] [ ] compoundName = CharOperation . splitOn ( '/' , binaryType . getName ( ) ) ; ReferenceBinding existingType = getCachedType ( compoundName ) ; if ( existingType == null || existingType instanceof UnresolvedReferenceBinding ) return createBinaryTypeFrom ( binaryType , computePackageFrom ( compoundName , false ) , needFieldsAndMethods , accessRestriction ) ; return null ; } public void completeTypeBindings ( ) { this . stepCompleted = BUILD_TYPE_HIERARCHY ; for ( int i = this . lastCompletedUnitIndex + 1 ; i <= this . lastUnitIndex ; i ++ ) { ( this . unitBeingCompleted = this . units [ i ] ) . scope . checkAndSetImports ( ) ; } this . stepCompleted = CHECK_AND_SET_IMPORTS ; for ( int i = this . lastCompletedUnitIndex + 1 ; i <= this . lastUnitIndex ; i ++ ) { ( this . unitBeingCompleted = this . units [ i ] ) . scope . connectTypeHierarchy ( ) ; ( this . unitBeingCompleted = this . units [ i ] ) . scope . augmentTypeHierarchy ( ) ; } this . stepCompleted = CONNECT_TYPE_HIERARCHY ; for ( int i = this . lastCompletedUnitIndex + 1 ; i <= this . lastUnitIndex ; i ++ ) { CompilationUnitScope unitScope = ( this . unitBeingCompleted = this . units [ i ] ) . scope ; unitScope . checkParameterizedTypes ( ) ; unitScope . buildFieldsAndMethods ( ) ; this . units [ i ] = null ; } this . stepCompleted = BUILD_FIELDS_AND_METHODS ; this . lastCompletedUnitIndex = this . lastUnitIndex ; this . unitBeingCompleted = null ; } public void completeTypeBindings ( CompilationUnitDeclaration parsedUnit ) { if ( this . stepCompleted == BUILD_FIELDS_AND_METHODS ) { completeTypeBindings ( ) ; } else { if ( parsedUnit . scope == null ) return ; if ( this . stepCompleted >= CHECK_AND_SET_IMPORTS ) ( this . unitBeingCompleted = parsedUnit ) . scope . checkAndSetImports ( ) ; if ( this . stepCompleted >= CONNECT_TYPE_HIERARCHY ) ( this . unitBeingCompleted = parsedUnit ) . scope . connectTypeHierarchy ( ) ; this . unitBeingCompleted = null ; } } public void completeTypeBindings ( CompilationUnitDeclaration parsedUnit , boolean buildFieldsAndMethods ) { if ( parsedUnit . scope == null ) return ; ( this . unitBeingCompleted = parsedUnit ) . scope . checkAndSetImports ( ) ; parsedUnit . scope . connectTypeHierarchy ( ) ; parsedUnit . scope . checkParameterizedTypes ( ) ; if ( buildFieldsAndMethods ) parsedUnit . scope . buildFieldsAndMethods ( ) ; this . unitBeingCompleted = null ; } public void completeTypeBindings ( CompilationUnitDeclaration [ ] parsedUnits , boolean [ ] buildFieldsAndMethods , int unitCount ) { for ( int i = 0 ; i < unitCount ; i ++ ) { CompilationUnitDeclaration parsedUnit = parsedUnits [ i ] ; if ( parsedUnit . scope != null ) ( this . unitBeingCompleted = parsedUnit ) . scope . checkAndSetImports ( ) ; } for ( int i = 0 ; i < unitCount ; i ++ ) { CompilationUnitDeclaration parsedUnit = parsedUnits [ i ] ; if ( parsedUnit . scope != null ) ( this . unitBeingCompleted = parsedUnit ) . scope . connectTypeHierarchy ( ) ; } for ( int i = 0 ; i < unitCount ; i ++ ) { CompilationUnitDeclaration parsedUnit = parsedUnits [ i ] ; if ( parsedUnit . scope != null ) { ( this . unitBeingCompleted = parsedUnit ) . scope . checkParameterizedTypes ( ) ; if ( buildFieldsAndMethods [ i ] ) parsedUnit . scope . buildFieldsAndMethods ( ) ; } } this . unitBeingCompleted = null ; } public MethodBinding computeArrayClone ( MethodBinding objectClone ) { if ( this . arrayClone == null ) { this . arrayClone = new MethodBinding ( ( objectClone . modifiers & ~ ClassFileConstants . AccProtected ) | ClassFileConstants . AccPublic , TypeConstants . CLONE , objectClone . returnType , Binding . NO_PARAMETERS , Binding . NO_EXCEPTIONS , ( ReferenceBinding ) objectClone . returnType ) ; } return this . arrayClone ; } public TypeBinding computeBoxingType ( TypeBinding type ) { TypeBinding boxedType ; switch ( type . id ) { case TypeIds . T_JavaLangBoolean : return TypeBinding . BOOLEAN ; case TypeIds . T_JavaLangByte : return TypeBinding . BYTE ; case TypeIds . T_JavaLangCharacter : return TypeBinding . CHAR ; case TypeIds . T_JavaLangShort : return TypeBinding . SHORT ; case TypeIds . T_JavaLangDouble : return TypeBinding . DOUBLE ; case TypeIds . T_JavaLangFloat : return TypeBinding . FLOAT ; case TypeIds . T_JavaLangInteger : return TypeBinding . INT ; case TypeIds . T_JavaLangLong : return TypeBinding . LONG ; case TypeIds . T_int : boxedType = getType ( JAVA_LANG_INTEGER ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_INTEGER , null , NotFound ) ; case TypeIds . T_byte : boxedType = getType ( JAVA_LANG_BYTE ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_BYTE , null , NotFound ) ; case TypeIds . T_short : boxedType = getType ( JAVA_LANG_SHORT ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_SHORT , null , NotFound ) ; case TypeIds . T_char : boxedType = getType ( JAVA_LANG_CHARACTER ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_CHARACTER , null , NotFound ) ; case TypeIds . T_long : boxedType = getType ( JAVA_LANG_LONG ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_LONG , null , NotFound ) ; case TypeIds . T_float : boxedType = getType ( JAVA_LANG_FLOAT ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_FLOAT , null , NotFound ) ; case TypeIds . T_double : boxedType = getType ( JAVA_LANG_DOUBLE ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_DOUBLE , null , NotFound ) ; case TypeIds . T_boolean : boxedType = getType ( JAVA_LANG_BOOLEAN ) ; if ( boxedType != null ) return boxedType ; return new ProblemReferenceBinding ( JAVA_LANG_BOOLEAN , null , NotFound ) ; } switch ( type . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : case Binding . TYPE_PARAMETER : switch ( type . erasure ( ) . id ) { case TypeIds . T_JavaLangBoolean : return TypeBinding . BOOLEAN ; case TypeIds . T_JavaLangByte : return TypeBinding . BYTE ; case TypeIds . T_JavaLangCharacter : return TypeBinding . CHAR ; case TypeIds . T_JavaLangShort : return TypeBinding . SHORT ; case TypeIds . T_JavaLangDouble : return TypeBinding . DOUBLE ; case TypeIds . T_JavaLangFloat : return TypeBinding . FLOAT ; case TypeIds . T_JavaLangInteger : return TypeBinding . INT ; case TypeIds . T_JavaLangLong : return TypeBinding . LONG ; } } return type ; } private PackageBinding computePackageFrom ( char [ ] [ ] constantPoolName , boolean isMissing ) { if ( constantPoolName . length == 1 ) return this . defaultPackage ; PackageBinding packageBinding = getPackage0 ( constantPoolName [ 0 ] ) ; if ( packageBinding == null || packageBinding == TheNotFoundPackage ) { packageBinding = new PackageBinding ( constantPoolName [ 0 ] , this ) ; if ( isMissing ) packageBinding . tagBits |= TagBits . HasMissingType ; this . knownPackages . put ( constantPoolName [ 0 ] , packageBinding ) ; } for ( int i = 1 , length = constantPoolName . length - 1 ; i < length ; i ++ ) { PackageBinding parent = packageBinding ; if ( ( packageBinding = parent . getPackage0 ( constantPoolName [ i ] ) ) == null || packageBinding == TheNotFoundPackage ) { packageBinding = new PackageBinding ( CharOperation . subarray ( constantPoolName , 0 , i + 1 ) , parent , this ) ; if ( isMissing ) { packageBinding . tagBits |= TagBits . HasMissingType ; } parent . addPackage ( packageBinding ) ; } } return packageBinding ; } public ReferenceBinding convertToParameterizedType ( ReferenceBinding originalType ) { if ( originalType != null ) { boolean isGeneric = originalType . isGenericType ( ) ; ReferenceBinding originalEnclosingType = originalType . enclosingType ( ) ; ReferenceBinding convertedEnclosingType = originalEnclosingType ; boolean needToConvert = isGeneric ; if ( originalEnclosingType != null ) { convertedEnclosingType = originalType . isStatic ( ) ? ( ReferenceBinding ) convertToRawType ( originalEnclosingType , false ) : convertToParameterizedType ( originalEnclosingType ) ; needToConvert |= originalEnclosingType != convertedEnclosingType ; } if ( needToConvert ) { return createParameterizedType ( originalType , isGeneric ? originalType . typeVariables ( ) : null , convertedEnclosingType ) ; } } return originalType ; } public TypeBinding convertToRawType ( TypeBinding type , boolean forceRawEnclosingType ) { int dimension ; TypeBinding originalType ; switch ( type . kind ( ) ) { case Binding . BASE_TYPE : case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : case Binding . RAW_TYPE : return type ; case Binding . ARRAY_TYPE : dimension = type . dimensions ( ) ; originalType = type . leafComponentType ( ) ; break ; default : if ( type . id == TypeIds . T_JavaLangObject ) return type ; dimension = 0 ; originalType = type ; } boolean needToConvert ; switch ( originalType . kind ( ) ) { case Binding . BASE_TYPE : return type ; case Binding . GENERIC_TYPE : needToConvert = true ; break ; case Binding . PARAMETERIZED_TYPE : ParameterizedTypeBinding paramType = ( ParameterizedTypeBinding ) originalType ; needToConvert = paramType . genericType ( ) . isGenericType ( ) ; break ; default : needToConvert = false ; break ; } ReferenceBinding originalEnclosing = originalType . enclosingType ( ) ; TypeBinding convertedType ; if ( originalEnclosing == null ) { convertedType = needToConvert ? createRawType ( ( ReferenceBinding ) originalType . erasure ( ) , null ) : originalType ; } else { ReferenceBinding convertedEnclosing ; if ( originalEnclosing . kind ( ) == Binding . RAW_TYPE ) { needToConvert |= ! ( ( ReferenceBinding ) originalType ) . isStatic ( ) ; convertedEnclosing = originalEnclosing ; } else if ( forceRawEnclosingType && ! needToConvert ) { convertedEnclosing = ( ReferenceBinding ) convertToRawType ( originalEnclosing , forceRawEnclosingType ) ; needToConvert = originalEnclosing != convertedEnclosing ; } else if ( needToConvert || ( ( ReferenceBinding ) originalType ) . isStatic ( ) ) { convertedEnclosing = ( ReferenceBinding ) convertToRawType ( originalEnclosing , false ) ; } else { convertedEnclosing = convertToParameterizedType ( originalEnclosing ) ; } if ( needToConvert ) { convertedType = createRawType ( ( ReferenceBinding ) originalType . erasure ( ) , convertedEnclosing ) ; } else if ( originalEnclosing != convertedEnclosing ) { convertedType = createParameterizedType ( ( ReferenceBinding ) originalType . erasure ( ) , null , convertedEnclosing ) ; } else { convertedType = originalType ; } } if ( originalType != convertedType ) { return dimension > 0 ? ( TypeBinding ) createArrayType ( convertedType , dimension ) : convertedType ; } return type ; } public ReferenceBinding [ ] convertToRawTypes ( ReferenceBinding [ ] originalTypes , boolean forceErasure , boolean forceRawEnclosingType ) { if ( originalTypes == null ) return null ; ReferenceBinding [ ] convertedTypes = originalTypes ; for ( int i = 0 , length = originalTypes . length ; i < length ; i ++ ) { ReferenceBinding originalType = originalTypes [ i ] ; ReferenceBinding convertedType = ( ReferenceBinding ) convertToRawType ( forceErasure ? originalType . erasure ( ) : originalType , forceRawEnclosingType ) ; if ( convertedType != originalType ) { if ( convertedTypes == originalTypes ) { System . arraycopy ( originalTypes , 0 , convertedTypes = new ReferenceBinding [ length ] , 0 , i ) ; } convertedTypes [ i ] = convertedType ; } else if ( convertedTypes != originalTypes ) { convertedTypes [ i ] = originalType ; } } return convertedTypes ; } public TypeBinding convertUnresolvedBinaryToRawType ( TypeBinding type ) { int dimension ; TypeBinding originalType ; switch ( type . kind ( ) ) { case Binding . BASE_TYPE : case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : case Binding . RAW_TYPE : return type ; case Binding . ARRAY_TYPE : dimension = type . dimensions ( ) ; originalType = type . leafComponentType ( ) ; break ; default : if ( type . id == TypeIds . T_JavaLangObject ) return type ; dimension = 0 ; originalType = type ; } boolean needToConvert ; switch ( originalType . kind ( ) ) { case Binding . BASE_TYPE : return type ; case Binding . GENERIC_TYPE : needToConvert = true ; break ; case Binding . PARAMETERIZED_TYPE : ParameterizedTypeBinding paramType = ( ParameterizedTypeBinding ) originalType ; needToConvert = paramType . genericType ( ) . isGenericType ( ) ; break ; default : needToConvert = false ; break ; } ReferenceBinding originalEnclosing = originalType . enclosingType ( ) ; TypeBinding convertedType ; if ( originalEnclosing == null ) { convertedType = needToConvert ? createRawType ( ( ReferenceBinding ) originalType . erasure ( ) , null ) : originalType ; } else { ReferenceBinding convertedEnclosing = ( ReferenceBinding ) convertUnresolvedBinaryToRawType ( originalEnclosing ) ; if ( convertedEnclosing != originalEnclosing ) { needToConvert |= ! ( ( ReferenceBinding ) originalType ) . isStatic ( ) ; } if ( needToConvert ) { convertedType = createRawType ( ( ReferenceBinding ) originalType . erasure ( ) , convertedEnclosing ) ; } else if ( originalEnclosing != convertedEnclosing ) { convertedType = createParameterizedType ( ( ReferenceBinding ) originalType . erasure ( ) , null , convertedEnclosing ) ; } else { convertedType = originalType ; } } if ( originalType != convertedType ) { return dimension > 0 ? ( TypeBinding ) createArrayType ( convertedType , dimension ) : convertedType ; } return type ; } public AnnotationBinding createAnnotation ( ReferenceBinding annotationType , ElementValuePair [ ] pairs ) { if ( pairs . length != 0 ) { AnnotationBinding . setMethodBindings ( annotationType , pairs ) ; } return new AnnotationBinding ( annotationType , pairs ) ; } public ArrayBinding createArrayType ( TypeBinding leafComponentType , int dimensionCount ) { if ( leafComponentType instanceof LocalTypeBinding ) return ( ( LocalTypeBinding ) leafComponentType ) . createArrayType ( dimensionCount , this ) ; int dimIndex = dimensionCount - 1 ; int length = this . uniqueArrayBindings . length ; ArrayBinding [ ] arrayBindings ; if ( dimIndex < length ) { if ( ( arrayBindings = this . uniqueArrayBindings [ dimIndex ] ) == null ) this . uniqueArrayBindings [ dimIndex ] = arrayBindings = new ArrayBinding [ 10 ] ; } else { System . arraycopy ( this . uniqueArrayBindings , 0 , this . uniqueArrayBindings = new ArrayBinding [ dimensionCount ] [ ] , 0 , length ) ; this . uniqueArrayBindings [ dimIndex ] = arrayBindings = new ArrayBinding [ 10 ] ; } int index = - 1 ; length = arrayBindings . length ; while ( ++ index < length ) { ArrayBinding currentBinding = arrayBindings [ index ] ; if ( currentBinding == null ) return arrayBindings [ index ] = new ArrayBinding ( leafComponentType , dimensionCount , this ) ; if ( currentBinding . leafComponentType == leafComponentType ) return currentBinding ; } System . arraycopy ( arrayBindings , 0 , ( arrayBindings = new ArrayBinding [ length * 2 ] ) , 0 , length ) ; this . uniqueArrayBindings [ dimIndex ] = arrayBindings ; return arrayBindings [ length ] = new ArrayBinding ( leafComponentType , dimensionCount , this ) ; } public BinaryTypeBinding createBinaryTypeFrom ( IBinaryType binaryType , PackageBinding packageBinding , AccessRestriction accessRestriction ) { return createBinaryTypeFrom ( binaryType , packageBinding , true , accessRestriction ) ; } public BinaryTypeBinding createBinaryTypeFrom ( IBinaryType binaryType , PackageBinding packageBinding , boolean needFieldsAndMethods , AccessRestriction accessRestriction ) { BinaryTypeBinding binaryBinding = new BinaryTypeBinding ( packageBinding , binaryType , this ) ; ReferenceBinding cachedType = packageBinding . getType0 ( binaryBinding . compoundName [ binaryBinding . compoundName . length - 1 ] ) ; if ( cachedType != null ) { if ( cachedType instanceof UnresolvedReferenceBinding ) { ( ( UnresolvedReferenceBinding ) cachedType ) . setResolvedType ( binaryBinding , this ) ; } else { if ( cachedType . isBinaryBinding ( ) ) return ( BinaryTypeBinding ) cachedType ; return null ; } } packageBinding . addType ( binaryBinding ) ; setAccessRestriction ( binaryBinding , accessRestriction ) ; binaryBinding . cachePartsFrom ( binaryType , needFieldsAndMethods ) ; return binaryBinding ; } public MissingTypeBinding createMissingType ( PackageBinding packageBinding , char [ ] [ ] compoundName ) { if ( packageBinding == null ) { packageBinding = computePackageFrom ( compoundName , true ) ; if ( packageBinding == TheNotFoundPackage ) packageBinding = this . defaultPackage ; } MissingTypeBinding missingType = new MissingTypeBinding ( packageBinding , compoundName , this ) ; if ( missingType . id != TypeIds . T_JavaLangObject ) { ReferenceBinding objectType = getType ( TypeConstants . JAVA_LANG_OBJECT ) ; if ( objectType == null ) { objectType = createMissingType ( null , TypeConstants . JAVA_LANG_OBJECT ) ; } missingType . setMissingSuperclass ( objectType ) ; } packageBinding . addType ( missingType ) ; if ( this . missingTypes == null ) this . missingTypes = new ArrayList ( 3 ) ; this . missingTypes . add ( missingType ) ; return missingType ; } public PackageBinding createPackage ( char [ ] [ ] compoundName ) { PackageBinding packageBinding = getPackage0 ( compoundName [ 0 ] ) ; if ( packageBinding == null || packageBinding == TheNotFoundPackage ) { packageBinding = new PackageBinding ( compoundName [ 0 ] , this ) ; this . knownPackages . put ( compoundName [ 0 ] , packageBinding ) ; } for ( int i = 1 , length = compoundName . length ; i < length ; i ++ ) { ReferenceBinding type = packageBinding . getType0 ( compoundName [ i ] ) ; if ( type != null && type != TheNotFoundType && ! ( type instanceof UnresolvedReferenceBinding ) ) return null ; PackageBinding parent = packageBinding ; if ( ( packageBinding = parent . getPackage0 ( compoundName [ i ] ) ) == null || packageBinding == TheNotFoundPackage ) { if ( this . nameEnvironment . findType ( compoundName [ i ] , parent . compoundName ) != null ) return null ; packageBinding = new PackageBinding ( CharOperation . subarray ( compoundName , 0 , i + 1 ) , parent , this ) ; parent . addPackage ( packageBinding ) ; } } return packageBinding ; } public ParameterizedGenericMethodBinding createParameterizedGenericMethod ( MethodBinding genericMethod , RawTypeBinding rawType ) { ParameterizedGenericMethodBinding [ ] cachedInfo = ( ParameterizedGenericMethodBinding [ ] ) this . uniqueParameterizedGenericMethodBindings . get ( genericMethod ) ; boolean needToGrow = false ; int index = 0 ; if ( cachedInfo != null ) { nextCachedMethod : for ( int max = cachedInfo . length ; index < max ; index ++ ) { ParameterizedGenericMethodBinding cachedMethod = cachedInfo [ index ] ; if ( cachedMethod == null ) break nextCachedMethod ; if ( ! cachedMethod . isRaw ) continue nextCachedMethod ; if ( cachedMethod . declaringClass != ( rawType == null ? genericMethod . declaringClass : rawType ) ) continue nextCachedMethod ; return cachedMethod ; } needToGrow = true ; } else { cachedInfo = new ParameterizedGenericMethodBinding [ 5 ] ; this . uniqueParameterizedGenericMethodBindings . put ( genericMethod , cachedInfo ) ; } int length = cachedInfo . length ; if ( needToGrow && index == length ) { System . arraycopy ( cachedInfo , 0 , cachedInfo = new ParameterizedGenericMethodBinding [ length * 2 ] , 0 , length ) ; this . uniqueParameterizedGenericMethodBindings . put ( genericMethod , cachedInfo ) ; } ParameterizedGenericMethodBinding parameterizedGenericMethod = new ParameterizedGenericMethodBinding ( genericMethod , rawType , this ) ; cachedInfo [ index ] = parameterizedGenericMethod ; return parameterizedGenericMethod ; } public ParameterizedGenericMethodBinding createParameterizedGenericMethod ( MethodBinding genericMethod , TypeBinding [ ] typeArguments ) { ParameterizedGenericMethodBinding [ ] cachedInfo = ( ParameterizedGenericMethodBinding [ ] ) this . uniqueParameterizedGenericMethodBindings . get ( genericMethod ) ; int argLength = typeArguments == null ? 0 : typeArguments . length ; boolean needToGrow = false ; int index = 0 ; if ( cachedInfo != null ) { nextCachedMethod : for ( int max = cachedInfo . length ; index < max ; index ++ ) { ParameterizedGenericMethodBinding cachedMethod = cachedInfo [ index ] ; if ( cachedMethod == null ) break nextCachedMethod ; if ( cachedMethod . isRaw ) continue nextCachedMethod ; TypeBinding [ ] cachedArguments = cachedMethod . typeArguments ; int cachedArgLength = cachedArguments == null ? 0 : cachedArguments . length ; if ( argLength != cachedArgLength ) continue nextCachedMethod ; for ( int j = 0 ; j < cachedArgLength ; j ++ ) { if ( typeArguments [ j ] != cachedArguments [ j ] ) continue nextCachedMethod ; } return cachedMethod ; } needToGrow = true ; } else { cachedInfo = new ParameterizedGenericMethodBinding [ 5 ] ; this . uniqueParameterizedGenericMethodBindings . put ( genericMethod , cachedInfo ) ; } int length = cachedInfo . length ; if ( needToGrow && index == length ) { System . arraycopy ( cachedInfo , 0 , cachedInfo = new ParameterizedGenericMethodBinding [ length * 2 ] , 0 , length ) ; this . uniqueParameterizedGenericMethodBindings . put ( genericMethod , cachedInfo ) ; } ParameterizedGenericMethodBinding parameterizedGenericMethod = new ParameterizedGenericMethodBinding ( genericMethod , typeArguments , this ) ; cachedInfo [ index ] = parameterizedGenericMethod ; return parameterizedGenericMethod ; } public ParameterizedMethodBinding createGetClassMethod ( TypeBinding receiverType , MethodBinding originalMethod , Scope scope ) { ParameterizedMethodBinding retVal = null ; if ( this . uniqueGetClassMethodBinding == null ) { this . uniqueGetClassMethodBinding = new SimpleLookupTable ( 3 ) ; } else { retVal = ( ParameterizedMethodBinding ) this . uniqueGetClassMethodBinding . get ( receiverType ) ; } if ( retVal == null ) { retVal = ParameterizedMethodBinding . instantiateGetClass ( receiverType , originalMethod , scope ) ; this . uniqueGetClassMethodBinding . put ( receiverType , retVal ) ; } return retVal ; } public ParameterizedTypeBinding createParameterizedType ( ReferenceBinding genericType , TypeBinding [ ] typeArguments , ReferenceBinding enclosingType ) { ParameterizedTypeBinding [ ] cachedInfo = ( ParameterizedTypeBinding [ ] ) this . uniqueParameterizedTypeBindings . get ( genericType ) ; int argLength = typeArguments == null ? 0 : typeArguments . length ; boolean needToGrow = false ; int index = 0 ; if ( cachedInfo != null ) { nextCachedType : for ( int max = cachedInfo . length ; index < max ; index ++ ) { ParameterizedTypeBinding cachedType = cachedInfo [ index ] ; if ( cachedType == null ) break nextCachedType ; if ( cachedType . actualType ( ) != genericType ) continue nextCachedType ; if ( cachedType . enclosingType ( ) != enclosingType ) continue nextCachedType ; TypeBinding [ ] cachedArguments = cachedType . arguments ; int cachedArgLength = cachedArguments == null ? 0 : cachedArguments . length ; if ( argLength != cachedArgLength ) continue nextCachedType ; for ( int j = 0 ; j < cachedArgLength ; j ++ ) { if ( typeArguments [ j ] != cachedArguments [ j ] ) continue nextCachedType ; } return cachedType ; } needToGrow = true ; } else { cachedInfo = new ParameterizedTypeBinding [ 5 ] ; this . uniqueParameterizedTypeBindings . put ( genericType , cachedInfo ) ; } int length = cachedInfo . length ; if ( needToGrow && index == length ) { System . arraycopy ( cachedInfo , 0 , cachedInfo = new ParameterizedTypeBinding [ length * 2 ] , 0 , length ) ; this . uniqueParameterizedTypeBindings . put ( genericType , cachedInfo ) ; } ParameterizedTypeBinding parameterizedType = new ParameterizedTypeBinding ( genericType , typeArguments , enclosingType , this ) ; cachedInfo [ index ] = parameterizedType ; return parameterizedType ; } public RawTypeBinding createRawType ( ReferenceBinding genericType , ReferenceBinding enclosingType ) { RawTypeBinding [ ] cachedInfo = ( RawTypeBinding [ ] ) this . uniqueRawTypeBindings . get ( genericType ) ; boolean needToGrow = false ; int index = 0 ; if ( cachedInfo != null ) { nextCachedType : for ( int max = cachedInfo . length ; index < max ; index ++ ) { RawTypeBinding cachedType = cachedInfo [ index ] ; if ( cachedType == null ) break nextCachedType ; if ( cachedType . actualType ( ) != genericType ) continue nextCachedType ; if ( cachedType . enclosingType ( ) != enclosingType ) continue nextCachedType ; return cachedType ; } needToGrow = true ; } else { cachedInfo = new RawTypeBinding [ 1 ] ; this . uniqueRawTypeBindings . put ( genericType , cachedInfo ) ; } int length = cachedInfo . length ; if ( needToGrow && index == length ) { System . arraycopy ( cachedInfo , 0 , cachedInfo = new RawTypeBinding [ length * 2 ] , 0 , length ) ; this . uniqueRawTypeBindings . put ( genericType , cachedInfo ) ; } RawTypeBinding rawType = new RawTypeBinding ( genericType , enclosingType , this ) ; cachedInfo [ index ] = rawType ; return rawType ; } public WildcardBinding createWildcard ( ReferenceBinding genericType , int rank , TypeBinding bound , TypeBinding [ ] otherBounds , int boundKind ) { if ( genericType == null ) genericType = ReferenceBinding . LUB_GENERIC ; WildcardBinding [ ] cachedInfo = ( WildcardBinding [ ] ) this . uniqueWildcardBindings . get ( genericType ) ; boolean needToGrow = false ; int index = 0 ; if ( cachedInfo != null ) { nextCachedType : for ( int max = cachedInfo . length ; index < max ; index ++ ) { WildcardBinding cachedType = cachedInfo [ index ] ; if ( cachedType == null ) break nextCachedType ; if ( cachedType . genericType != genericType ) continue nextCachedType ; if ( cachedType . rank != rank ) continue nextCachedType ; if ( cachedType . boundKind != boundKind ) continue nextCachedType ; if ( cachedType . bound != bound ) continue nextCachedType ; if ( cachedType . otherBounds != otherBounds ) { int cachedLength = cachedType . otherBounds == null ? 0 : cachedType . otherBounds . length ; int length = otherBounds == null ? 0 : otherBounds . length ; if ( cachedLength != length ) continue nextCachedType ; for ( int j = 0 ; j < length ; j ++ ) { if ( cachedType . otherBounds [ j ] != otherBounds [ j ] ) continue nextCachedType ; } } return cachedType ; } needToGrow = true ; } else { cachedInfo = new WildcardBinding [ 10 ] ; this . uniqueWildcardBindings . put ( genericType , cachedInfo ) ; } int length = cachedInfo . length ; if ( needToGrow && index == length ) { System . arraycopy ( cachedInfo , 0 , cachedInfo = new WildcardBinding [ length * 2 ] , 0 , length ) ; this . uniqueWildcardBindings . put ( genericType , cachedInfo ) ; } WildcardBinding wildcard = new WildcardBinding ( genericType , rank , bound , otherBounds , boundKind , this ) ; cachedInfo [ index ] = wildcard ; return wildcard ; } public AccessRestriction getAccessRestriction ( TypeBinding type ) { return ( AccessRestriction ) this . accessRestrictions . get ( type ) ; } public ReferenceBinding getCachedType ( char [ ] [ ] compoundName ) { if ( compoundName . length == 1 ) { if ( this . defaultPackage == null ) return null ; return this . defaultPackage . getType0 ( compoundName [ 0 ] ) ; } PackageBinding packageBinding = getPackage0 ( compoundName [ 0 ] ) ; if ( packageBinding == null || packageBinding == TheNotFoundPackage ) return null ; for ( int i = 1 , packageLength = compoundName . length - 1 ; i < packageLength ; i ++ ) if ( ( packageBinding = packageBinding . getPackage0 ( compoundName [ i ] ) ) == null || packageBinding == TheNotFoundPackage ) return null ; return packageBinding . getType0 ( compoundName [ compoundName . length - 1 ] ) ; } PackageBinding getPackage0 ( char [ ] name ) { return this . knownPackages . get ( name ) ; } public ReferenceBinding getResolvedType ( char [ ] [ ] compoundName , Scope scope ) { ReferenceBinding type = getType ( compoundName ) ; if ( type != null ) return type ; this . problemReporter . isClassPathCorrect ( compoundName , scope == null ? this . unitBeingCompleted : scope . referenceCompilationUnit ( ) , this . missingClassFileLocation ) ; return createMissingType ( null , compoundName ) ; } PackageBinding getTopLevelPackage ( char [ ] name ) { PackageBinding packageBinding = getPackage0 ( name ) ; if ( packageBinding != null ) { if ( packageBinding == TheNotFoundPackage ) return null ; return packageBinding ; } if ( this . nameEnvironment . isPackage ( null , name ) ) { this . knownPackages . put ( name , packageBinding = new PackageBinding ( name , this ) ) ; return packageBinding ; } this . knownPackages . put ( name , TheNotFoundPackage ) ; return null ; } public ReferenceBinding getType ( char [ ] [ ] compoundName ) { ReferenceBinding referenceBinding ; if ( compoundName . length == 1 ) { if ( this . defaultPackage == null ) return null ; if ( ( referenceBinding = this . defaultPackage . getType0 ( compoundName [ 0 ] ) ) == null ) { PackageBinding packageBinding = getPackage0 ( compoundName [ 0 ] ) ; if ( packageBinding != null && packageBinding != TheNotFoundPackage ) return null ; referenceBinding = askForType ( this . defaultPackage , compoundName [ 0 ] ) ; } } else { PackageBinding packageBinding = getPackage0 ( compoundName [ 0 ] ) ; if ( packageBinding == TheNotFoundPackage ) return null ; if ( packageBinding != null ) { for ( int i = 1 , packageLength = compoundName . length - 1 ; i < packageLength ; i ++ ) { if ( ( packageBinding = packageBinding . getPackage0 ( compoundName [ i ] ) ) == null ) break ; if ( packageBinding == TheNotFoundPackage ) return null ; } } if ( packageBinding == null ) referenceBinding = askForType ( compoundName ) ; else if ( ( referenceBinding = packageBinding . getType0 ( compoundName [ compoundName . length - 1 ] ) ) == null ) referenceBinding = askForType ( packageBinding , compoundName [ compoundName . length - 1 ] ) ; } if ( referenceBinding == null || referenceBinding == TheNotFoundType ) return null ; referenceBinding = ( ReferenceBinding ) BinaryTypeBinding . resolveType ( referenceBinding , this , false ) ; if ( referenceBinding . isNestedType ( ) ) return new ProblemReferenceBinding ( compoundName , referenceBinding , InternalNameProvided ) ; return referenceBinding ; } private TypeBinding [ ] getTypeArgumentsFromSignature ( SignatureWrapper wrapper , TypeVariableBinding [ ] staticVariables , ReferenceBinding enclosingType , ReferenceBinding genericType , char [ ] [ ] [ ] missingTypeNames ) { java . util . ArrayList args = new java . util . ArrayList ( 2 ) ; int rank = 0 ; do { args . add ( getTypeFromVariantTypeSignature ( wrapper , staticVariables , enclosingType , genericType , rank ++ , missingTypeNames ) ) ; } while ( wrapper . signature [ wrapper . start ] != '>' ) ; wrapper . start ++ ; TypeBinding [ ] typeArguments = new TypeBinding [ args . size ( ) ] ; args . toArray ( typeArguments ) ; return typeArguments ; } private ReferenceBinding getTypeFromCompoundName ( char [ ] [ ] compoundName , boolean isParameterized , boolean wasMissingType ) { ReferenceBinding binding = getCachedType ( compoundName ) ; if ( binding == null ) { PackageBinding packageBinding = computePackageFrom ( compoundName , false ) ; binding = new UnresolvedReferenceBinding ( compoundName , packageBinding ) ; if ( wasMissingType ) { binding . tagBits |= TagBits . HasMissingType ; } packageBinding . addType ( binding ) ; } else if ( binding == TheNotFoundType ) { this . problemReporter . isClassPathCorrect ( compoundName , this . unitBeingCompleted , this . missingClassFileLocation ) ; binding = createMissingType ( null , compoundName ) ; } else if ( ! isParameterized ) { binding = ( ReferenceBinding ) convertUnresolvedBinaryToRawType ( binding ) ; } return binding ; } ReferenceBinding getTypeFromConstantPoolName ( char [ ] signature , int start , int end , boolean isParameterized , char [ ] [ ] [ ] missingTypeNames ) { if ( end == - 1 ) end = signature . length ; char [ ] [ ] compoundName = CharOperation . splitOn ( '/' , signature , start , end ) ; boolean wasMissingType = false ; if ( missingTypeNames != null ) { for ( int i = 0 , max = missingTypeNames . length ; i < max ; i ++ ) { if ( CharOperation . equals ( compoundName , missingTypeNames [ i ] ) ) { wasMissingType = true ; break ; } } } return getTypeFromCompoundName ( compoundName , isParameterized , wasMissingType ) ; } TypeBinding getTypeFromSignature ( char [ ] signature , int start , int end , boolean isParameterized , TypeBinding enclosingType , char [ ] [ ] [ ] missingTypeNames ) { int dimension = 0 ; while ( signature [ start ] == '[' ) { start ++ ; dimension ++ ; } if ( end == - 1 ) end = signature . length - 1 ; TypeBinding binding = null ; if ( start == end ) { switch ( signature [ start ] ) { case 'I' : binding = TypeBinding . INT ; break ; case 'Z' : binding = TypeBinding . BOOLEAN ; break ; case 'V' : binding = TypeBinding . VOID ; break ; case 'C' : binding = TypeBinding . CHAR ; break ; case 'D' : binding = TypeBinding . DOUBLE ; break ; case 'B' : binding = TypeBinding . BYTE ; break ; case 'F' : binding = TypeBinding . FLOAT ; break ; case 'J' : binding = TypeBinding . LONG ; break ; case 'S' : binding = TypeBinding . SHORT ; break ; default : this . problemReporter . corruptedSignature ( enclosingType , signature , start ) ; } } else { binding = getTypeFromConstantPoolName ( signature , start + 1 , end , isParameterized , missingTypeNames ) ; } if ( dimension == 0 ) return binding ; return createArrayType ( binding , dimension ) ; } public TypeBinding getTypeFromTypeSignature ( SignatureWrapper wrapper , TypeVariableBinding [ ] staticVariables , ReferenceBinding enclosingType , char [ ] [ ] [ ] missingTypeNames ) { int dimension = 0 ; while ( wrapper . signature [ wrapper . start ] == '[' ) { wrapper . start ++ ; dimension ++ ; } if ( wrapper . signature [ wrapper . start ] == 'T' ) { int varStart = wrapper . start + 1 ; int varEnd = wrapper . computeEnd ( ) ; for ( int i = staticVariables . length ; -- i >= 0 ; ) if ( CharOperation . equals ( staticVariables [ i ] . sourceName , wrapper . signature , varStart , varEnd ) ) return dimension == 0 ? ( TypeBinding ) staticVariables [ i ] : createArrayType ( staticVariables [ i ] , dimension ) ; ReferenceBinding initialType = enclosingType ; do { TypeVariableBinding [ ] enclosingTypeVariables ; if ( enclosingType instanceof BinaryTypeBinding ) { enclosingTypeVariables = ( ( BinaryTypeBinding ) enclosingType ) . typeVariables ; } else { enclosingTypeVariables = enclosingType . typeVariables ( ) ; } for ( int i = enclosingTypeVariables . length ; -- i >= 0 ; ) if ( CharOperation . equals ( enclosingTypeVariables [ i ] . sourceName , wrapper . signature , varStart , varEnd ) ) return dimension == 0 ? ( TypeBinding ) enclosingTypeVariables [ i ] : createArrayType ( enclosingTypeVariables [ i ] , dimension ) ; } while ( ( enclosingType = enclosingType . enclosingType ( ) ) != null ) ; this . problemReporter . undefinedTypeVariableSignature ( CharOperation . subarray ( wrapper . signature , varStart , varEnd ) , initialType ) ; return null ; } boolean isParameterized ; TypeBinding type = getTypeFromSignature ( wrapper . signature , wrapper . start , wrapper . computeEnd ( ) , isParameterized = ( wrapper . end == wrapper . bracket ) , enclosingType , missingTypeNames ) ; if ( ! isParameterized ) return dimension == 0 ? type : createArrayType ( type , dimension ) ; ReferenceBinding actualType = ( ReferenceBinding ) type ; if ( actualType instanceof UnresolvedReferenceBinding ) if ( CharOperation . indexOf ( '$' , actualType . compoundName [ actualType . compoundName . length - 1 ] ) > 0 ) actualType = ( ReferenceBinding ) BinaryTypeBinding . resolveType ( actualType , this , false ) ; ReferenceBinding actualEnclosing = actualType . enclosingType ( ) ; if ( actualEnclosing != null ) { actualEnclosing = ( ReferenceBinding ) convertToRawType ( actualEnclosing , false ) ; } TypeBinding [ ] typeArguments = getTypeArgumentsFromSignature ( wrapper , staticVariables , enclosingType , actualType , missingTypeNames ) ; ParameterizedTypeBinding parameterizedType = createParameterizedType ( actualType , typeArguments , actualEnclosing ) ; while ( wrapper . signature [ wrapper . start ] == '.' ) { wrapper . start ++ ; int memberStart = wrapper . start ; char [ ] memberName = wrapper . nextWord ( ) ; BinaryTypeBinding . resolveType ( parameterizedType , this , false ) ; ReferenceBinding memberType = parameterizedType . genericType ( ) . getMemberType ( memberName ) ; if ( memberType == null ) this . problemReporter . corruptedSignature ( parameterizedType , wrapper . signature , memberStart ) ; if ( wrapper . signature [ wrapper . start ] == '<' ) { wrapper . start ++ ; typeArguments = getTypeArgumentsFromSignature ( wrapper , staticVariables , enclosingType , memberType , missingTypeNames ) ; } else { typeArguments = null ; } parameterizedType = createParameterizedType ( memberType , typeArguments , parameterizedType ) ; } wrapper . start ++ ; return dimension == 0 ? ( TypeBinding ) parameterizedType : createArrayType ( parameterizedType , dimension ) ; } TypeBinding getTypeFromVariantTypeSignature ( SignatureWrapper wrapper , TypeVariableBinding [ ] staticVariables , ReferenceBinding enclosingType , ReferenceBinding genericType , int rank , char [ ] [ ] [ ] missingTypeNames ) { switch ( wrapper . signature [ wrapper . start ] ) { case '-' : wrapper . start ++ ; TypeBinding bound = getTypeFromTypeSignature ( wrapper , staticVariables , enclosingType , missingTypeNames ) ; return createWildcard ( genericType , rank , bound , null , Wildcard . SUPER ) ; case '+' : wrapper . start ++ ; bound = getTypeFromTypeSignature ( wrapper , staticVariables , enclosingType , missingTypeNames ) ; return createWildcard ( genericType , rank , bound , null , Wildcard . EXTENDS ) ; case '*' : wrapper . start ++ ; return createWildcard ( genericType , rank , null , null , Wildcard . UNBOUND ) ; default : return getTypeFromTypeSignature ( wrapper , staticVariables , enclosingType , missingTypeNames ) ; } } boolean isMissingType ( char [ ] typeName ) { for ( int i = this . missingTypes == null ? 0 : this . missingTypes . size ( ) ; -- i >= 0 ; ) { MissingTypeBinding missingType = ( MissingTypeBinding ) this . missingTypes . get ( i ) ; if ( CharOperation . equals ( missingType . sourceName , typeName ) ) return true ; } return false ; } boolean isPackage ( char [ ] [ ] compoundName , char [ ] name ) { if ( compoundName == null || compoundName . length == 0 ) return this . nameEnvironment . isPackage ( null , name ) ; return this . nameEnvironment . isPackage ( compoundName , name ) ; } public MethodVerifier methodVerifier ( ) { if ( this . verifier == null ) this . verifier = newMethodVerifier ( ) ; return this . verifier ; } public MethodVerifier newMethodVerifier ( ) { return this . globalOptions . sourceLevel < ClassFileConstants . JDK1_5 ? new MethodVerifier ( this ) : new MethodVerifier15 ( this ) ; } public void releaseClassFiles ( org . eclipse . jdt . internal . compiler . ClassFile [ ] classFiles ) { for ( int i = 0 , fileCount = classFiles . length ; i < fileCount ; i ++ ) this . classFilePool . release ( classFiles [ i ] ) ; } public void reset ( ) { this . defaultPackage = new PackageBinding ( this ) ; this . defaultImports = null ; this . knownPackages = new HashtableOfPackage ( ) ; this . accessRestrictions = new HashMap ( 3 ) ; this . verifier = null ; for ( int i = this . uniqueArrayBindings . length ; -- i >= 0 ; ) { ArrayBinding [ ] arrayBindings = this . uniqueArrayBindings [ i ] ; if ( arrayBindings != null ) for ( int j = arrayBindings . length ; -- j >= 0 ; ) arrayBindings [ j ] = null ; } this . uniqueParameterizedTypeBindings = new SimpleLookupTable ( 3 ) ; this . uniqueRawTypeBindings = new SimpleLookupTable ( 3 ) ; this . uniqueWildcardBindings = new SimpleLookupTable ( 3 ) ; this . uniqueParameterizedGenericMethodBindings = new SimpleLookupTable ( 3 ) ; this . uniqueGetClassMethodBinding = null ; this . missingTypes = null ; for ( int i = this . units . length ; -- i >= 0 ; ) this . units [ i ] = null ; this . lastUnitIndex = - 1 ; this . lastCompletedUnitIndex = - 1 ; this . unitBeingCompleted = null ; this . classFilePool . reset ( ) ; } public void setAccessRestriction ( ReferenceBinding type , AccessRestriction accessRestriction ) { if ( accessRestriction == null ) return ; type . modifiers |= ExtraCompilerModifiers . AccRestrictedAccess ; this . accessRestrictions . put ( type , accessRestriction ) ; } void updateCaches ( UnresolvedReferenceBinding unresolvedType , ReferenceBinding resolvedType ) { if ( this . uniqueParameterizedTypeBindings . get ( unresolvedType ) != null ) { Object [ ] keys = this . uniqueParameterizedTypeBindings . keyTable ; for ( int i = 0 , l = keys . length ; i < l ; i ++ ) { if ( keys [ i ] == unresolvedType ) { keys [ i ] = resolvedType ; break ; } } } if ( this . uniqueRawTypeBindings . get ( unresolvedType ) != null ) { Object [ ] keys = this . uniqueRawTypeBindings . keyTable ; for ( int i = 0 , l = keys . length ; i < l ; i ++ ) { if ( keys [ i ] == unresolvedType ) { keys [ i ] = resolvedType ; break ; } } } if ( this . uniqueWildcardBindings . get ( unresolvedType ) != null ) { Object [ ] keys = this . uniqueWildcardBindings . keyTable ; for ( int i = 0 , l = keys . length ; i < l ; i ++ ) { if ( keys [ i ] == unresolvedType ) { keys [ i ] = resolvedType ; break ; } } } } } </s>