<s> package org . eclipse . jdt . internal . compiler . lookup ; import java . util . List ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . codegen . ConstantPool ; import org . eclipse . jdt . internal . compiler . util . Util ; public class MethodBinding extends Binding { public int modifiers ; public char [ ] selector ; public TypeBinding returnType ; public TypeBinding [ ] parameters ; public ReferenceBinding [ ] thrownExceptions ; public ReferenceBinding declaringClass ; public TypeVariableBinding [ ] typeVariables = Binding . NO_TYPE_VARIABLES ; char [ ] signature ; public long tagBits ; protected MethodBinding ( ) { } public MethodBinding ( int modifiers , char [ ] selector , TypeBinding returnType , TypeBinding [ ] parameters , ReferenceBinding [ ] thrownExceptions , ReferenceBinding declaringClass ) { this . modifiers = modifiers ; this . selector = selector ; this . returnType = returnType ; this . parameters = ( parameters == null || parameters . length == 0 ) ? Binding . NO_PARAMETERS : parameters ; this . thrownExceptions = ( thrownExceptions == null || thrownExceptions . length == 0 ) ? Binding . NO_EXCEPTIONS : thrownExceptions ; this . declaringClass = declaringClass ; if ( this . declaringClass != null ) { if ( this . declaringClass . isStrictfp ( ) ) if ( ! ( isNative ( ) || isAbstract ( ) ) ) this . modifiers |= ClassFileConstants . AccStrictfp ; } } public MethodBinding ( int modifiers , TypeBinding [ ] parameters , ReferenceBinding [ ] thrownExceptions , ReferenceBinding declaringClass ) { this ( modifiers , TypeConstants . INIT , TypeBinding . VOID , parameters , thrownExceptions , declaringClass ) ; } public MethodBinding ( MethodBinding initialMethodBinding , ReferenceBinding declaringClass ) { this . modifiers = initialMethodBinding . modifiers ; this . selector = initialMethodBinding . selector ; this . returnType = initialMethodBinding . returnType ; this . parameters = initialMethodBinding . parameters ; this . thrownExceptions = initialMethodBinding . thrownExceptions ; this . declaringClass = declaringClass ; declaringClass . storeAnnotationHolder ( this , initialMethodBinding . declaringClass . retrieveAnnotationHolder ( initialMethodBinding , true ) ) ; } public final boolean areParameterErasuresEqual ( MethodBinding method ) { TypeBinding [ ] args = method . parameters ; if ( this . parameters == args ) return true ; int length = this . parameters . length ; if ( length != args . length ) return false ; for ( int i = 0 ; i < length ; i ++ ) if ( this . parameters [ i ] != args [ i ] && this . parameters [ i ] . erasure ( ) != args [ i ] . erasure ( ) ) return false ; return true ; } public final boolean areParametersCompatibleWith ( TypeBinding [ ] arguments ) { int paramLength = this . parameters . length ; int argLength = arguments . length ; int lastIndex = argLength ; if ( isVarargs ( ) ) { lastIndex = paramLength - 1 ; if ( paramLength == argLength ) { TypeBinding varArgType = this . parameters [ lastIndex ] ; TypeBinding lastArgument = arguments [ lastIndex ] ; if ( varArgType != lastArgument && ! lastArgument . isCompatibleWith ( varArgType ) ) return false ; } else if ( paramLength < argLength ) { TypeBinding varArgType = ( ( ArrayBinding ) this . parameters [ lastIndex ] ) . elementsType ( ) ; for ( int i = lastIndex ; i < argLength ; i ++ ) if ( varArgType != arguments [ i ] && ! arguments [ i ] . isCompatibleWith ( varArgType ) ) return false ; } else if ( lastIndex != argLength ) { return false ; } } for ( int i = 0 ; i < lastIndex ; i ++ ) if ( this . parameters [ i ] != arguments [ i ] && ! arguments [ i ] . isCompatibleWith ( this . parameters [ i ] ) ) return false ; return true ; } public final boolean areParametersEqual ( MethodBinding method ) { TypeBinding [ ] args = method . parameters ; if ( this . parameters == args ) return true ; int length = this . parameters . length ; if ( length != args . length ) return false ; for ( int i = 0 ; i < length ; i ++ ) if ( this . parameters [ i ] != args [ i ] ) return false ; return true ; } public final boolean areTypeVariableErasuresEqual ( MethodBinding method ) { TypeVariableBinding [ ] vars = method . typeVariables ; if ( this . typeVariables == vars ) return true ; int length = this . typeVariables . length ; if ( length != vars . length ) return false ; for ( int i = 0 ; i < length ; i ++ ) if ( this . typeVariables [ i ] != vars [ i ] && this . typeVariables [ i ] . erasure ( ) != vars [ i ] . erasure ( ) ) return false ; return true ; } MethodBinding asRawMethod ( LookupEnvironment env ) { if ( this . typeVariables == Binding . NO_TYPE_VARIABLES ) return this ; int length = this . typeVariables . length ; TypeBinding [ ] arguments = new TypeBinding [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { TypeVariableBinding var = this . typeVariables [ i ] ; if ( var . boundsCount ( ) <= 1 ) { arguments [ i ] = env . convertToRawType ( var . upperBound ( ) , false ) ; } else { TypeBinding [ ] itsSuperinterfaces = var . superInterfaces ( ) ; int superLength = itsSuperinterfaces . length ; TypeBinding rawFirstBound = null ; TypeBinding [ ] rawOtherBounds = null ; if ( var . boundsCount ( ) == superLength ) { rawFirstBound = env . convertToRawType ( itsSuperinterfaces [ 0 ] , false ) ; rawOtherBounds = new TypeBinding [ superLength - 1 ] ; for ( int s = 1 ; s < superLength ; s ++ ) rawOtherBounds [ s - 1 ] = env . convertToRawType ( itsSuperinterfaces [ s ] , false ) ; } else { rawFirstBound = env . convertToRawType ( var . superclass ( ) , false ) ; rawOtherBounds = new TypeBinding [ superLength ] ; for ( int s = 0 ; s < superLength ; s ++ ) rawOtherBounds [ s ] = env . convertToRawType ( itsSuperinterfaces [ s ] , false ) ; } arguments [ i ] = env . createWildcard ( null , 0 , rawFirstBound , rawOtherBounds , org . eclipse . jdt . internal . compiler . ast . Wildcard . EXTENDS ) ; } } return env . createParameterizedGenericMethod ( this , arguments ) ; } public final boolean canBeSeenBy ( InvocationSite invocationSite , Scope scope ) { if ( isPublic ( ) ) return true ; SourceTypeBinding invocationType = scope . enclosingSourceType ( ) ; if ( invocationType == this . declaringClass ) return true ; if ( isProtected ( ) ) { if ( invocationType . fPackage == this . declaringClass . fPackage ) return true ; return invocationSite . isSuperAccess ( ) ; } if ( isPrivate ( ) ) { ReferenceBinding outerInvocationType = invocationType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = ( ReferenceBinding ) this . declaringClass . erasure ( ) ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } return outerInvocationType == outerDeclaringClass ; } return invocationType . fPackage == this . declaringClass . fPackage ; } public final boolean canBeSeenBy ( PackageBinding invocationPackage ) { if ( isPublic ( ) ) return true ; if ( isPrivate ( ) ) return false ; return invocationPackage == this . declaringClass . getPackage ( ) ; } public final boolean canBeSeenBy ( TypeBinding receiverType , InvocationSite invocationSite , Scope scope ) { if ( isPublic ( ) ) return true ; SourceTypeBinding invocationType = scope . enclosingSourceType ( ) ; if ( invocationType == this . declaringClass && invocationType == receiverType ) return true ; if ( invocationType == null ) return ! isPrivate ( ) && scope . getCurrentPackage ( ) == this . declaringClass . fPackage ; if ( isProtected ( ) ) { if ( invocationType == this . declaringClass ) return true ; if ( invocationType . fPackage == this . declaringClass . fPackage ) return true ; ReferenceBinding currentType = invocationType ; TypeBinding receiverErasure = receiverType . erasure ( ) ; ReferenceBinding declaringErasure = ( ReferenceBinding ) this . declaringClass . erasure ( ) ; int depth = 0 ; do { if ( currentType . findSuperTypeOriginatingFrom ( declaringErasure ) != null ) { if ( invocationSite . isSuperAccess ( ) ) return true ; if ( receiverType instanceof ArrayBinding ) return false ; if ( isStatic ( ) ) { if ( depth > 0 ) invocationSite . setDepth ( depth ) ; return true ; } if ( currentType == receiverErasure || receiverErasure . findSuperTypeOriginatingFrom ( currentType ) != null ) { if ( depth > 0 ) invocationSite . setDepth ( depth ) ; return true ; } } depth ++ ; currentType = currentType . enclosingType ( ) ; } while ( currentType != null ) ; return false ; } if ( isPrivate ( ) ) { receiverCheck : { if ( receiverType != this . declaringClass ) { if ( receiverType . isTypeVariable ( ) && ( ( TypeVariableBinding ) receiverType ) . isErasureBoundTo ( this . declaringClass . erasure ( ) ) ) break receiverCheck ; return false ; } } if ( invocationType != this . declaringClass ) { ReferenceBinding outerInvocationType = invocationType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = ( ReferenceBinding ) this . declaringClass . erasure ( ) ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } if ( outerInvocationType != outerDeclaringClass ) return false ; } return true ; } PackageBinding declaringPackage = this . declaringClass . fPackage ; if ( invocationType . fPackage != declaringPackage ) return false ; if ( receiverType instanceof ArrayBinding ) return false ; TypeBinding originalDeclaringClass = this . declaringClass . original ( ) ; ReferenceBinding currentType = ( ReferenceBinding ) ( receiverType ) ; do { if ( currentType . isCapture ( ) ) { if ( originalDeclaringClass == currentType . erasure ( ) . original ( ) ) return true ; } else { if ( originalDeclaringClass == currentType . original ( ) ) return true ; } PackageBinding currentPackage = currentType . fPackage ; if ( currentPackage != null && currentPackage != declaringPackage ) return false ; } while ( ( currentType = currentType . superclass ( ) ) != null ) ; return false ; } public List collectMissingTypes ( List missingTypes ) { if ( ( this . tagBits & TagBits . HasMissingType ) != 0 ) { missingTypes = this . returnType . collectMissingTypes ( missingTypes ) ; for ( int i = 0 , max = this . parameters . length ; i < max ; i ++ ) { missingTypes = this . parameters [ i ] . collectMissingTypes ( missingTypes ) ; } for ( int i = 0 , max = this . thrownExceptions . length ; i < max ; i ++ ) { missingTypes = this . thrownExceptions [ i ] . collectMissingTypes ( missingTypes ) ; } for ( int i = 0 , max = this . typeVariables . length ; i < max ; i ++ ) { TypeVariableBinding variable = this . typeVariables [ i ] ; missingTypes = variable . superclass ( ) . collectMissingTypes ( missingTypes ) ; ReferenceBinding [ ] interfaces = variable . superInterfaces ( ) ; for ( int j = 0 , length = interfaces . length ; j < length ; j ++ ) { missingTypes = interfaces [ j ] . collectMissingTypes ( missingTypes ) ; } } } return missingTypes ; } MethodBinding computeSubstitutedMethod ( MethodBinding method , LookupEnvironment env ) { int length = this . typeVariables . length ; TypeVariableBinding [ ] vars = method . typeVariables ; if ( length != vars . length ) return null ; ParameterizedGenericMethodBinding substitute = env . createParameterizedGenericMethod ( method , this . typeVariables ) ; for ( int i = 0 ; i < length ; i ++ ) if ( ! this . typeVariables [ i ] . isInterchangeableWith ( vars [ i ] , substitute ) ) return null ; return substitute ; } public char [ ] computeUniqueKey ( boolean isLeaf ) { char [ ] declaringKey = this . declaringClass . computeUniqueKey ( false ) ; int declaringLength = declaringKey . length ; int selectorLength = this . selector == TypeConstants . INIT ? 0 : this . selector . length ; char [ ] sig = genericSignature ( ) ; boolean isGeneric = sig != null ; if ( ! isGeneric ) sig = signature ( ) ; int signatureLength = sig . length ; int thrownExceptionsLength = this . thrownExceptions . length ; int thrownExceptionsSignatureLength = 0 ; char [ ] [ ] thrownExceptionsSignatures = null ; boolean addThrownExceptions = thrownExceptionsLength > 0 && ( ! isGeneric || CharOperation . lastIndexOf ( '^' , sig ) < 0 ) ; if ( addThrownExceptions ) { thrownExceptionsSignatures = new char [ thrownExceptionsLength ] [ ] ; for ( int i = 0 ; i < thrownExceptionsLength ; i ++ ) { if ( this . thrownExceptions [ i ] != null ) { thrownExceptionsSignatures [ i ] = this . thrownExceptions [ i ] . signature ( ) ; thrownExceptionsSignatureLength += thrownExceptionsSignatures [ i ] . length + 1 ; } } } char [ ] uniqueKey = new char [ declaringLength + 1 + selectorLength + signatureLength + thrownExceptionsSignatureLength ] ; int index = 0 ; System . arraycopy ( declaringKey , 0 , uniqueKey , index , declaringLength ) ; index = declaringLength ; uniqueKey [ index ++ ] = '.' ; System . arraycopy ( this . selector , 0 , uniqueKey , index , selectorLength ) ; index += selectorLength ; System . arraycopy ( sig , 0 , uniqueKey , index , signatureLength ) ; if ( thrownExceptionsSignatureLength > 0 ) { index += signatureLength ; for ( int i = 0 ; i < thrownExceptionsLength ; i ++ ) { char [ ] thrownExceptionSignature = thrownExceptionsSignatures [ i ] ; if ( thrownExceptionSignature != null ) { uniqueKey [ index ++ ] = '|' ; int length = thrownExceptionSignature . length ; System . arraycopy ( thrownExceptionSignature , 0 , uniqueKey , index , length ) ; index += length ; } } } return uniqueKey ; } public final char [ ] constantPoolName ( ) { return this . selector ; } public MethodBinding findOriginalInheritedMethod ( MethodBinding inheritedMethod ) { MethodBinding inheritedOriginal = inheritedMethod . original ( ) ; TypeBinding superType = this . declaringClass . findSuperTypeOriginatingFrom ( inheritedOriginal . declaringClass ) ; if ( superType == null || ! ( superType instanceof ReferenceBinding ) ) return null ; if ( inheritedOriginal . declaringClass != superType ) { MethodBinding [ ] superMethods = ( ( ReferenceBinding ) superType ) . getMethods ( inheritedOriginal . selector , inheritedOriginal . parameters . length ) ; for ( int m = 0 , l = superMethods . length ; m < l ; m ++ ) if ( superMethods [ m ] . original ( ) == inheritedOriginal ) return superMethods [ m ] ; } return inheritedOriginal ; } public char [ ] genericSignature ( ) { if ( ( this . modifiers & ExtraCompilerModifiers . AccGenericSignature ) == 0 ) return null ; StringBuffer sig = new StringBuffer ( 10 ) ; if ( this . typeVariables != Binding . NO_TYPE_VARIABLES ) { sig . append ( '<' ) ; for ( int i = 0 , length = this . typeVariables . length ; i < length ; i ++ ) { sig . append ( this . typeVariables [ i ] . genericSignature ( ) ) ; } sig . append ( '>' ) ; } sig . append ( '(' ) ; for ( int i = 0 , length = this . parameters . length ; i < length ; i ++ ) { sig . append ( this . parameters [ i ] . genericTypeSignature ( ) ) ; } sig . append ( ')' ) ; if ( this . returnType != null ) sig . append ( this . returnType . genericTypeSignature ( ) ) ; boolean needExceptionSignatures = false ; int length = this . thrownExceptions . length ; for ( int i = 0 ; i < length ; i ++ ) { if ( ( this . thrownExceptions [ i ] . modifiers & ExtraCompilerModifiers . AccGenericSignature ) != 0 ) { needExceptionSignatures = true ; break ; } } if ( needExceptionSignatures ) { for ( int i = 0 ; i < length ; i ++ ) { sig . append ( '^' ) ; sig . append ( this . thrownExceptions [ i ] . genericTypeSignature ( ) ) ; } } int sigLength = sig . length ( ) ; char [ ] genericSignature = new char [ sigLength ] ; sig . getChars ( 0 , sigLength , genericSignature , 0 ) ; return genericSignature ; } public final int getAccessFlags ( ) { return this . modifiers & ExtraCompilerModifiers . AccJustFlag ; } public AnnotationBinding [ ] getAnnotations ( ) { MethodBinding originalMethod = original ( ) ; return originalMethod . declaringClass . retrieveAnnotations ( originalMethod ) ; } public long getAnnotationTagBits ( ) { MethodBinding originalMethod = original ( ) ; if ( ( originalMethod . tagBits & TagBits . AnnotationResolved ) == 0 && originalMethod . declaringClass instanceof SourceTypeBinding ) { ClassScope scope = ( ( SourceTypeBinding ) originalMethod . declaringClass ) . scope ; if ( scope != null ) { TypeDeclaration typeDecl = scope . referenceContext ; AbstractMethodDeclaration methodDecl = typeDecl . declarationOf ( originalMethod ) ; if ( methodDecl != null ) ASTNode . resolveAnnotations ( methodDecl . scope , methodDecl . annotations , originalMethod ) ; } } return originalMethod . tagBits ; } public Object getDefaultValue ( ) { MethodBinding originalMethod = original ( ) ; if ( ( originalMethod . tagBits & TagBits . DefaultValueResolved ) == 0 ) { if ( originalMethod . declaringClass instanceof SourceTypeBinding ) { SourceTypeBinding sourceType = ( SourceTypeBinding ) originalMethod . declaringClass ; if ( sourceType . scope != null ) { AbstractMethodDeclaration methodDeclaration = originalMethod . sourceMethod ( ) ; if ( methodDeclaration != null && methodDeclaration . isAnnotationMethod ( ) ) { methodDeclaration . resolve ( sourceType . scope ) ; } } } originalMethod . tagBits |= TagBits . DefaultValueResolved ; } AnnotationHolder holder = originalMethod . declaringClass . retrieveAnnotationHolder ( originalMethod , true ) ; return holder == null ? null : holder . getDefaultValue ( ) ; } public AnnotationBinding [ ] [ ] getParameterAnnotations ( ) { int length ; if ( ( length = this . parameters . length ) == 0 ) { return null ; } MethodBinding originalMethod = original ( ) ; AnnotationHolder holder = originalMethod . declaringClass . retrieveAnnotationHolder ( originalMethod , true ) ; AnnotationBinding [ ] [ ] allParameterAnnotations = holder == null ? null : holder . getParameterAnnotations ( ) ; if ( allParameterAnnotations == null && ( this . tagBits & TagBits . HasParameterAnnotations ) != 0 ) { allParameterAnnotations = new AnnotationBinding [ length ] [ ] ; if ( this . declaringClass instanceof SourceTypeBinding ) { SourceTypeBinding sourceType = ( SourceTypeBinding ) this . declaringClass ; if ( sourceType . scope != null ) { AbstractMethodDeclaration methodDecl = sourceType . scope . referenceType ( ) . declarationOf ( this ) ; for ( int i = 0 ; i < length ; i ++ ) { Argument argument = methodDecl . arguments [ i ] ; if ( argument . annotations != null ) { ASTNode . resolveAnnotations ( methodDecl . scope , argument . annotations , argument . binding ) ; allParameterAnnotations [ i ] = argument . binding . getAnnotations ( ) ; } else { allParameterAnnotations [ i ] = Binding . NO_ANNOTATIONS ; } } } else { for ( int i = 0 ; i < length ; i ++ ) { allParameterAnnotations [ i ] = Binding . NO_ANNOTATIONS ; } } } else { for ( int i = 0 ; i < length ; i ++ ) { allParameterAnnotations [ i ] = Binding . NO_ANNOTATIONS ; } } setParameterAnnotations ( allParameterAnnotations ) ; } return allParameterAnnotations ; } public TypeVariableBinding getTypeVariable ( char [ ] variableName ) { for ( int i = this . typeVariables . length ; -- i >= 0 ; ) if ( CharOperation . equals ( this . typeVariables [ i ] . sourceName , variableName ) ) return this . typeVariables [ i ] ; return null ; } public boolean hasSubstitutedParameters ( ) { return false ; } public boolean hasSubstitutedReturnType ( ) { return false ; } public final boolean isAbstract ( ) { return ( this . modifiers & ClassFileConstants . AccAbstract ) != 0 ; } public final boolean isBridge ( ) { return ( this . modifiers & ClassFileConstants . AccBridge ) != 0 ; } public final boolean isConstructor ( ) { return this . selector == TypeConstants . INIT ; } public final boolean isDefault ( ) { return ! isPublic ( ) && ! isProtected ( ) && ! isPrivate ( ) ; } public final boolean isDefaultAbstract ( ) { return ( this . modifiers & ExtraCompilerModifiers . AccDefaultAbstract ) != 0 ; } public final boolean isDeprecated ( ) { return ( this . modifiers & ClassFileConstants . AccDeprecated ) != 0 ; } public final boolean isFinal ( ) { return ( this . modifiers & ClassFileConstants . AccFinal ) != 0 ; } public final boolean isImplementing ( ) { return ( this . modifiers & ExtraCompilerModifiers . AccImplementing ) != 0 ; } public final boolean isMain ( ) { if ( this . selector . length == 4 && CharOperation . equals ( this . selector , TypeConstants . MAIN ) && ( ( this . modifiers & ( ClassFileConstants . AccPublic | ClassFileConstants . AccStatic ) ) != 0 ) && TypeBinding . VOID == this . returnType && this . parameters . length == 1 ) { TypeBinding paramType = this . parameters [ 0 ] ; if ( paramType . dimensions ( ) == 1 && paramType . leafComponentType ( ) . id == TypeIds . T_JavaLangString ) { return true ; } } return false ; } public final boolean isNative ( ) { return ( this . modifiers & ClassFileConstants . AccNative ) != 0 ; } public final boolean isOverriding ( ) { return ( this . modifiers & ExtraCompilerModifiers . AccOverriding ) != 0 ; } public final boolean isPrivate ( ) { return ( this . modifiers & ClassFileConstants . AccPrivate ) != 0 ; } public final boolean isOrEnclosedByPrivateType ( ) { if ( ( this . modifiers & ClassFileConstants . AccPrivate ) != 0 ) return true ; return this . declaringClass != null && this . declaringClass . isOrEnclosedByPrivateType ( ) ; } public final boolean isProtected ( ) { return ( this . modifiers & ClassFileConstants . AccProtected ) != 0 ; } public final boolean isPublic ( ) { return ( this . modifiers & ClassFileConstants . AccPublic ) != 0 ; } public final boolean isStatic ( ) { return ( this . modifiers & ClassFileConstants . AccStatic ) != 0 ; } public final boolean isStrictfp ( ) { return ( this . modifiers & ClassFileConstants . AccStrictfp ) != 0 ; } public final boolean isSynchronized ( ) { return ( this . modifiers & ClassFileConstants . AccSynchronized ) != 0 ; } public final boolean isSynthetic ( ) { return ( this . modifiers & ClassFileConstants . AccSynthetic ) != 0 ; } public final boolean isUsed ( ) { return ( this . modifiers & ExtraCompilerModifiers . AccLocallyUsed ) != 0 ; } public final boolean isVarargs ( ) { return ( this . modifiers & ClassFileConstants . AccVarargs ) != 0 ; } public final boolean isViewedAsDeprecated ( ) { return ( this . modifiers & ( ClassFileConstants . AccDeprecated | ExtraCompilerModifiers . AccDeprecatedImplicitly ) ) != 0 ; } public final int kind ( ) { return Binding . METHOD ; } public MethodBinding original ( ) { return this ; } public char [ ] readableName ( ) { StringBuffer buffer = new StringBuffer ( this . parameters . length + 1 * 20 ) ; if ( isConstructor ( ) ) buffer . append ( this . declaringClass . sourceName ( ) ) ; else buffer . append ( this . selector ) ; buffer . append ( '(' ) ; if ( this . parameters != Binding . NO_PARAMETERS ) { for ( int i = 0 , length = this . parameters . length ; i < length ; i ++ ) { if ( i > 0 ) buffer . append ( ", " ) ; buffer . append ( this . parameters [ i ] . sourceName ( ) ) ; } } buffer . append ( ')' ) ; return buffer . toString ( ) . toCharArray ( ) ; } public void setAnnotations ( AnnotationBinding [ ] annotations ) { this . declaringClass . storeAnnotations ( this , annotations ) ; } public void setAnnotations ( AnnotationBinding [ ] annotations , AnnotationBinding [ ] [ ] parameterAnnotations , Object defaultValue , LookupEnvironment optionalEnv ) { this . declaringClass . storeAnnotationHolder ( this , AnnotationHolder . storeAnnotations ( annotations , parameterAnnotations , defaultValue , optionalEnv ) ) ; } public void setDefaultValue ( Object defaultValue ) { MethodBinding originalMethod = original ( ) ; originalMethod . tagBits |= TagBits . DefaultValueResolved ; AnnotationHolder holder = this . declaringClass . retrieveAnnotationHolder ( this , false ) ; if ( holder == null ) setAnnotations ( null , null , defaultValue , null ) ; else setAnnotations ( holder . getAnnotations ( ) , holder . getParameterAnnotations ( ) , defaultValue , null ) ; } public void setParameterAnnotations ( AnnotationBinding [ ] [ ] parameterAnnotations ) { AnnotationHolder holder = this . declaringClass . retrieveAnnotationHolder ( this , false ) ; if ( holder == null ) setAnnotations ( null , parameterAnnotations , null , null ) ; else setAnnotations ( holder . getAnnotations ( ) , parameterAnnotations , holder . getDefaultValue ( ) , null ) ; } protected final void setSelector ( char [ ] selector ) { this . selector = selector ; this . signature = null ; } public char [ ] shortReadableName ( ) { StringBuffer buffer = new StringBuffer ( this . parameters . length + 1 * 20 ) ; if ( isConstructor ( ) ) buffer . append ( this . declaringClass . shortReadableName ( ) ) ; else buffer . append ( this . selector ) ; buffer . append ( '(' ) ; if ( this . parameters != Binding . NO_PARAMETERS ) { for ( int i = 0 , length = this . parameters . length ; i < length ; i ++ ) { if ( i > 0 ) buffer . append ( ", " ) ; buffer . append ( this . parameters [ i ] . shortReadableName ( ) ) ; } } buffer . append ( ')' ) ; int nameLength = buffer . length ( ) ; char [ ] shortReadableName = new char [ nameLength ] ; buffer . getChars ( 0 , nameLength , shortReadableName , 0 ) ; return shortReadableName ; } public final char [ ] signature ( ) { if ( this . signature != null ) return this . signature ; StringBuffer buffer = new StringBuffer ( this . parameters . length + 1 * 20 ) ; buffer . append ( '(' ) ; TypeBinding [ ] targetParameters = this . parameters ; boolean isConstructor = isConstructor ( ) ; if ( isConstructor && this . declaringClass . isEnum ( ) ) { buffer . append ( ConstantPool . JavaLangStringSignature ) ; buffer . append ( TypeBinding . INT . signature ( ) ) ; } boolean needSynthetics = isConstructor && this . declaringClass . isNestedType ( ) ; if ( needSynthetics ) { ReferenceBinding [ ] syntheticArgumentTypes = this . declaringClass . syntheticEnclosingInstanceTypes ( ) ; if ( syntheticArgumentTypes != null ) { for ( int i = 0 , count = syntheticArgumentTypes . length ; i < count ; i ++ ) { buffer . append ( syntheticArgumentTypes [ i ] . signature ( ) ) ; } } if ( this instanceof SyntheticMethodBinding ) { targetParameters = ( ( SyntheticMethodBinding ) this ) . targetMethod . parameters ; } } if ( targetParameters != Binding . NO_PARAMETERS ) { for ( int i = 0 ; i < targetParameters . length ; i ++ ) { buffer . append ( targetParameters [ i ] . signature ( ) ) ; } } if ( needSynthetics ) { SyntheticArgumentBinding [ ] syntheticOuterArguments = this . declaringClass . syntheticOuterLocalVariables ( ) ; int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments . length ; for ( int i = 0 ; i < count ; i ++ ) { buffer . append ( syntheticOuterArguments [ i ] . type . signature ( ) ) ; } for ( int i = targetParameters . length , extraLength = this . parameters . length ; i < extraLength ; i ++ ) { buffer . append ( this . parameters [ i ] . signature ( ) ) ; } } buffer . append ( ')' ) ; if ( this . returnType != null ) buffer . append ( this . returnType . signature ( ) ) ; int nameLength = buffer . length ( ) ; this . signature = new char [ nameLength ] ; buffer . getChars ( 0 , nameLength , this . signature , 0 ) ; return this . signature ; } public final char [ ] signature ( ClassFile classFile ) { if ( this . signature != null ) { if ( ( this . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { boolean isConstructor = isConstructor ( ) ; TypeBinding [ ] targetParameters = this . parameters ; boolean needSynthetics = isConstructor && this . declaringClass . isNestedType ( ) ; if ( needSynthetics ) { ReferenceBinding [ ] syntheticArgumentTypes = this . declaringClass . syntheticEnclosingInstanceTypes ( ) ; if ( syntheticArgumentTypes != null ) { for ( int i = 0 , count = syntheticArgumentTypes . length ; i < count ; i ++ ) { ReferenceBinding syntheticArgumentType = syntheticArgumentTypes [ i ] ; if ( ( syntheticArgumentType . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { Util . recordNestedType ( classFile , syntheticArgumentType ) ; } } } if ( this instanceof SyntheticMethodBinding ) { targetParameters = ( ( SyntheticMethodBinding ) this ) . targetMethod . parameters ; } } if ( targetParameters != Binding . NO_PARAMETERS ) { for ( int i = 0 , max = targetParameters . length ; i < max ; i ++ ) { TypeBinding targetParameter = targetParameters [ i ] ; TypeBinding leafTargetParameterType = targetParameter . leafComponentType ( ) ; if ( ( leafTargetParameterType . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { Util . recordNestedType ( classFile , leafTargetParameterType ) ; } } } if ( needSynthetics ) { for ( int i = targetParameters . length , extraLength = this . parameters . length ; i < extraLength ; i ++ ) { TypeBinding parameter = this . parameters [ i ] ; TypeBinding leafParameterType = parameter . leafComponentType ( ) ; if ( ( leafParameterType . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { Util . recordNestedType ( classFile , leafParameterType ) ; } } } if ( this . returnType != null ) { TypeBinding ret = this . returnType . leafComponentType ( ) ; if ( ( ret . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { Util . recordNestedType ( classFile , ret ) ; } } } return this . signature ; } StringBuffer buffer = new StringBuffer ( this . parameters . length + 1 * 20 ) ; buffer . append ( '(' ) ; TypeBinding [ ] targetParameters = this . parameters ; boolean isConstructor = isConstructor ( ) ; if ( isConstructor && this . declaringClass . isEnum ( ) ) { buffer . append ( ConstantPool . JavaLangStringSignature ) ; buffer . append ( TypeBinding . INT . signature ( ) ) ; } boolean needSynthetics = isConstructor && this . declaringClass . isNestedType ( ) ; if ( needSynthetics ) { ReferenceBinding [ ] syntheticArgumentTypes = this . declaringClass . syntheticEnclosingInstanceTypes ( ) ; if ( syntheticArgumentTypes != null ) { for ( int i = 0 , count = syntheticArgumentTypes . length ; i < count ; i ++ ) { ReferenceBinding syntheticArgumentType = syntheticArgumentTypes [ i ] ; if ( ( syntheticArgumentType . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { this . tagBits |= TagBits . ContainsNestedTypeReferences ; Util . recordNestedType ( classFile , syntheticArgumentType ) ; } buffer . append ( syntheticArgumentType . signature ( ) ) ; } } if ( this instanceof SyntheticMethodBinding ) { targetParameters = ( ( SyntheticMethodBinding ) this ) . targetMethod . parameters ; } } if ( targetParameters != Binding . NO_PARAMETERS ) { for ( int i = 0 , max = targetParameters . length ; i < max ; i ++ ) { TypeBinding targetParameter = targetParameters [ i ] ; TypeBinding leafTargetParameterType = targetParameter . leafComponentType ( ) ; if ( ( leafTargetParameterType . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { this . tagBits |= TagBits . ContainsNestedTypeReferences ; Util . recordNestedType ( classFile , leafTargetParameterType ) ; } buffer . append ( targetParameter . signature ( ) ) ; } } if ( needSynthetics ) { SyntheticArgumentBinding [ ] syntheticOuterArguments = this . declaringClass . syntheticOuterLocalVariables ( ) ; int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments . length ; for ( int i = 0 ; i < count ; i ++ ) { buffer . append ( syntheticOuterArguments [ i ] . type . signature ( ) ) ; } for ( int i = targetParameters . length , extraLength = this . parameters . length ; i < extraLength ; i ++ ) { TypeBinding parameter = this . parameters [ i ] ; TypeBinding leafParameterType = parameter . leafComponentType ( ) ; if ( ( leafParameterType . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { this . tagBits |= TagBits . ContainsNestedTypeReferences ; Util . recordNestedType ( classFile , leafParameterType ) ; } buffer . append ( parameter . signature ( ) ) ; } } buffer . append ( ')' ) ; if ( this . returnType != null ) { TypeBinding ret = this . returnType . leafComponentType ( ) ; if ( ( ret . tagBits & TagBits . ContainsNestedTypeReferences ) != 0 ) { this . tagBits |= TagBits . ContainsNestedTypeReferences ; Util . recordNestedType ( classFile , ret ) ; } buffer . append ( this . returnType . signature ( ) ) ; } int nameLength = buffer . length ( ) ; this . signature = new char [ nameLength ] ; buffer . getChars ( 0 , nameLength , this . signature , 0 ) ; return this . signature ; } public final int sourceEnd ( ) { AbstractMethodDeclaration method = sourceMethod ( ) ; if ( method == null ) { if ( this . declaringClass instanceof SourceTypeBinding ) return ( ( SourceTypeBinding ) this . declaringClass ) . sourceEnd ( ) ; return 0 ; } return method . sourceEnd ; } public AbstractMethodDeclaration sourceMethod ( ) { if ( isSynthetic ( ) ) { return null ; } SourceTypeBinding sourceType ; try { sourceType = ( SourceTypeBinding ) this . declaringClass ; } catch ( ClassCastException e ) { return null ; } AbstractMethodDeclaration [ ] methods = sourceType . scope . referenceContext . methods ; if ( methods != null ) { for ( int i = methods . length ; -- i >= 0 ; ) if ( this == methods [ i ] . binding ) return methods [ i ] ; } return null ; } public final int sourceStart ( ) { AbstractMethodDeclaration method = sourceMethod ( ) ; if ( method == null ) { if ( this . declaringClass instanceof SourceTypeBinding ) return ( ( SourceTypeBinding ) this . declaringClass ) . sourceStart ( ) ; return 0 ; } return method . sourceStart ; } public MethodBinding tiebreakMethod ( ) { return this ; } public String toString ( ) { StringBuffer output = new StringBuffer ( 10 ) ; if ( ( this . modifiers & ExtraCompilerModifiers . AccUnresolved ) != 0 ) { output . append ( "" ) ; } ASTNode . printModifiers ( this . modifiers , output ) ; output . append ( this . returnType != null ? this . returnType . debugName ( ) : "<no type>" ) ; output . append ( " " ) ; output . append ( this . selector != null ? new String ( this . selector ) : "" ) ; output . append ( "(" ) ; if ( this . parameters != null ) { if ( this . parameters != Binding . NO_PARAMETERS ) { for ( int i = 0 , length = this . parameters . length ; i < length ; i ++ ) { if ( i > 0 ) output . append ( ", " ) ; output . append ( this . parameters [ i ] != null ? this . parameters [ i ] . debugName ( ) : "" ) ; } } } else { output . append ( "" ) ; } output . append ( ") " ) ; if ( this . thrownExceptions != null ) { if ( this . thrownExceptions != Binding . NO_EXCEPTIONS ) { output . append ( "throws " ) ; for ( int i = 0 , length = this . thrownExceptions . length ; i < length ; i ++ ) { if ( i > 0 ) output . append ( ", " ) ; output . append ( ( this . thrownExceptions [ i ] != null ) ? this . thrownExceptions [ i ] . debugName ( ) : "" ) ; } } } else { output . append ( "" ) ; } return output . toString ( ) ; } public TypeVariableBinding [ ] typeVariables ( ) { return this . typeVariables ; } } </s>