<s> package org . eclipse . jdt . internal . compiler . lookup ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AbstractVariableDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; public class ClassScope extends Scope { public TypeDeclaration referenceContext ; public TypeReference superTypeReference ; java . util . ArrayList deferredBoundChecks ; public ClassScope ( Scope parent , TypeDeclaration context ) { super ( Scope . CLASS_SCOPE , parent ) ; this . referenceContext = context ; this . deferredBoundChecks = null ; } void buildAnonymousTypeBinding ( SourceTypeBinding enclosingType , ReferenceBinding supertype ) { LocalTypeBinding anonymousType = buildLocalType ( enclosingType , enclosingType . fPackage ) ; anonymousType . modifiers |= ExtraCompilerModifiers . AccLocallyUsed ; if ( supertype . isInterface ( ) ) { anonymousType . superclass = getJavaLangObject ( ) ; anonymousType . superInterfaces = new ReferenceBinding [ ] { supertype } ; TypeReference typeReference = this . referenceContext . allocation . type ; if ( typeReference != null ) { if ( ( supertype . tagBits & TagBits . HasDirectWildcard ) != 0 ) { problemReporter ( ) . superTypeCannotUseWildcard ( anonymousType , typeReference , supertype ) ; anonymousType . tagBits |= TagBits . HierarchyHasProblems ; anonymousType . superInterfaces = Binding . NO_SUPERINTERFACES ; } } } else { anonymousType . superclass = supertype ; anonymousType . superInterfaces = Binding . NO_SUPERINTERFACES ; TypeReference typeReference = this . referenceContext . allocation . type ; if ( typeReference != null ) { if ( supertype . erasure ( ) . id == TypeIds . T_JavaLangEnum ) { problemReporter ( ) . cannotExtendEnum ( anonymousType , typeReference , supertype ) ; anonymousType . tagBits |= TagBits . HierarchyHasProblems ; anonymousType . superclass = getJavaLangObject ( ) ; } else if ( supertype . isFinal ( ) ) { problemReporter ( ) . anonymousClassCannotExtendFinalClass ( typeReference , supertype ) ; anonymousType . tagBits |= TagBits . HierarchyHasProblems ; anonymousType . superclass = getJavaLangObject ( ) ; } else if ( ( supertype . tagBits & TagBits . HasDirectWildcard ) != 0 ) { problemReporter ( ) . superTypeCannotUseWildcard ( anonymousType , typeReference , supertype ) ; anonymousType . tagBits |= TagBits . HierarchyHasProblems ; anonymousType . superclass = getJavaLangObject ( ) ; } } } connectMemberTypes ( ) ; buildFieldsAndMethods ( ) ; anonymousType . faultInTypesForFieldsAndMethods ( ) ; anonymousType . verifyMethods ( environment ( ) . methodVerifier ( ) ) ; } void buildFields ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; if ( sourceType . areFieldsInitialized ( ) ) return ; if ( this . referenceContext . fields == null ) { sourceType . setFields ( Binding . NO_FIELDS ) ; return ; } FieldDeclaration [ ] fields = this . referenceContext . fields ; int size = fields . length ; int count = 0 ; for ( int i = 0 ; i < size ; i ++ ) { switch ( fields [ i ] . getKind ( ) ) { case AbstractVariableDeclaration . FIELD : case AbstractVariableDeclaration . ENUM_CONSTANT : count ++ ; } } FieldBinding [ ] fieldBindings = new FieldBinding [ count ] ; HashtableOfObject knownFieldNames = new HashtableOfObject ( count ) ; count = 0 ; for ( int i = 0 ; i < size ; i ++ ) { FieldDeclaration field = fields [ i ] ; if ( field . getKind ( ) == AbstractVariableDeclaration . INITIALIZER ) { } else { FieldBinding fieldBinding = new FieldBinding ( field , null , field . modifiers | ExtraCompilerModifiers . AccUnresolved , sourceType ) ; fieldBinding . id = count ; checkAndSetModifiersForField ( fieldBinding , field ) ; if ( knownFieldNames . containsKey ( field . name ) ) { FieldBinding previousBinding = ( FieldBinding ) knownFieldNames . get ( field . name ) ; if ( previousBinding != null ) { for ( int f = 0 ; f < i ; f ++ ) { FieldDeclaration previousField = fields [ f ] ; if ( previousField . binding == previousBinding ) { problemReporter ( ) . duplicateFieldInType ( sourceType , previousField ) ; break ; } } } knownFieldNames . put ( field . name , null ) ; problemReporter ( ) . duplicateFieldInType ( sourceType , field ) ; field . binding = null ; } else { knownFieldNames . put ( field . name , fieldBinding ) ; fieldBindings [ count ++ ] = fieldBinding ; } } } if ( count != fieldBindings . length ) System . arraycopy ( fieldBindings , 0 , fieldBindings = new FieldBinding [ count ] , 0 , count ) ; sourceType . tagBits &= ~ ( TagBits . AreFieldsSorted | TagBits . AreFieldsComplete ) ; sourceType . setFields ( fieldBindings ) ; } void buildFieldsAndMethods ( ) { buildFields ( ) ; buildMethods ( ) ; SourceTypeBinding sourceType = this . referenceContext . binding ; if ( ! sourceType . isPrivate ( ) && sourceType . superclass instanceof SourceTypeBinding && sourceType . superclass . isPrivate ( ) ) ( ( SourceTypeBinding ) sourceType . superclass ) . tagIndirectlyAccessibleMembers ( ) ; if ( sourceType . isMemberType ( ) && ! sourceType . isLocalType ( ) ) ( ( MemberTypeBinding ) sourceType ) . checkSyntheticArgsAndFields ( ) ; ReferenceBinding [ ] memberTypes = sourceType . memberTypes ; for ( int i = 0 , length = memberTypes . length ; i < length ; i ++ ) ( ( SourceTypeBinding ) memberTypes [ i ] ) . scope . buildFieldsAndMethods ( ) ; } private LocalTypeBinding buildLocalType ( SourceTypeBinding enclosingType , PackageBinding packageBinding ) { this . referenceContext . scope = this ; this . referenceContext . staticInitializerScope = new MethodScope ( this , this . referenceContext , true ) ; this . referenceContext . initializerScope = new MethodScope ( this , this . referenceContext , false ) ; LocalTypeBinding localType = new LocalTypeBinding ( this , enclosingType , innermostSwitchCase ( ) ) ; this . referenceContext . binding = localType ; checkAndSetModifiers ( ) ; buildTypeVariables ( ) ; ReferenceBinding [ ] memberTypeBindings = Binding . NO_MEMBER_TYPES ; if ( this . referenceContext . memberTypes != null ) { int size = this . referenceContext . memberTypes . length ; memberTypeBindings = new ReferenceBinding [ size ] ; int count = 0 ; nextMember : for ( int i = 0 ; i < size ; i ++ ) { TypeDeclaration memberContext = this . referenceContext . memberTypes [ i ] ; switch ( TypeDeclaration . kind ( memberContext . modifiers ) ) { case TypeDeclaration . INTERFACE_DECL : case TypeDeclaration . ANNOTATION_TYPE_DECL : problemReporter ( ) . illegalLocalTypeDeclaration ( memberContext ) ; continue nextMember ; } ReferenceBinding type = localType ; do { if ( CharOperation . equals ( type . sourceName , memberContext . name ) ) { problemReporter ( ) . typeCollidesWithEnclosingType ( memberContext ) ; continue nextMember ; } type = type . enclosingType ( ) ; } while ( type != null ) ; for ( int j = 0 ; j < i ; j ++ ) { if ( CharOperation . equals ( this . referenceContext . memberTypes [ j ] . name , memberContext . name ) ) { problemReporter ( ) . duplicateNestedType ( memberContext ) ; continue nextMember ; } } ClassScope memberScope = new ClassScope ( this , this . referenceContext . memberTypes [ i ] ) ; LocalTypeBinding memberBinding = memberScope . buildLocalType ( localType , packageBinding ) ; memberBinding . setAsMemberType ( ) ; memberTypeBindings [ count ++ ] = memberBinding ; } if ( count != size ) System . arraycopy ( memberTypeBindings , 0 , memberTypeBindings = new ReferenceBinding [ count ] , 0 , count ) ; } localType . memberTypes = memberTypeBindings ; return localType ; } void buildLocalTypeBinding ( SourceTypeBinding enclosingType ) { LocalTypeBinding localType = buildLocalType ( enclosingType , enclosingType . fPackage ) ; connectTypeHierarchy ( ) ; if ( compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ) { checkParameterizedTypeBounds ( ) ; checkParameterizedSuperTypeCollisions ( ) ; } buildFieldsAndMethods ( ) ; localType . faultInTypesForFieldsAndMethods ( ) ; this . referenceContext . binding . verifyMethods ( environment ( ) . methodVerifier ( ) ) ; } private void buildMemberTypes ( AccessRestriction accessRestriction ) { SourceTypeBinding sourceType = this . referenceContext . binding ; ReferenceBinding [ ] memberTypeBindings = Binding . NO_MEMBER_TYPES ; if ( this . referenceContext . memberTypes != null ) { int length = this . referenceContext . memberTypes . length ; memberTypeBindings = new ReferenceBinding [ length ] ; int count = 0 ; nextMember : for ( int i = 0 ; i < length ; i ++ ) { TypeDeclaration memberContext = this . referenceContext . memberTypes [ i ] ; switch ( TypeDeclaration . kind ( memberContext . modifiers ) ) { case TypeDeclaration . INTERFACE_DECL : case TypeDeclaration . ANNOTATION_TYPE_DECL : if ( sourceType . isNestedType ( ) && sourceType . isClass ( ) && ! sourceType . isStatic ( ) ) { problemReporter ( ) . illegalLocalTypeDeclaration ( memberContext ) ; continue nextMember ; } break ; } ReferenceBinding type = sourceType ; do { if ( CharOperation . equals ( type . sourceName , memberContext . name ) ) { problemReporter ( ) . typeCollidesWithEnclosingType ( memberContext ) ; continue nextMember ; } type = type . enclosingType ( ) ; } while ( type != null ) ; for ( int j = 0 ; j < i ; j ++ ) { if ( CharOperation . equals ( this . referenceContext . memberTypes [ j ] . name , memberContext . name ) ) { problemReporter ( ) . duplicateNestedType ( memberContext ) ; continue nextMember ; } } ClassScope memberScope = buildClassScope ( this , memberContext ) ; memberTypeBindings [ count ++ ] = memberScope . buildType ( sourceType , sourceType . fPackage , accessRestriction ) ; } if ( count != length ) System . arraycopy ( memberTypeBindings , 0 , memberTypeBindings = new ReferenceBinding [ count ] , 0 , count ) ; } sourceType . memberTypes = memberTypeBindings ; } protected ClassScope buildClassScope ( Scope parent , TypeDeclaration typeDecl ) { return new ClassScope ( parent , typeDecl ) ; } void buildMethods ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; if ( sourceType . areMethodsInitialized ( ) ) return ; boolean isEnum = TypeDeclaration . kind ( this . referenceContext . modifiers ) == TypeDeclaration . ENUM_DECL ; if ( this . referenceContext . methods == null && ! isEnum ) { this . referenceContext . binding . setMethods ( Binding . NO_METHODS ) ; return ; } AbstractMethodDeclaration [ ] methods = this . referenceContext . methods ; int size = methods == null ? 0 : methods . length ; int clinitIndex = - 1 ; for ( int i = 0 ; i < size ; i ++ ) { if ( methods [ i ] . isClinit ( ) ) { clinitIndex = i ; break ; } } int count = isEnum ? 2 : 0 ; MethodBinding [ ] methodBindings = new MethodBinding [ ( clinitIndex == - 1 ? size : size - 1 ) + count ] ; if ( isEnum ) { methodBindings [ 0 ] = sourceType . addSyntheticEnumMethod ( TypeConstants . VALUES ) ; methodBindings [ 1 ] = sourceType . addSyntheticEnumMethod ( TypeConstants . VALUEOF ) ; } boolean hasNativeMethods = false ; if ( sourceType . isAbstract ( ) ) { for ( int i = 0 ; i < size ; i ++ ) { if ( i != clinitIndex ) { MethodScope scope = new MethodScope ( this , methods [ i ] , false ) ; MethodBinding methodBinding = scope . createMethod ( methods [ i ] ) ; if ( methodBinding != null ) { methodBindings [ count ++ ] = methodBinding ; hasNativeMethods = hasNativeMethods || methodBinding . isNative ( ) ; } } } } else { boolean hasAbstractMethods = false ; for ( int i = 0 ; i < size ; i ++ ) { if ( i != clinitIndex ) { MethodScope scope = new MethodScope ( this , methods [ i ] , false ) ; MethodBinding methodBinding = scope . createMethod ( methods [ i ] ) ; if ( methodBinding != null ) { methodBindings [ count ++ ] = methodBinding ; hasAbstractMethods = hasAbstractMethods || methodBinding . isAbstract ( ) ; hasNativeMethods = hasNativeMethods || methodBinding . isNative ( ) ; } } } if ( hasAbstractMethods ) problemReporter ( ) . abstractMethodInConcreteClass ( sourceType ) ; } if ( count != methodBindings . length ) System . arraycopy ( methodBindings , 0 , methodBindings = new MethodBinding [ count ] , 0 , count ) ; methodBindings = augmentMethodBindings ( methodBindings ) ; sourceType . tagBits &= ~ ( TagBits . AreMethodsSorted | TagBits . AreMethodsComplete ) ; sourceType . setMethods ( methodBindings ) ; if ( hasNativeMethods ) { for ( int i = 0 ; i < methodBindings . length ; i ++ ) { methodBindings [ i ] . modifiers |= ExtraCompilerModifiers . AccLocallyUsed ; } FieldBinding [ ] fields = sourceType . unResolvedFields ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { fields [ i ] . modifiers |= ExtraCompilerModifiers . AccLocallyUsed ; } } } protected MethodBinding [ ] augmentMethodBindings ( MethodBinding [ ] methodBindings ) { return methodBindings ; } SourceTypeBinding buildType ( SourceTypeBinding enclosingType , PackageBinding packageBinding , AccessRestriction accessRestriction ) { this . referenceContext . scope = this ; this . referenceContext . staticInitializerScope = new MethodScope ( this , this . referenceContext , true ) ; this . referenceContext . initializerScope = new MethodScope ( this , this . referenceContext , false ) ; if ( enclosingType == null ) { char [ ] [ ] className = CharOperation . arrayConcat ( packageBinding . compoundName , this . referenceContext . name ) ; this . referenceContext . binding = new SourceTypeBinding ( className , packageBinding , this ) ; } else { char [ ] [ ] className = CharOperation . deepCopy ( enclosingType . compoundName ) ; className [ className . length - 1 ] = CharOperation . concat ( className [ className . length - 1 ] , this . referenceContext . name , '$' ) ; ReferenceBinding existingType = packageBinding . getType0 ( className [ className . length - 1 ] ) ; if ( existingType != null ) { if ( existingType instanceof UnresolvedReferenceBinding ) { } else { this . parent . problemReporter ( ) . duplicateNestedType ( this . referenceContext ) ; } } this . referenceContext . binding = new MemberTypeBinding ( className , this , enclosingType ) ; } SourceTypeBinding sourceType = this . referenceContext . binding ; environment ( ) . setAccessRestriction ( sourceType , accessRestriction ) ; sourceType . fPackage . addType ( sourceType ) ; checkAndSetModifiers ( ) ; buildTypeVariables ( ) ; buildMemberTypes ( accessRestriction ) ; return sourceType ; } private void buildTypeVariables ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; TypeParameter [ ] typeParameters = this . referenceContext . typeParameters ; if ( typeParameters == null || typeParameters . length == 0 ) { sourceType . typeVariables = Binding . NO_TYPE_VARIABLES ; return ; } sourceType . typeVariables = Binding . NO_TYPE_VARIABLES ; if ( sourceType . id == TypeIds . T_JavaLangObject ) { problemReporter ( ) . objectCannotBeGeneric ( this . referenceContext ) ; return ; } sourceType . typeVariables = createTypeVariables ( typeParameters , sourceType ) ; sourceType . modifiers |= ExtraCompilerModifiers . AccGenericSignature ; } private void checkAndSetModifiers ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; int modifiers = sourceType . modifiers ; if ( ( modifiers & ExtraCompilerModifiers . AccAlternateModifierProblem ) != 0 ) problemReporter ( ) . duplicateModifierForType ( sourceType ) ; ReferenceBinding enclosingType = sourceType . enclosingType ( ) ; boolean isMemberType = sourceType . isMemberType ( ) ; if ( isMemberType ) { modifiers |= ( enclosingType . modifiers & ( ExtraCompilerModifiers . AccGenericSignature | ClassFileConstants . AccStrictfp ) ) ; if ( enclosingType . isInterface ( ) ) modifiers |= ClassFileConstants . AccPublic ; if ( sourceType . isEnum ( ) ) { if ( ! enclosingType . isStatic ( ) ) problemReporter ( ) . nonStaticContextForEnumMemberType ( sourceType ) ; else modifiers |= ClassFileConstants . AccStatic ; } } else if ( sourceType . isLocalType ( ) ) { if ( sourceType . isEnum ( ) ) { problemReporter ( ) . illegalLocalTypeDeclaration ( this . referenceContext ) ; sourceType . modifiers = 0 ; return ; } if ( sourceType . isAnonymousType ( ) ) { modifiers |= ClassFileConstants . AccFinal ; if ( this . referenceContext . allocation . type == null ) modifiers |= ClassFileConstants . AccEnum ; } Scope scope = this ; do { switch ( scope . kind ) { case METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) scope ; if ( methodScope . isInsideInitializer ( ) ) { SourceTypeBinding type = ( ( TypeDeclaration ) methodScope . referenceContext ) . binding ; if ( methodScope . initializedField != null ) { if ( methodScope . initializedField . isViewedAsDeprecated ( ) && ! sourceType . isDeprecated ( ) ) modifiers |= ExtraCompilerModifiers . AccDeprecatedImplicitly ; } else { if ( type . isStrictfp ( ) ) modifiers |= ClassFileConstants . AccStrictfp ; if ( type . isViewedAsDeprecated ( ) && ! sourceType . isDeprecated ( ) ) modifiers |= ExtraCompilerModifiers . AccDeprecatedImplicitly ; } } else { MethodBinding method = ( ( AbstractMethodDeclaration ) methodScope . referenceContext ) . binding ; if ( method != null ) { if ( method . isStrictfp ( ) ) modifiers |= ClassFileConstants . AccStrictfp ; if ( method . isViewedAsDeprecated ( ) && ! sourceType . isDeprecated ( ) ) modifiers |= ExtraCompilerModifiers . AccDeprecatedImplicitly ; } } break ; case CLASS_SCOPE : if ( enclosingType . isStrictfp ( ) ) modifiers |= ClassFileConstants . AccStrictfp ; if ( enclosingType . isViewedAsDeprecated ( ) && ! sourceType . isDeprecated ( ) ) modifiers |= ExtraCompilerModifiers . AccDeprecatedImplicitly ; break ; } scope = scope . parent ; } while ( scope != null ) ; } int realModifiers = modifiers & ExtraCompilerModifiers . AccJustFlag ; if ( ( realModifiers & ClassFileConstants . AccInterface ) != 0 ) { if ( isMemberType ) { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccPrivate | ClassFileConstants . AccProtected | ClassFileConstants . AccStatic | ClassFileConstants . AccAbstract | ClassFileConstants . AccInterface | ClassFileConstants . AccStrictfp | ClassFileConstants . AccAnnotation ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) { if ( ( realModifiers & ClassFileConstants . AccAnnotation ) != 0 ) problemReporter ( ) . illegalModifierForAnnotationMemberType ( sourceType ) ; else problemReporter ( ) . illegalModifierForMemberInterface ( sourceType ) ; } } else { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccAbstract | ClassFileConstants . AccInterface | ClassFileConstants . AccStrictfp | ClassFileConstants . AccAnnotation ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) { if ( ( realModifiers & ClassFileConstants . AccAnnotation ) != 0 ) problemReporter ( ) . illegalModifierForAnnotationType ( sourceType ) ; else problemReporter ( ) . illegalModifierForInterface ( sourceType ) ; } } if ( sourceType . sourceName == TypeConstants . PACKAGE_INFO_NAME && compilerOptions ( ) . targetJDK > ClassFileConstants . JDK1_5 ) { modifiers |= ClassFileConstants . AccSynthetic ; } modifiers |= ClassFileConstants . AccAbstract ; } else if ( ( realModifiers & ClassFileConstants . AccEnum ) != 0 ) { if ( isMemberType ) { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccPrivate | ClassFileConstants . AccProtected | ClassFileConstants . AccStatic | ClassFileConstants . AccStrictfp | ClassFileConstants . AccEnum ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) { problemReporter ( ) . illegalModifierForMemberEnum ( sourceType ) ; modifiers &= ~ ClassFileConstants . AccAbstract ; realModifiers &= ~ ClassFileConstants . AccAbstract ; } } else if ( sourceType . isLocalType ( ) ) { } else { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccStrictfp | ClassFileConstants . AccEnum ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) problemReporter ( ) . illegalModifierForEnum ( sourceType ) ; } if ( ! sourceType . isAnonymousType ( ) ) { checkAbstractEnum : { if ( ( this . referenceContext . bits & ASTNode . HasAbstractMethods ) != 0 ) { modifiers |= ClassFileConstants . AccAbstract ; break checkAbstractEnum ; } TypeDeclaration typeDeclaration = this . referenceContext ; FieldDeclaration [ ] fields = typeDeclaration . fields ; int fieldsLength = fields == null ? 0 : fields . length ; if ( fieldsLength == 0 ) break checkAbstractEnum ; AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; int methodsLength = methods == null ? 0 : methods . length ; boolean definesAbstractMethod = typeDeclaration . superInterfaces != null ; for ( int i = 0 ; i < methodsLength && ! definesAbstractMethod ; i ++ ) definesAbstractMethod = methods [ i ] . isAbstract ( ) ; if ( ! definesAbstractMethod ) break checkAbstractEnum ; boolean needAbstractBit = false ; for ( int i = 0 ; i < fieldsLength ; i ++ ) { FieldDeclaration fieldDecl = fields [ i ] ; if ( fieldDecl . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { if ( fieldDecl . initialization instanceof QualifiedAllocationExpression ) { needAbstractBit = true ; } else { break checkAbstractEnum ; } } } if ( needAbstractBit ) { modifiers |= ClassFileConstants . AccAbstract ; } } checkFinalEnum : { TypeDeclaration typeDeclaration = this . referenceContext ; FieldDeclaration [ ] fields = typeDeclaration . fields ; if ( fields != null ) { for ( int i = 0 , fieldsLength = fields . length ; i < fieldsLength ; i ++ ) { FieldDeclaration fieldDecl = fields [ i ] ; if ( fieldDecl . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { if ( fieldDecl . initialization instanceof QualifiedAllocationExpression ) { break checkFinalEnum ; } } } } modifiers |= ClassFileConstants . AccFinal ; } } } else { if ( isMemberType ) { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccPrivate | ClassFileConstants . AccProtected | ClassFileConstants . AccStatic | ClassFileConstants . AccAbstract | ClassFileConstants . AccFinal | ClassFileConstants . AccStrictfp ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) problemReporter ( ) . illegalModifierForMemberClass ( sourceType ) ; } else if ( sourceType . isLocalType ( ) ) { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccAbstract | ClassFileConstants . AccFinal | ClassFileConstants . AccStrictfp ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) problemReporter ( ) . illegalModifierForLocalClass ( sourceType ) ; } else { final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccAbstract | ClassFileConstants . AccFinal | ClassFileConstants . AccStrictfp ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) problemReporter ( ) . illegalModifierForClass ( sourceType ) ; } if ( ( realModifiers & ( ClassFileConstants . AccFinal | ClassFileConstants . AccAbstract ) ) == ( ClassFileConstants . AccFinal | ClassFileConstants . AccAbstract ) ) problemReporter ( ) . illegalModifierCombinationFinalAbstractForClass ( sourceType ) ; } if ( isMemberType ) { if ( enclosingType . isInterface ( ) ) { if ( ( realModifiers & ( ClassFileConstants . AccProtected | ClassFileConstants . AccPrivate ) ) != 0 ) { problemReporter ( ) . illegalVisibilityModifierForInterfaceMemberType ( sourceType ) ; if ( ( realModifiers & ClassFileConstants . AccProtected ) != 0 ) modifiers &= ~ ClassFileConstants . AccProtected ; if ( ( realModifiers & ClassFileConstants . AccPrivate ) != 0 ) modifiers &= ~ ClassFileConstants . AccPrivate ; } } else { int accessorBits = realModifiers & ( ClassFileConstants . AccPublic | ClassFileConstants . AccProtected | ClassFileConstants . AccPrivate ) ; if ( ( accessorBits & ( accessorBits - 1 ) ) > 1 ) { problemReporter ( ) . illegalVisibilityModifierCombinationForMemberType ( sourceType ) ; if ( ( accessorBits & ClassFileConstants . AccPublic ) != 0 ) { if ( ( accessorBits & ClassFileConstants . AccProtected ) != 0 ) modifiers &= ~ ClassFileConstants . AccProtected ; if ( ( accessorBits & ClassFileConstants . AccPrivate ) != 0 ) modifiers &= ~ ClassFileConstants . AccPrivate ; } else if ( ( accessorBits & ClassFileConstants . AccProtected ) != 0 && ( accessorBits & ClassFileConstants . AccPrivate ) != 0 ) { modifiers &= ~ ClassFileConstants . AccPrivate ; } } } if ( ( realModifiers & ClassFileConstants . AccStatic ) == 0 ) { if ( enclosingType . isInterface ( ) ) modifiers |= ClassFileConstants . AccStatic ; } else if ( ! enclosingType . isStatic ( ) ) { problemReporter ( ) . illegalStaticModifierForMemberType ( sourceType ) ; } } sourceType . modifiers = modifiers ; } private void checkAndSetModifiersForField ( FieldBinding fieldBinding , FieldDeclaration fieldDecl ) { int modifiers = fieldBinding . modifiers ; final ReferenceBinding declaringClass = fieldBinding . declaringClass ; if ( ( modifiers & ExtraCompilerModifiers . AccAlternateModifierProblem ) != 0 ) problemReporter ( ) . duplicateModifierForField ( declaringClass , fieldDecl ) ; if ( declaringClass . isInterface ( ) ) { final int IMPLICIT_MODIFIERS = ClassFileConstants . AccPublic | ClassFileConstants . AccStatic | ClassFileConstants . AccFinal ; modifiers |= IMPLICIT_MODIFIERS ; if ( ( modifiers & ExtraCompilerModifiers . AccJustFlag ) != IMPLICIT_MODIFIERS ) { if ( ( declaringClass . modifiers & ClassFileConstants . AccAnnotation ) != 0 ) problemReporter ( ) . illegalModifierForAnnotationField ( fieldDecl ) ; else problemReporter ( ) . illegalModifierForInterfaceField ( fieldDecl ) ; } fieldBinding . modifiers = modifiers ; return ; } else if ( fieldDecl . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { if ( ( modifiers & ExtraCompilerModifiers . AccJustFlag ) != 0 ) problemReporter ( ) . illegalModifierForEnumConstant ( declaringClass , fieldDecl ) ; final int IMPLICIT_MODIFIERS = ClassFileConstants . AccPublic | ClassFileConstants . AccStatic | ClassFileConstants . AccFinal | ClassFileConstants . AccEnum | ExtraCompilerModifiers . AccLocallyUsed ; fieldBinding . modifiers |= IMPLICIT_MODIFIERS ; return ; } int realModifiers = modifiers & ExtraCompilerModifiers . AccJustFlag ; final int UNEXPECTED_MODIFIERS = ~ ( ClassFileConstants . AccPublic | ClassFileConstants . AccPrivate | ClassFileConstants . AccProtected | ClassFileConstants . AccFinal | ClassFileConstants . AccStatic | ClassFileConstants . AccTransient | ClassFileConstants . AccVolatile ) ; if ( ( realModifiers & UNEXPECTED_MODIFIERS ) != 0 ) { problemReporter ( ) . illegalModifierForField ( declaringClass , fieldDecl ) ; modifiers &= ~ ExtraCompilerModifiers . AccJustFlag | ~ UNEXPECTED_MODIFIERS ; } int accessorBits = realModifiers & ( ClassFileConstants . AccPublic | ClassFileConstants . AccProtected | ClassFileConstants . AccPrivate ) ; if ( ( accessorBits & ( accessorBits - 1 ) ) > 1 ) { problemReporter ( ) . illegalVisibilityModifierCombinationForField ( declaringClass , fieldDecl ) ; if ( ( accessorBits & ClassFileConstants . AccPublic ) != 0 ) { if ( ( accessorBits & ClassFileConstants . AccProtected ) != 0 ) modifiers &= ~ ClassFileConstants . AccProtected ; if ( ( accessorBits & ClassFileConstants . AccPrivate ) != 0 ) modifiers &= ~ ClassFileConstants . AccPrivate ; } else if ( ( accessorBits & ClassFileConstants . AccProtected ) != 0 && ( accessorBits & ClassFileConstants . AccPrivate ) != 0 ) { modifiers &= ~ ClassFileConstants . AccPrivate ; } } if ( ( realModifiers & ( ClassFileConstants . AccFinal | ClassFileConstants . AccVolatile ) ) == ( ClassFileConstants . AccFinal | ClassFileConstants . AccVolatile ) ) problemReporter ( ) . illegalModifierCombinationFinalVolatileForField ( declaringClass , fieldDecl ) ; if ( fieldDecl . initialization == null && ( modifiers & ClassFileConstants . AccFinal ) != 0 ) modifiers |= ExtraCompilerModifiers . AccBlankFinal ; fieldBinding . modifiers = modifiers ; } public void checkParameterizedSuperTypeCollisions ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; ReferenceBinding [ ] interfaces = sourceType . superInterfaces ; Map invocations = new HashMap ( 2 ) ; ReferenceBinding itsSuperclass = sourceType . isInterface ( ) ? null : sourceType . superclass ; nextInterface : for ( int i = 0 , length = interfaces . length ; i < length ; i ++ ) { ReferenceBinding one = interfaces [ i ] ; if ( one == null ) continue nextInterface ; if ( itsSuperclass != null && hasErasedCandidatesCollisions ( itsSuperclass , one , invocations , sourceType , this . referenceContext ) ) continue nextInterface ; nextOtherInterface : for ( int j = 0 ; j < i ; j ++ ) { ReferenceBinding two = interfaces [ j ] ; if ( two == null ) continue nextOtherInterface ; if ( hasErasedCandidatesCollisions ( one , two , invocations , sourceType , this . referenceContext ) ) continue nextInterface ; } } TypeParameter [ ] typeParameters = this . referenceContext . typeParameters ; nextVariable : for ( int i = 0 , paramLength = typeParameters == null ? 0 : typeParameters . length ; i < paramLength ; i ++ ) { TypeParameter typeParameter = typeParameters [ i ] ; TypeVariableBinding typeVariable = typeParameter . binding ; if ( typeVariable == null || ! typeVariable . isValidBinding ( ) ) continue nextVariable ; TypeReference [ ] boundRefs = typeParameter . bounds ; if ( boundRefs != null ) { boolean checkSuperclass = typeVariable . firstBound == typeVariable . superclass ; for ( int j = 0 , boundLength = boundRefs . length ; j < boundLength ; j ++ ) { TypeReference typeRef = boundRefs [ j ] ; TypeBinding superType = typeRef . resolvedType ; if ( superType == null || ! superType . isValidBinding ( ) ) continue ; if ( checkSuperclass ) if ( hasErasedCandidatesCollisions ( superType , typeVariable . superclass , invocations , typeVariable , typeRef ) ) continue nextVariable ; for ( int index = typeVariable . superInterfaces . length ; -- index >= 0 ; ) if ( hasErasedCandidatesCollisions ( superType , typeVariable . superInterfaces [ index ] , invocations , typeVariable , typeRef ) ) continue nextVariable ; } } } ReferenceBinding [ ] memberTypes = this . referenceContext . binding . memberTypes ; if ( memberTypes != null && memberTypes != Binding . NO_MEMBER_TYPES ) for ( int i = 0 , size = memberTypes . length ; i < size ; i ++ ) ( ( SourceTypeBinding ) memberTypes [ i ] ) . scope . checkParameterizedSuperTypeCollisions ( ) ; } private void checkForInheritedMemberTypes ( SourceTypeBinding sourceType ) { ReferenceBinding currentType = sourceType ; ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = 0 ; do { if ( currentType . hasMemberTypes ( ) ) return ; 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 && ( currentType . tagBits & TagBits . HasNoMemberTypes ) == 0 ) ; if ( interfacesToVisit != null ) { boolean needToTag = false ; for ( int i = 0 ; i < nextPosition ; i ++ ) { ReferenceBinding anInterface = interfacesToVisit [ i ] ; if ( ( anInterface . tagBits & TagBits . HasNoMemberTypes ) == 0 ) { if ( anInterface . hasMemberTypes ( ) ) return ; needToTag = true ; ReferenceBinding [ ] itsInterfaces = anInterface . 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 ; } } } } if ( needToTag ) { for ( int i = 0 ; i < nextPosition ; i ++ ) interfacesToVisit [ i ] . tagBits |= TagBits . HasNoMemberTypes ; } } currentType = sourceType ; do { currentType . tagBits |= TagBits . HasNoMemberTypes ; } while ( ( currentType = currentType . superclass ( ) ) != null && ( currentType . tagBits & TagBits . HasNoMemberTypes ) == 0 ) ; } public void checkParameterizedTypeBounds ( ) { for ( int i = 0 , l = this . deferredBoundChecks == null ? 0 : this . deferredBoundChecks . size ( ) ; i < l ; i ++ ) ( ( TypeReference ) this . deferredBoundChecks . get ( i ) ) . checkBounds ( this ) ; this . deferredBoundChecks = null ; ReferenceBinding [ ] memberTypes = this . referenceContext . binding . memberTypes ; if ( memberTypes != null && memberTypes != Binding . NO_MEMBER_TYPES ) for ( int i = 0 , size = memberTypes . length ; i < size ; i ++ ) ( ( SourceTypeBinding ) memberTypes [ i ] ) . scope . checkParameterizedTypeBounds ( ) ; } private void connectMemberTypes ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; ReferenceBinding [ ] memberTypes = sourceType . memberTypes ; if ( memberTypes != null && memberTypes != Binding . NO_MEMBER_TYPES ) { for ( int i = 0 , size = memberTypes . length ; i < size ; i ++ ) ( ( SourceTypeBinding ) memberTypes [ i ] ) . scope . connectTypeHierarchy ( ) ; } } private boolean connectSuperclass ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; if ( sourceType . id == TypeIds . T_JavaLangObject ) { sourceType . superclass = null ; sourceType . superInterfaces = Binding . NO_SUPERINTERFACES ; if ( ! sourceType . isClass ( ) ) problemReporter ( ) . objectMustBeClass ( sourceType ) ; if ( this . referenceContext . superclass != null || ( this . referenceContext . superInterfaces != null && this . referenceContext . superInterfaces . length > 0 ) ) problemReporter ( ) . objectCannotHaveSuperTypes ( sourceType ) ; return true ; } if ( this . referenceContext . superclass == null ) { if ( sourceType . isEnum ( ) && compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ) return connectEnumSuperclass ( ) ; sourceType . superclass = getJavaLangObject ( ) ; return ! detectHierarchyCycle ( sourceType , sourceType . superclass , null ) ; } TypeReference superclassRef = this . referenceContext . superclass ; ReferenceBinding superclass = findSupertype ( superclassRef ) ; if ( superclass != null ) { if ( ! superclass . isClass ( ) && ( superclass . tagBits & TagBits . HasMissingType ) == 0 ) { if ( shouldReport ( IProblem . SuperclassMustBeAClass ) ) problemReporter ( ) . superclassMustBeAClass ( sourceType , superclassRef , superclass ) ; } else if ( superclass . isFinal ( ) ) { problemReporter ( ) . classExtendFinalClass ( sourceType , superclassRef , superclass ) ; } else if ( ( superclass . tagBits & TagBits . HasDirectWildcard ) != 0 ) { problemReporter ( ) . superTypeCannotUseWildcard ( sourceType , superclassRef , superclass ) ; } else if ( superclass . erasure ( ) . id == TypeIds . T_JavaLangEnum ) { problemReporter ( ) . cannotExtendEnum ( sourceType , superclassRef , superclass ) ; } else if ( ( superclass . tagBits & TagBits . HierarchyHasProblems ) != 0 || ! superclassRef . resolvedType . isValidBinding ( ) ) { sourceType . superclass = superclass ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; return superclassRef . resolvedType . isValidBinding ( ) ; } else { sourceType . superclass = superclass ; return true ; } } sourceType . tagBits |= TagBits . HierarchyHasProblems ; sourceType . superclass = getJavaLangObject ( ) ; if ( ( sourceType . superclass . tagBits & TagBits . BeginHierarchyCheck ) == 0 ) detectHierarchyCycle ( sourceType , sourceType . superclass , null ) ; return false ; } public boolean shouldReport ( int i ) { return true ; } private boolean connectEnumSuperclass ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; ReferenceBinding rootEnumType = getJavaLangEnum ( ) ; if ( ( rootEnumType . tagBits & TagBits . HasMissingType ) != 0 ) { sourceType . tagBits |= TagBits . HierarchyHasProblems ; sourceType . superclass = rootEnumType ; return false ; } boolean foundCycle = detectHierarchyCycle ( sourceType , rootEnumType , null ) ; TypeVariableBinding [ ] refTypeVariables = rootEnumType . typeVariables ( ) ; if ( refTypeVariables == Binding . NO_TYPE_VARIABLES ) { problemReporter ( ) . nonGenericTypeCannotBeParameterized ( 0 , null , rootEnumType , new TypeBinding [ ] { sourceType } ) ; return false ; } else if ( 1 != refTypeVariables . length ) { problemReporter ( ) . incorrectArityForParameterizedType ( null , rootEnumType , new TypeBinding [ ] { sourceType } ) ; return false ; } ParameterizedTypeBinding superType = environment ( ) . createParameterizedType ( rootEnumType , new TypeBinding [ ] { environment ( ) . convertToRawType ( sourceType , false ) , } , null ) ; sourceType . tagBits |= ( superType . tagBits & TagBits . HierarchyHasProblems ) ; sourceType . superclass = superType ; if ( refTypeVariables [ 0 ] . boundCheck ( superType , sourceType ) != TypeConstants . OK ) { problemReporter ( ) . typeMismatchError ( rootEnumType , refTypeVariables [ 0 ] , sourceType , null ) ; } return ! foundCycle ; } protected boolean connectSuperInterfaces ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; sourceType . superInterfaces = Binding . NO_SUPERINTERFACES ; if ( this . referenceContext . superInterfaces == null ) { if ( sourceType . isAnnotationType ( ) && compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ) { ReferenceBinding annotationType = getJavaLangAnnotationAnnotation ( ) ; boolean foundCycle = detectHierarchyCycle ( sourceType , annotationType , null ) ; sourceType . superInterfaces = new ReferenceBinding [ ] { annotationType } ; return ! foundCycle ; } return true ; } if ( sourceType . id == TypeIds . T_JavaLangObject ) return true ; boolean noProblems = true ; int length = this . referenceContext . superInterfaces . length ; ReferenceBinding [ ] interfaceBindings = new ReferenceBinding [ length ] ; int count = 0 ; nextInterface : for ( int i = 0 ; i < length ; i ++ ) { TypeReference superInterfaceRef = this . referenceContext . superInterfaces [ i ] ; ReferenceBinding superInterface = findSupertype ( superInterfaceRef ) ; if ( superInterface == null ) { sourceType . tagBits |= TagBits . HierarchyHasProblems ; noProblems = false ; continue nextInterface ; } for ( int j = 0 ; j < i ; j ++ ) { if ( interfaceBindings [ j ] == superInterface ) { problemReporter ( ) . duplicateSuperinterface ( sourceType , superInterfaceRef , superInterface ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; noProblems = false ; continue nextInterface ; } } if ( ! superInterface . isInterface ( ) && ( superInterface . tagBits & TagBits . HasMissingType ) == 0 ) { problemReporter ( ) . superinterfaceMustBeAnInterface ( sourceType , superInterfaceRef , superInterface ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; noProblems = false ; continue nextInterface ; } else if ( superInterface . isAnnotationType ( ) ) { problemReporter ( ) . annotationTypeUsedAsSuperinterface ( sourceType , superInterfaceRef , superInterface ) ; } if ( ( superInterface . tagBits & TagBits . HasDirectWildcard ) != 0 ) { problemReporter ( ) . superTypeCannotUseWildcard ( sourceType , superInterfaceRef , superInterface ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; noProblems = false ; continue nextInterface ; } if ( ( superInterface . tagBits & TagBits . HierarchyHasProblems ) != 0 || ! superInterfaceRef . resolvedType . isValidBinding ( ) ) { sourceType . tagBits |= TagBits . HierarchyHasProblems ; noProblems &= superInterfaceRef . resolvedType . isValidBinding ( ) ; } interfaceBindings [ count ++ ] = superInterface ; } if ( count > 0 ) { if ( count != length ) System . arraycopy ( interfaceBindings , 0 , interfaceBindings = new ReferenceBinding [ count ] , 0 , count ) ; sourceType . superInterfaces = interfaceBindings ; } return noProblems ; } void connectTypeHierarchy ( ) { SourceTypeBinding sourceType = this . referenceContext . binding ; if ( ( sourceType . tagBits & TagBits . BeginHierarchyCheck ) == 0 ) { sourceType . tagBits |= TagBits . BeginHierarchyCheck ; environment ( ) . typesBeingConnected . add ( sourceType ) ; boolean noProblems = connectSuperclass ( ) ; noProblems &= connectSuperInterfaces ( ) ; environment ( ) . typesBeingConnected . remove ( sourceType ) ; sourceType . tagBits |= TagBits . EndHierarchyCheck ; noProblems &= connectTypeVariables ( this . referenceContext . typeParameters , false ) ; sourceType . tagBits |= TagBits . TypeVariablesAreConnected ; if ( noProblems && sourceType . isHierarchyInconsistent ( ) ) problemReporter ( ) . hierarchyHasProblems ( sourceType ) ; } connectMemberTypes ( ) ; LookupEnvironment env = environment ( ) ; try { env . missingClassFileLocation = this . referenceContext ; checkForInheritedMemberTypes ( sourceType ) ; } catch ( AbortCompilation e ) { e . updateContext ( this . referenceContext , referenceCompilationUnit ( ) . compilationResult ) ; throw e ; } finally { env . missingClassFileLocation = null ; } } private void connectTypeHierarchyWithoutMembers ( ) { if ( this . parent instanceof CompilationUnitScope ) { if ( ( ( CompilationUnitScope ) this . parent ) . imports == null ) ( ( CompilationUnitScope ) this . parent ) . checkAndSetImports ( ) ; } else if ( this . parent instanceof ClassScope ) { ( ( ClassScope ) this . parent ) . connectTypeHierarchyWithoutMembers ( ) ; } SourceTypeBinding sourceType = this . referenceContext . binding ; if ( ( sourceType . tagBits & TagBits . BeginHierarchyCheck ) != 0 ) return ; sourceType . tagBits |= TagBits . BeginHierarchyCheck ; environment ( ) . typesBeingConnected . add ( sourceType ) ; boolean noProblems = connectSuperclass ( ) ; noProblems &= connectSuperInterfaces ( ) ; environment ( ) . typesBeingConnected . remove ( sourceType ) ; sourceType . tagBits |= TagBits . EndHierarchyCheck ; noProblems &= connectTypeVariables ( this . referenceContext . typeParameters , false ) ; sourceType . tagBits |= TagBits . TypeVariablesAreConnected ; if ( noProblems && sourceType . isHierarchyInconsistent ( ) ) problemReporter ( ) . hierarchyHasProblems ( sourceType ) ; } public boolean detectHierarchyCycle ( TypeBinding superType , TypeReference reference ) { if ( ! ( superType instanceof ReferenceBinding ) ) return false ; if ( reference == this . superTypeReference ) { if ( superType . isTypeVariable ( ) ) return false ; if ( superType . isParameterizedType ( ) ) superType = ( ( ParameterizedTypeBinding ) superType ) . genericType ( ) ; compilationUnitScope ( ) . recordSuperTypeReference ( superType ) ; return detectHierarchyCycle ( this . referenceContext . binding , ( ReferenceBinding ) superType , reference ) ; } if ( ( superType . tagBits & TagBits . BeginHierarchyCheck ) == 0 && superType instanceof SourceTypeBinding ) ( ( SourceTypeBinding ) superType ) . scope . connectTypeHierarchyWithoutMembers ( ) ; return false ; } private boolean detectHierarchyCycle ( SourceTypeBinding sourceType , ReferenceBinding superType , TypeReference reference ) { if ( superType . isRawType ( ) ) superType = ( ( RawTypeBinding ) superType ) . genericType ( ) ; if ( sourceType == superType ) { problemReporter ( ) . hierarchyCircularity ( sourceType , superType , reference ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; return true ; } if ( superType . isMemberType ( ) ) { ReferenceBinding current = superType . enclosingType ( ) ; do { if ( current . isHierarchyBeingActivelyConnected ( ) && current == sourceType ) { problemReporter ( ) . hierarchyCircularity ( sourceType , current , reference ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; current . tagBits |= TagBits . HierarchyHasProblems ; return true ; } } while ( ( current = current . enclosingType ( ) ) != null ) ; } if ( superType . isBinaryBinding ( ) ) { boolean hasCycle = false ; ReferenceBinding parentType = superType . superclass ( ) ; if ( parentType != null ) { if ( sourceType == parentType ) { problemReporter ( ) . hierarchyCircularity ( sourceType , superType , reference ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; superType . tagBits |= TagBits . HierarchyHasProblems ; return true ; } if ( parentType . isParameterizedType ( ) ) parentType = ( ( ParameterizedTypeBinding ) parentType ) . genericType ( ) ; hasCycle |= detectHierarchyCycle ( sourceType , parentType , reference ) ; if ( ( parentType . tagBits & TagBits . HierarchyHasProblems ) != 0 ) { sourceType . tagBits |= TagBits . HierarchyHasProblems ; parentType . tagBits |= TagBits . HierarchyHasProblems ; } } ReferenceBinding [ ] itsInterfaces = superType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { for ( int i = 0 , length = itsInterfaces . length ; i < length ; i ++ ) { ReferenceBinding anInterface = itsInterfaces [ i ] ; if ( sourceType == anInterface ) { problemReporter ( ) . hierarchyCircularity ( sourceType , superType , reference ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; superType . tagBits |= TagBits . HierarchyHasProblems ; return true ; } if ( anInterface . isParameterizedType ( ) ) anInterface = ( ( ParameterizedTypeBinding ) anInterface ) . genericType ( ) ; hasCycle |= detectHierarchyCycle ( sourceType , anInterface , reference ) ; if ( ( anInterface . tagBits & TagBits . HierarchyHasProblems ) != 0 ) { sourceType . tagBits |= TagBits . HierarchyHasProblems ; superType . tagBits |= TagBits . HierarchyHasProblems ; } } } return hasCycle ; } if ( superType . isHierarchyBeingActivelyConnected ( ) ) { org . eclipse . jdt . internal . compiler . ast . TypeReference ref = ( ( SourceTypeBinding ) superType ) . scope . superTypeReference ; if ( ref != null && ref . resolvedType != null && ( ( ReferenceBinding ) ref . resolvedType ) . isHierarchyBeingActivelyConnected ( ) ) { problemReporter ( ) . hierarchyCircularity ( sourceType , superType , reference ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; superType . tagBits |= TagBits . HierarchyHasProblems ; return true ; } if ( ref != null && ref . resolvedType == null ) { char [ ] referredName = ref . getLastToken ( ) ; for ( Iterator iter = environment ( ) . typesBeingConnected . iterator ( ) ; iter . hasNext ( ) ; ) { SourceTypeBinding type = ( SourceTypeBinding ) iter . next ( ) ; if ( CharOperation . equals ( referredName , type . sourceName ( ) ) ) { problemReporter ( ) . hierarchyCircularity ( sourceType , superType , reference ) ; sourceType . tagBits |= TagBits . HierarchyHasProblems ; superType . tagBits |= TagBits . HierarchyHasProblems ; return true ; } } } } if ( ( superType . tagBits & TagBits . BeginHierarchyCheck ) == 0 ) ( ( SourceTypeBinding ) superType ) . scope . connectTypeHierarchyWithoutMembers ( ) ; if ( ( superType . tagBits & TagBits . HierarchyHasProblems ) != 0 ) sourceType . tagBits |= TagBits . HierarchyHasProblems ; return false ; } private ReferenceBinding findSupertype ( TypeReference typeReference ) { CompilationUnitScope unitScope = compilationUnitScope ( ) ; LookupEnvironment env = unitScope . environment ; try { env . missingClassFileLocation = typeReference ; typeReference . aboutToResolve ( this ) ; unitScope . recordQualifiedReference ( typeReference . getTypeName ( ) ) ; this . superTypeReference = typeReference ; ReferenceBinding superType = ( ReferenceBinding ) typeReference . resolveSuperType ( this ) ; return superType ; } catch ( AbortCompilation e ) { SourceTypeBinding sourceType = this . referenceContext . binding ; if ( sourceType . superInterfaces == null ) sourceType . superInterfaces = Binding . NO_SUPERINTERFACES ; e . updateContext ( typeReference , referenceCompilationUnit ( ) . compilationResult ) ; throw e ; } finally { env . missingClassFileLocation = null ; this . superTypeReference = null ; } } public ProblemReporter problemReporter ( ) { MethodScope outerMethodScope ; if ( ( outerMethodScope = outerMostMethodScope ( ) ) == null ) { ProblemReporter problemReporter = referenceCompilationUnit ( ) . problemReporter ; problemReporter . referenceContext = this . referenceContext ; return problemReporter ; } return outerMethodScope . problemReporter ( ) ; } public TypeDeclaration referenceType ( ) { return this . referenceContext ; } public String toString ( ) { if ( this . referenceContext != null ) return "" + this . referenceContext . binding . toString ( ) ; return "" ; } public MethodBinding [ ] getAnyExtraMethods ( char [ ] selector ) { return null ; } } </s>