Example usage for org.eclipse.jdt.internal.compiler.lookup MethodBinding sourceMethod

List of usage examples for org.eclipse.jdt.internal.compiler.lookup MethodBinding sourceMethod

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup MethodBinding sourceMethod.

Prototype

public AbstractMethodDeclaration sourceMethod() 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java

License:Open Source License

private static JsonElement toJsonMethod(MethodBinding method) {
    JsonObject object = new JsonObject();
    object.addProperty("modifiers", method.getAccessFlags());
    object.addProperty("constructor", method.isConstructor());
    object.add("argumentNames", toJsonParametersName(method.sourceMethod()));
    object.add("annotations", toJsonAnnotations(method.getAnnotations()));
    object.add("defaultValue", toJsonDefaultValue(method.getDefaultValue()));
    object.add("exceptionTypeNames", toJsonExceptionTypeNames(method.thrownExceptions));
    object.add("genericSignature", method.genericSignature() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(method.genericSignature())));
    object.add("methodDescriptor",
            method.signature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.signature())));
    object.add("parameterAnnotations", toJsonParameterAnnotations(method));
    object.add("selector",
            method.selector == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.selector)));
    object.addProperty("tagBits", String.valueOf(method.getAnnotationTagBits()));
    object.addProperty("clinit", false);
    return object;
}

From source file:com.google.gwt.dev.javac.JdtUtil.java

License:Apache License

/**
 * Work around JDT bug.//from  ww w  .  jav a  2 s  .  c o m
 */
public static AbstractMethodDeclaration safeSourceMethod(MethodBinding mb) {
    try {
        return mb.sourceMethod();
    } catch (Exception e) {
        return null;
    }
}

From source file:io.gige.compiler.internal.HackElements.java

License:Apache License

@Override
public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults(
        AnnotationMirror a) {/*from w w w.ja  v  a  2 s.  c  o m*/
    Map<? extends ExecutableElement, ? extends AnnotationValue> map = super.getElementValuesWithDefaults(a);
    if (a instanceof AnnotationMirrorImpl) {
        AnnotationMirrorImpl impl = (AnnotationMirrorImpl) a;
        ReferenceBinding annoType = impl._binding.getAnnotationType();
        for (MethodBinding method : annoType.methods()) {
            MethodBinding originalMethod = method.original();
            AbstractMethodDeclaration methodDeclaration = originalMethod.sourceMethod();
            if (methodDeclaration instanceof AnnotationMethodDeclaration) {
                AnnotationMethodDeclaration amd = (AnnotationMethodDeclaration) methodDeclaration;
                Expression exp = amd.defaultValue;
                if (exp instanceof QualifiedNameReference) {
                    QualifiedNameReference qae = (QualifiedNameReference) exp;
                    qae.bits |= ASTNode.RestrictiveFlagMASK;
                }
            }
        }
    }
    return map;
}

From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyClassScope.java

License:Open Source License

private void createGetterMethod(String propertyName, String name, boolean isStatic,
        List<MethodBinding> groovyMethods, MethodBinding[] existingMethods,
        GroovyTypeDeclaration typeDeclaration) {
    boolean found = false;

    char[] nameAsCharArray = name.toCharArray();
    for (MethodBinding existingMethod : existingMethods) {
        if (CharOperation.equals(nameAsCharArray, existingMethod.selector)) {
            // check if this possible candidate has parameters (if it does, it can't be our getter)
            if ((existingMethod.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) {
                // need some intelligence here
                AbstractMethodDeclaration methodDecl = existingMethod.sourceMethod();
                if (methodDecl == null) {
                    // FIXASC decide what we can do here
                } else {
                    Argument[] arguments = methodDecl.arguments;
                    if (arguments == null || arguments.length == 0) {
                        found = true;/*from   ww w .ja  v a 2 s .c om*/
                    }
                }
            } else {
                TypeBinding[] existingParams = existingMethod.parameters;
                if (existingParams == null || existingParams.length == 0) {
                    found = true;
                }
            }
        }
    }

    // FIXASC what about inherited methods - what if the supertype
    // provides an implementation, does the subtype get a new method?
    if (!found) {
        int modifiers = ClassFileConstants.AccPublic;
        if (isStatic) {
            modifiers |= ClassFileConstants.AccStatic;
        }
        if (this.referenceContext.binding.isInterface()) {
            modifiers |= ClassFileConstants.AccAbstract;
        }
        /*
         * if (typeDeclaration != null) { // check we are not attempting to override a final method MethodBinding[]
         * existingBindings = typeDeclaration.binding.getMethods(name.toCharArray()); int stop = 1; }
         */
        MethodBinding mb = new LazilyResolvedMethodBinding(true, propertyName, modifiers, nameAsCharArray, null,
                this.referenceContext.binding);
        // FIXASC parameter names - what value would it have to set them correctly?
        groovyMethods.add(mb);
    }
}

From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyClassScope.java

License:Open Source License

private void createSetterMethod(String propertyName, String name, boolean isStatic,
        List<MethodBinding> groovyMethods, MethodBinding[] existingMethods,
        GroovyTypeDeclaration typeDeclaration, String propertyType) {
    boolean found = false;

    char[] nameAsCharArray = name.toCharArray();
    for (MethodBinding existingMethod : existingMethods) {
        if (CharOperation.equals(nameAsCharArray, existingMethod.selector)) {
            // check if this possible candidate has parameters (if it does, it can't be our getter)
            if ((existingMethod.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) {
                // lets look at the declaration
                AbstractMethodDeclaration methodDecl = existingMethod.sourceMethod();
                if (methodDecl == null) {
                    // FIXASC decide what we can do here
                } else {
                    Argument[] arguments = methodDecl.arguments;
                    if (arguments != null && arguments.length == 1) {
                        // might be a candidate, it takes one parameter
                        // TypeReference tr = arguments[0].type;
                        // String typename = new String(CharOperation.concatWith(tr.getTypeName(), '.'));
                        // // not really an exact comparison here...
                        // if (typename.endsWith(propertyName)) {
                        found = true;/* w w  w .j a v  a 2s . com*/
                        // }
                    }
                }
            } else {
                TypeBinding[] existingParams = existingMethod.parameters;
                if (existingParams != null && existingParams.length == 1) {
                    // if (CharOperation.equals(existingParams[0].signature(),)) {
                    // might be a candidate, it takes one parameter
                    found = true;
                    // }
                }
            }
        }
    }

    // FIXASC what about inherited methods - what if the supertype
    // provides an implementation, does the subtype get a new method?
    if (!found) {
        int modifiers = ClassFileConstants.AccPublic;
        if (isStatic) {
            modifiers |= ClassFileConstants.AccStatic;
        }
        if (this.referenceContext.binding.isInterface()) {
            modifiers |= ClassFileConstants.AccAbstract;
        }
        char[] methodName = name.toCharArray();
        /*
         * if (typeDeclaration != null) { // check we are not attempting to override a final method MethodBinding[]
         * existingBindings = typeDeclaration.binding.getMethods(name.toCharArray()); int stop = 1; }
         */
        MethodBinding mb = new LazilyResolvedMethodBinding(false, propertyName, modifiers, methodName, null,
                this.referenceContext.binding);
        // FIXASC parameter names - what value would it have to set them correctly?
        groovyMethods.add(mb);
    }
}

From source file:org.eclipse.jdt.internal.compiler.lookup.MethodVerifier15.java

License:Open Source License

void reportRawReferences() {
    CompilerOptions compilerOptions = this.type.scope.compilerOptions();
    if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
            || compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined 
        return;//from w w  w . j  a  v  a2 s . co m
    }
    /* Code below is only for a method that does not override/implement a super type method. If it were to,
       it would have been handled in checkAgainstInheritedMethods.
    */
    Object[] methodArray = this.currentMethods.valueTable;
    for (int s = methodArray.length; --s >= 0;) {
        if (methodArray[s] == null)
            continue;
        MethodBinding[] current = (MethodBinding[]) methodArray[s];
        for (int i = 0, length = current.length; i < length; i++) {
            MethodBinding currentMethod = current[i];
            if ((currentMethod.modifiers
                    & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) == 0) {
                AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
                if (methodDecl == null)
                    return;
                TypeBinding[] parameterTypes = currentMethod.parameters;
                Argument[] arguments = methodDecl.arguments;
                for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
                    TypeBinding parameterType = parameterTypes[j];
                    Argument arg = arguments[j];
                    if (parameterType.leafComponentType().isRawType()
                            && compilerOptions
                                    .getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
                            && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
                        methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
                    }
                }
                if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration) {
                    TypeReference returnType = ((MethodDeclaration) methodDecl).returnType;
                    TypeBinding methodType = currentMethod.returnType;
                    if (returnType != null) {
                        if (methodType.leafComponentType().isRawType()
                                && compilerOptions.getSeverity(
                                        CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
                                && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
                            methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
                        }
                    }
                }
            }
        }
    }
}

From source file:org.eclipse.jdt.internal.compiler.lookup.MethodVerifier15.java

License:Open Source License

public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) {
    CompilerOptions compilerOptions = this.type.scope.compilerOptions();
    if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
            || compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined 
        return;/*from   ww w .jav a  2  s .c  o  m*/
    }
    AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
    if (methodDecl == null)
        return;
    TypeBinding[] parameterTypes = currentMethod.parameters;
    TypeBinding[] inheritedParameterTypes = inheritedMethod.parameters;
    Argument[] arguments = methodDecl.arguments;
    for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
        TypeBinding parameterType = parameterTypes[j];
        TypeBinding inheritedParameterType = inheritedParameterTypes[j];
        Argument arg = arguments[j];
        if (parameterType.leafComponentType().isRawType()) {
            if (inheritedParameterType.leafComponentType().isRawType()) {
                arg.binding.tagBits |= TagBits.ForcedToBeRawType;
            } else {
                if (compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
                        && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
                    methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
                }
            }
        }
    }
    TypeReference returnType = null;
    if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration
            && (returnType = ((MethodDeclaration) methodDecl).returnType) != null) {
        final TypeBinding inheritedMethodType = inheritedMethod.returnType;
        final TypeBinding methodType = currentMethod.returnType;
        if (methodType.leafComponentType().isRawType()) {
            if (inheritedMethodType.leafComponentType().isRawType()) {
                // 
            } else {
                if ((returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0 && compilerOptions
                        .getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
                    methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
                }
            }
        }
    }
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticMethod(MethodBinding targetMethod, boolean isSuperAccess) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(targetMethod);/*  www.j  a  v a 2s . co  m*/
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(targetMethod, isSuperAccess, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(targetMethod,
                accessors = new SyntheticMethodBinding[2]);
        accessors[isSuperAccess ? 0 : 1] = accessMethod;
    } else {
        if ((accessMethod = accessors[isSuperAccess ? 0 : 1]) == null) {
            accessMethod = new SyntheticMethodBinding(targetMethod, isSuperAccess, this);
            accessors[isSuperAccess ? 0 : 1] = accessMethod;
        }
    }
    if (targetMethod.declaringClass.isStatic()) {
        if ((targetMethod.isConstructor() && targetMethod.parameters.length >= 0xFE)
                || targetMethod.parameters.length >= 0xFF) {
            this.scope.problemReporter().tooManyParametersForSyntheticMethod(targetMethod.sourceMethod());
        }
    } else if ((targetMethod.isConstructor() && targetMethod.parameters.length >= 0xFD)
            || targetMethod.parameters.length >= 0xFE) {
        this.scope.problemReporter().tooManyParametersForSyntheticMethod(targetMethod.sourceMethod());
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public MethodBinding[] methods() {
    if ((this.tagBits & TagBits.AreMethodsComplete) != 0)
        return this.methods;

    // lazily sort methods
    if ((this.tagBits & TagBits.AreMethodsSorted) == 0) {
        int length = this.methods.length;
        if (length > 1)
            ReferenceBinding.sortMethods(this.methods, 0, length);
        this.tagBits |= TagBits.AreMethodsSorted;
    }// w w  w. ja  v  a 2s  . c o m

    int failed = 0;
    MethodBinding[] resolvedMethods = this.methods;
    try {
        for (int i = 0, length = this.methods.length; i < length; i++) {
            if (resolveTypesFor(this.methods[i]) == null) {
                // do not alter original method array until resolution is over, due to reentrance (143259)
                if (resolvedMethods == this.methods) {
                    System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length);
                }
                resolvedMethods[i] = null; // unable to resolve parameters
                failed++;
            }
        }

        // find & report collision cases
        boolean complyTo15OrAbove = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
        boolean compliance16 = this.scope.compilerOptions().complianceLevel == ClassFileConstants.JDK1_6;

        for (int i = 0, length = this.methods.length; i < length; i++) {
            int severity = ProblemSeverities.Error;
            MethodBinding method = resolvedMethods[i];
            if (method == null)
                continue;
            char[] selector = method.selector;
            AbstractMethodDeclaration methodDecl = null;
            nextSibling: for (int j = i + 1; j < length; j++) {
                MethodBinding method2 = resolvedMethods[j];
                if (method2 == null)
                    continue nextSibling;
                if (!CharOperation.equals(selector, method2.selector))
                    break nextSibling; // methods with same selector are contiguous

                if (complyTo15OrAbove) {
                    if (method.areParameterErasuresEqual(method2)) {
                        // we now ignore return types in 1.7 when detecting duplicates, just as we did before 1.5 
                        // Only in 1.6, we have to make sure even return types are different
                        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719
                        if (compliance16 && method.returnType != null && method2.returnType != null) {
                            if (method.returnType.erasure() != method2.returnType.erasure()) {
                                // check to see if the erasure of either method is equal to the other
                                // if not, then change severity to WARNING
                                TypeBinding[] params1 = method.parameters;
                                TypeBinding[] params2 = method2.parameters;
                                int pLength = params1.length;
                                TypeVariableBinding[] vars = method.typeVariables;
                                TypeVariableBinding[] vars2 = method2.typeVariables;
                                boolean equalTypeVars = vars == vars2;
                                MethodBinding subMethod = method2;
                                if (!equalTypeVars) {
                                    MethodBinding temp = method.computeSubstitutedMethod(method2,
                                            this.scope.environment());
                                    if (temp != null) {
                                        equalTypeVars = true;
                                        subMethod = temp;
                                    }
                                }
                                boolean equalParams = method.areParametersEqual(subMethod);
                                if (equalParams && equalTypeVars) {
                                    // duplicates regardless of return types
                                } else if (vars != Binding.NO_TYPE_VARIABLES
                                        && vars2 != Binding.NO_TYPE_VARIABLES) {
                                    // both have type arguments. Erasure of signature of one cannot be equal to signature of other
                                    severity = ProblemSeverities.Warning;
                                } else if (pLength > 0) {
                                    int index = pLength;
                                    // is erasure of signature of m2 same as signature of m1?
                                    for (; --index >= 0;) {
                                        if (params1[index] != params2[index].erasure())
                                            break;
                                        if (params1[index] == params2[index]) {
                                            TypeBinding type = params1[index].leafComponentType();
                                            if (type instanceof SourceTypeBinding
                                                    && type.typeVariables() != Binding.NO_TYPE_VARIABLES) {
                                                index = pLength; // handle comparing identical source types like X<T>... its erasure is itself BUT we need to answer false
                                                break;
                                            }
                                        }
                                    }
                                    if (index >= 0 && index < pLength) {
                                        // is erasure of signature of m1 same as signature of m2?
                                        for (index = pLength; --index >= 0;)
                                            if (params1[index].erasure() != params2[index])
                                                break;

                                    }
                                    if (index >= 0) {
                                        // erasure of neither is equal to signature of other
                                        severity = ProblemSeverities.Warning;
                                    }
                                } else if (pLength != 0) {
                                    severity = ProblemSeverities.Warning;
                                } // pLength = 0 automatically makes erasure of arguments one equal to arguments of other.
                            }
                            // else return types also equal. All conditions satisfied
                            // to give error in 1.6 compliance as well.
                        }
                    } else {
                        continue nextSibling;
                    }
                } else if (!method.areParametersEqual(method2)) {
                    // prior to 1.5, parameters identical meant a collision case
                    continue nextSibling;
                }
                // otherwise duplicates / name clash
                boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector, TypeConstants.VALUEOF)
                        || CharOperation.equals(selector, TypeConstants.VALUES));
                // report duplicate
                boolean removeMethod2 = (severity == ProblemSeverities.Error) ? true : false; // do not remove if in 1.6 and just a warning given
                if (methodDecl == null) {
                    methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special
                    if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method
                        boolean removeMethod = method.returnType == null && method2.returnType != null;
                        if (isEnumSpecialMethod) {
                            this.scope.problemReporter().duplicateEnumSpecialMethod(this, methodDecl);
                            // remove user defined methods & keep the synthetic
                            removeMethod = true;
                        } else {
                            this.scope.problemReporter().duplicateMethodInType(this, methodDecl,
                                    method.areParametersEqual(method2), severity);
                        }
                        if (removeMethod) {
                            removeMethod2 = false;
                            methodDecl.binding = null;
                            // do not alter original method array until resolution is over, due to reentrance (143259)
                            if (resolvedMethods == this.methods)
                                System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length],
                                        0, length);
                            resolvedMethods[i] = null;
                            failed++;
                        }
                    }
                }
                AbstractMethodDeclaration method2Decl = method2.sourceMethod();
                if (method2Decl != null && method2Decl.binding != null) { // ensure its a valid user defined method
                    if (isEnumSpecialMethod) {
                        this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl);
                        removeMethod2 = true;
                    } else {
                        this.scope.problemReporter().duplicateMethodInType(this, method2Decl,
                                method.areParametersEqual(method2), severity);
                    }
                    if (removeMethod2) {
                        method2Decl.binding = null;
                        // do not alter original method array until resolution is over, due to reentrance (143259)
                        if (resolvedMethods == this.methods)
                            System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0,
                                    length);
                        resolvedMethods[j] = null;
                        failed++;
                    }
                }
            }
            if (method.returnType == null && resolvedMethods[i] != null) { // forget method with invalid return type... was kept to detect possible collisions
                methodDecl = method.sourceMethod();
                if (methodDecl != null)
                    methodDecl.binding = null;
                // do not alter original method array until resolution is over, due to reentrance (143259)
                if (resolvedMethods == this.methods)
                    System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length);
                resolvedMethods[i] = null;
                failed++;
            }
        }
    } finally {
        if (failed > 0) {
            int newSize = resolvedMethods.length - failed;
            if (newSize == 0) {
                this.methods = Binding.NO_METHODS;
            } else {
                MethodBinding[] newMethods = new MethodBinding[newSize];
                for (int i = 0, j = 0, length = resolvedMethods.length; i < length; i++)
                    if (resolvedMethods[i] != null)
                        newMethods[j++] = resolvedMethods[i];
                this.methods = newMethods;
            }
        }

        // handle forward references to potential default abstract methods
        addDefaultAbstractMethods();
        this.tagBits |= TagBits.AreMethodsComplete;
    }
    return this.methods;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public MethodBinding resolveTypesFor(MethodBinding method) {
    if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0)
        return method;

    if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
        if ((method.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0)
            method.modifiers |= ClassFileConstants.AccDeprecated;
    }//from  w  w w  .j  a  va  2s .co  m
    if (isViewedAsDeprecated() && !method.isDeprecated())
        method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
    if (hasRestrictedAccess())
        method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;

    AbstractMethodDeclaration methodDecl = method.sourceMethod();
    // GROOVY
    /* old {
    if (methodDecl == null) return null; // method could not be resolved in previous iteration
     } new*/
    if (methodDecl == null) {
        if (method instanceof LazilyResolvedMethodBinding) {
            LazilyResolvedMethodBinding lrMethod = (LazilyResolvedMethodBinding) method;
            // the rest is a copy of the code below but doesn't depend on the method declaration
            // nothing to do for method type parameters (there are none)
            // nothing to do for method exceptions (there are none)
            TypeBinding ptb = lrMethod.getParameterTypeBinding();
            if (ptb == null) {
                method.parameters = Binding.NO_PARAMETERS;
            } else {
                method.parameters = new TypeBinding[] { ptb };
            }
            method.returnType = lrMethod.getReturnTypeBinding();
            method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
            return method;
        }
        // returning null is what this clause would have done anyway
        return null;
    }
    // FIXASC - end

    TypeParameter[] typeParameters = methodDecl.typeParameters();
    if (typeParameters != null) {
        methodDecl.scope.connectTypeVariables(typeParameters, true);
        // Perform deferred bound checks for type variables (only done after type variable hierarchy is connected)
        for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++)
            typeParameters[i].checkBounds(methodDecl.scope);
    }
    TypeReference[] exceptionTypes = methodDecl.thrownExceptions;
    if (exceptionTypes != null) {
        int size = exceptionTypes.length;
        method.thrownExceptions = new ReferenceBinding[size];
        int count = 0;
        ReferenceBinding resolvedExceptionType;
        for (int i = 0; i < size; i++) {
            resolvedExceptionType = (ReferenceBinding) exceptionTypes[i].resolveType(methodDecl.scope,
                    true /* check bounds*/);
            if (resolvedExceptionType == null)
                continue;
            if (resolvedExceptionType.isBoundParameterizedType()) {
                methodDecl.scope.problemReporter().invalidParameterizedExceptionType(resolvedExceptionType,
                        exceptionTypes[i]);
                continue;
            }
            if (resolvedExceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) {
                if (resolvedExceptionType.isValidBinding()) {
                    methodDecl.scope.problemReporter().cannotThrowType(exceptionTypes[i],
                            resolvedExceptionType);
                    continue;
                }
            }
            if ((resolvedExceptionType.tagBits & TagBits.HasMissingType) != 0) {
                method.tagBits |= TagBits.HasMissingType;
            }
            method.modifiers |= (resolvedExceptionType.modifiers & ExtraCompilerModifiers.AccGenericSignature);
            method.thrownExceptions[count++] = resolvedExceptionType;
        }
        if (count < size)
            System.arraycopy(method.thrownExceptions, 0, method.thrownExceptions = new ReferenceBinding[count],
                    0, count);
    }
    final boolean reportUnavoidableGenericTypeProblems = this.scope
            .compilerOptions().reportUnavoidableGenericTypeProblems;
    boolean foundArgProblem = false;
    Argument[] arguments = methodDecl.arguments;
    if (arguments != null) {
        int size = arguments.length;
        method.parameters = Binding.NO_PARAMETERS;
        TypeBinding[] newParameters = new TypeBinding[size];
        for (int i = 0; i < size; i++) {
            Argument arg = arguments[i];
            if (arg.annotations != null) {
                method.tagBits |= TagBits.HasParameterAnnotations;
            }
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
            boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && !method.isConstructor()
                    && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0;
            TypeBinding parameterType;
            if (deferRawTypeCheck) {
                arg.type.bits |= ASTNode.IgnoreRawTypeCheck;
            }
            try {
                parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/);
            } finally {
                if (deferRawTypeCheck) {
                    arg.type.bits &= ~ASTNode.IgnoreRawTypeCheck;
                }
            }

            if (parameterType == null) {
                foundArgProblem = true;
            } else if (parameterType == TypeBinding.VOID) {
                methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg);
                foundArgProblem = true;
            } else {
                if ((parameterType.tagBits & TagBits.HasMissingType) != 0) {
                    method.tagBits |= TagBits.HasMissingType;
                }
                TypeBinding leafType = parameterType.leafComponentType();
                if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers
                        & ExtraCompilerModifiers.AccGenericSignature) != 0)
                    method.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
                newParameters[i] = parameterType;
                arg.binding = new LocalVariableBinding(arg, parameterType, arg.modifiers, true);
            }
        }
        // only assign parameters if no problems are found
        if (!foundArgProblem) {
            method.parameters = newParameters;
        }
    }

    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=337799
    if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) {
        if ((method.tagBits & TagBits.AnnotationSafeVarargs) != 0) {
            if (!method.isVarargs()) {
                methodDecl.scope.problemReporter().safeVarargsOnFixedArityMethod(method);
            } else if (!method.isStatic() && !method.isFinal() && !method.isConstructor()) {
                methodDecl.scope.problemReporter().safeVarargsOnNonFinalInstanceMethod(method);
            }
        } else if (method.parameters != null && method.parameters.length > 0 && method.isVarargs()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=337795
            if (!method.parameters[method.parameters.length - 1].isReifiable()) {
                methodDecl.scope.problemReporter()
                        .possibleHeapPollutionFromVararg(methodDecl.arguments[methodDecl.arguments.length - 1]);
            }
        }
    }

    boolean foundReturnTypeProblem = false;
    if (!method.isConstructor()) {
        TypeReference returnType = methodDecl instanceof MethodDeclaration
                ? ((MethodDeclaration) methodDecl).returnType
                : null;
        if (returnType == null) {
            methodDecl.scope.problemReporter().missingReturnType(methodDecl);
            method.returnType = null;
            foundReturnTypeProblem = true;
        } else {
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
            boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems
                    && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0;
            TypeBinding methodType;
            if (deferRawTypeCheck) {
                returnType.bits |= ASTNode.IgnoreRawTypeCheck;
            }
            try {
                methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/);
            } finally {
                if (deferRawTypeCheck) {
                    returnType.bits &= ~ASTNode.IgnoreRawTypeCheck;
                }
            }
            if (methodType == null) {
                foundReturnTypeProblem = true;
            } else if (methodType.isArrayType()
                    && ((ArrayBinding) methodType).leafComponentType == TypeBinding.VOID) {
                methodDecl.scope.problemReporter().returnTypeCannotBeVoidArray((MethodDeclaration) methodDecl);
                foundReturnTypeProblem = true;
            } else {
                if ((methodType.tagBits & TagBits.HasMissingType) != 0) {
                    method.tagBits |= TagBits.HasMissingType;
                }
                method.returnType = methodType;
                TypeBinding leafType = methodType.leafComponentType();
                if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers
                        & ExtraCompilerModifiers.AccGenericSignature) != 0)
                    method.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
            }
        }
    }
    if (foundArgProblem) {
        methodDecl.binding = null;
        method.parameters = Binding.NO_PARAMETERS; // see 107004
        // nullify type parameter bindings as well as they have a backpointer to the method binding
        // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81134)
        if (typeParameters != null)
            for (int i = 0, length = typeParameters.length; i < length; i++)
                typeParameters[i].binding = null;
        return null;
    }
    if (foundReturnTypeProblem)
        return method; // but its still unresolved with a null return type & is still connected to its method declaration

    method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
    return method;
}