Example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccVarargs

List of usage examples for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccVarargs

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccVarargs.

Prototype

int AccVarargs

To view the source code for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccVarargs.

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.compiler.parser.SourceTypeConverter.java

License:Open Source License

private AbstractMethodDeclaration convert(SourceMethod methodHandle, SourceMethodElementInfo methodInfo,
        CompilationResult compilationResult) throws JavaModelException {
    AbstractMethodDeclaration method;/*from   ww w  .j a v a 2 s . c o m*/

    /* only source positions available */
    int start = methodInfo.getNameSourceStart();
    int end = methodInfo.getNameSourceEnd();

    /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=324850, Even when this type is being constructed
       on behalf of a 1.4 project we must internalize type variables properly in order to be able to
       recognize usages of them in the method signature, to apply substitutions and thus to be able to
       detect overriding in the presence of generics. If we simply drop them, when the method signature
       refers to the type parameter, we won't know it should be bound to the type parameter and perform
       incorrect lookup and may mistakenly end up with missing types
     */
    TypeParameter[] typeParams = null;
    char[][] typeParameterNames = methodInfo.getTypeParameterNames();
    if (typeParameterNames != null) {
        int parameterCount = typeParameterNames.length;
        if (parameterCount > 0) { // method's type parameters must be null if no type parameter
            char[][][] typeParameterBounds = methodInfo.getTypeParameterBounds();
            typeParams = new TypeParameter[parameterCount];
            for (int i = 0; i < parameterCount; i++) {
                typeParams[i] = createTypeParameter(typeParameterNames[i], typeParameterBounds[i], start, end);
            }
        }
    }

    int modifiers = methodInfo.getModifiers();
    if (methodInfo.isConstructor()) {
        ConstructorDeclaration decl = new ConstructorDeclaration(compilationResult);
        decl.bits &= ~ASTNode.IsDefaultConstructor;
        method = decl;
        decl.typeParameters = typeParams;
    } else {
        MethodDeclaration decl;
        if (methodInfo.isAnnotationMethod()) {
            AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration(
                    compilationResult);

            /* conversion of default value */
            SourceAnnotationMethodInfo annotationMethodInfo = (SourceAnnotationMethodInfo) methodInfo;
            boolean hasDefaultValue = annotationMethodInfo.defaultValueStart != -1
                    || annotationMethodInfo.defaultValueEnd != -1;
            if ((this.flags & FIELD_INITIALIZATION) != 0) {
                if (hasDefaultValue) {
                    char[] defaultValueSource = CharOperation.subarray(getSource(),
                            annotationMethodInfo.defaultValueStart, annotationMethodInfo.defaultValueEnd + 1);
                    if (defaultValueSource != null) {
                        Expression expression = parseMemberValue(defaultValueSource);
                        if (expression != null) {
                            annotationMethodDeclaration.defaultValue = expression;
                        }
                    } else {
                        // could not retrieve the default value
                        hasDefaultValue = false;
                    }
                }
            }
            if (hasDefaultValue)
                modifiers |= ClassFileConstants.AccAnnotationDefault;
            decl = annotationMethodDeclaration;
        } else {
            decl = new MethodDeclaration(compilationResult);
        }

        // convert return type
        decl.returnType = createTypeReference(methodInfo.getReturnTypeName(), start, end);

        // type parameters
        decl.typeParameters = typeParams;

        method = decl;
    }
    method.selector = methodHandle.getElementName().toCharArray();
    boolean isVarargs = (modifiers & ClassFileConstants.AccVarargs) != 0;
    method.modifiers = modifiers & ~ClassFileConstants.AccVarargs;
    method.sourceStart = start;
    method.sourceEnd = end;
    method.declarationSourceStart = methodInfo.getDeclarationSourceStart();
    method.declarationSourceEnd = methodInfo.getDeclarationSourceEnd();

    // convert 1.5 specific constructs only if compliance is 1.5 or above
    if (this.has1_5Compliance) {
        /* convert annotations */
        method.annotations = convertAnnotations(methodHandle);
    }

    /* convert arguments */
    String[] argumentTypeSignatures = methodHandle.getParameterTypes();
    char[][] argumentNames = methodInfo.getArgumentNames();
    int argumentCount = argumentTypeSignatures == null ? 0 : argumentTypeSignatures.length;
    if (argumentCount > 0) {
        ILocalVariable[] parameters = methodHandle.getParameters();
        long position = ((long) start << 32) + end;
        method.arguments = new Argument[argumentCount];
        for (int i = 0; i < argumentCount; i++) {
            TypeReference typeReference = createTypeReference(argumentTypeSignatures[i], start, end);
            if (isVarargs && i == argumentCount - 1) {
                typeReference.bits |= ASTNode.IsVarArgs;
            }
            method.arguments[i] = new Argument(argumentNames[i], position, typeReference,
                    ClassFileConstants.AccDefault);
            // do not care whether was final or not
            // convert 1.5 specific constructs only if compliance is 1.5 or above
            if (this.has1_5Compliance) {
                /* convert annotations */
                method.arguments[i].annotations = convertAnnotations(parameters[i]);
            }
        }
    }

    /* convert thrown exceptions */
    char[][] exceptionTypeNames = methodInfo.getExceptionTypeNames();
    int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length;
    if (exceptionCount > 0) {
        method.thrownExceptions = new TypeReference[exceptionCount];
        for (int i = 0; i < exceptionCount; i++) {
            method.thrownExceptions[i] = createTypeReference(exceptionTypeNames[i], start, end);
        }
    }

    /* convert local and anonymous types */
    if ((this.flags & LOCAL_TYPE) != 0) {
        IJavaElement[] children = methodInfo.getChildren();
        int typesLength = children.length;
        if (typesLength != 0) {
            Statement[] statements = new Statement[typesLength];
            for (int i = 0; i < typesLength; i++) {
                SourceType type = (SourceType) children[i];
                TypeDeclaration localType = convert(type, compilationResult);
                if ((localType.bits & ASTNode.IsAnonymousType) != 0) {
                    QualifiedAllocationExpression expression = new QualifiedAllocationExpression(localType);
                    expression.type = localType.superclass;
                    localType.superclass = null;
                    localType.superInterfaces = null;
                    localType.allocation = expression;
                    statements[i] = expression;
                } else {
                    statements[i] = localType;
                }
            }
            method.statements = statements;
        }
    }

    return method;
}

From source file:lombok.eclipse.agent.PatchDelegate.java

License:Open Source License

private static MethodDeclaration createDelegateMethod(char[] name, EclipseNode typeNode, BindingTuple pair,
        CompilationResult compilationResult, EclipseNode annNode, DelegateReceiver delegateReceiver) {
    /* public <T, U, ...> ReturnType methodName(ParamType1 name1, ParamType2 name2, ...) throws T1, T2, ... {
     *      (return) delegate.<T, U>methodName(name1, name2);
     *  }/*w w w .  j a va 2s .c o m*/
     */

    boolean isVarargs = (pair.base.modifiers & ClassFileConstants.AccVarargs) != 0;

    try {
        checkConflictOfTypeVarNames(pair, typeNode);
    } catch (CantMakeDelegates e) {
        annNode.addError(
                "There's a conflict in the names of type parameters. Fix it by renaming the following type parameters of your class: "
                        + e.conflicted);
        return null;
    }

    ASTNode source = annNode.get();

    int pS = source.sourceStart, pE = source.sourceEnd;

    MethodBinding binding = pair.parameterized;
    MethodDeclaration method = new MethodDeclaration(compilationResult);
    setGeneratedBy(method, source);
    method.sourceStart = pS;
    method.sourceEnd = pE;
    method.modifiers = ClassFileConstants.AccPublic;

    method.returnType = makeType(binding.returnType, source, false);
    boolean isDeprecated = binding.isDeprecated();

    method.selector = binding.selector;

    if (binding.thrownExceptions != null && binding.thrownExceptions.length > 0) {
        method.thrownExceptions = new TypeReference[binding.thrownExceptions.length];
        for (int i = 0; i < method.thrownExceptions.length; i++) {
            method.thrownExceptions[i] = makeType(binding.thrownExceptions[i], source, false);
        }
    }

    MessageSend call = new MessageSend();
    call.sourceStart = pS;
    call.sourceEnd = pE;
    call.nameSourcePosition = pos(source);
    setGeneratedBy(call, source);
    call.receiver = delegateReceiver.get(source, name);
    call.selector = binding.selector;

    if (binding.typeVariables != null && binding.typeVariables.length > 0) {
        method.typeParameters = new TypeParameter[binding.typeVariables.length];
        call.typeArguments = new TypeReference[binding.typeVariables.length];
        for (int i = 0; i < method.typeParameters.length; i++) {
            method.typeParameters[i] = new TypeParameter();
            method.typeParameters[i].sourceStart = pS;
            method.typeParameters[i].sourceEnd = pE;
            setGeneratedBy(method.typeParameters[i], source);
            method.typeParameters[i].name = binding.typeVariables[i].sourceName;
            call.typeArguments[i] = new SingleTypeReference(binding.typeVariables[i].sourceName, pos(source));
            setGeneratedBy(call.typeArguments[i], source);
            ReferenceBinding super1 = binding.typeVariables[i].superclass;
            ReferenceBinding[] super2 = binding.typeVariables[i].superInterfaces;
            if (super2 == null)
                super2 = new ReferenceBinding[0];
            if (super1 != null || super2.length > 0) {
                int offset = super1 == null ? 0 : 1;
                method.typeParameters[i].bounds = new TypeReference[super2.length + offset - 1];
                if (super1 != null)
                    method.typeParameters[i].type = makeType(super1, source, false);
                else
                    method.typeParameters[i].type = makeType(super2[0], source, false);
                int ctr = 0;
                for (int j = (super1 == null) ? 1 : 0; j < super2.length; j++) {
                    method.typeParameters[i].bounds[ctr] = makeType(super2[j], source, false);
                    method.typeParameters[i].bounds[ctr++].bits |= ASTNode.IsSuperType;
                }
            }
        }
    }

    if (isDeprecated) {
        method.annotations = new Annotation[] { generateDeprecatedAnnotation(source) };
    }

    method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;

    if (binding.parameters != null && binding.parameters.length > 0) {
        method.arguments = new Argument[binding.parameters.length];
        call.arguments = new Expression[method.arguments.length];
        for (int i = 0; i < method.arguments.length; i++) {
            AbstractMethodDeclaration sourceElem;
            try {
                sourceElem = pair.base.sourceMethod();
            } catch (Exception e) {
                sourceElem = null;
            }
            char[] argName;
            if (sourceElem == null)
                argName = ("arg" + i).toCharArray();
            else {
                argName = sourceElem.arguments[i].name;
            }
            method.arguments[i] = new Argument(argName, pos(source),
                    makeType(binding.parameters[i], source, false), ClassFileConstants.AccFinal);
            setGeneratedBy(method.arguments[i], source);
            call.arguments[i] = new SingleNameReference(argName, pos(source));
            setGeneratedBy(call.arguments[i], source);
        }
        if (isVarargs) {
            method.arguments[method.arguments.length - 1].type.bits |= ASTNode.IsVarArgs;
        }
    }

    Statement body;
    if (method.returnType instanceof SingleTypeReference
            && ((SingleTypeReference) method.returnType).token == TypeConstants.VOID) {
        body = call;
    } else {
        body = new ReturnStatement(call, source.sourceStart, source.sourceEnd);
        setGeneratedBy(body, source);
    }

    method.statements = new Statement[] { body };
    return method;
}

From source file:org.eclipse.ajdt.core.parserbridge.AJSourceElementNotifier.java

License:Open Source License

protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {

    // range check
    boolean isInRange = initialPosition <= methodDeclaration.declarationSourceStart
            && eofPosition >= methodDeclaration.declarationSourceEnd;

    if (methodDeclaration.isClinit()) {
        this.visitIfNeeded(methodDeclaration);
        return;/*from   ww  w  .  j  a  v  a 2 s. c  om*/
    }

    if (methodDeclaration.isDefaultConstructor()) {
        if (reportReferenceInfo) {
            ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
            ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
            if (constructorCall != null) {
                switch (constructorCall.accessMode) {
                case ExplicitConstructorCall.This:
                    requestor.acceptConstructorReference(typeNames[nestedTypeIndex - 1],
                            constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
                            constructorCall.sourceStart);
                    break;
                case ExplicitConstructorCall.Super:
                case ExplicitConstructorCall.ImplicitSuper:
                    requestor.acceptConstructorReference(superTypeNames[nestedTypeIndex - 1],
                            constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
                            constructorCall.sourceStart);
                    break;
                }
            }
        }
        return;
    }
    char[][] argumentTypes = null;
    char[][] argumentNames = null;
    boolean isVarArgs = false;
    Argument[] arguments = methodDeclaration.arguments;
    if (arguments != null) {
        char[][][] argumentTypesAndNames = this.getArguments(arguments);
        argumentTypes = argumentTypesAndNames[0];
        argumentNames = argumentTypesAndNames[1];

        isVarArgs = arguments[arguments.length - 1].isVarArgs();
    }
    char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration);
    // by default no selector end position
    int selectorSourceEnd = -1;
    if (methodDeclaration.isConstructor()) {
        selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
        if (isInRange) {
            int currentModifiers = methodDeclaration.modifiers;
            if (isVarArgs)
                currentModifiers |= ClassFileConstants.AccVarargs;

            // remember deprecation so as to not lose it below
            boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0
                    || hasDeprecatedAnnotation(methodDeclaration.annotations);

            ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
            methodInfo.isConstructor = true;
            methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
            methodInfo.modifiers = deprecated
                    ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated
                    : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
            methodInfo.name = methodDeclaration.selector;
            methodInfo.nameSourceStart = methodDeclaration.sourceStart;
            methodInfo.nameSourceEnd = selectorSourceEnd;
            methodInfo.parameterTypes = argumentTypes;
            methodInfo.parameterNames = argumentNames;
            methodInfo.exceptionTypes = thrownExceptionTypes;
            methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
            methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
            methodInfo.annotations = methodDeclaration.annotations;
            methodInfo.node = methodDeclaration;
            requestor.enterConstructor(methodInfo);
        }
        if (reportReferenceInfo) {
            ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
            ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
            if (constructorCall != null) {
                switch (constructorCall.accessMode) {
                case ExplicitConstructorCall.This:
                    requestor.acceptConstructorReference(typeNames[nestedTypeIndex - 1],
                            constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
                            constructorCall.sourceStart);
                    break;
                case ExplicitConstructorCall.Super:
                case ExplicitConstructorCall.ImplicitSuper:
                    requestor.acceptConstructorReference(superTypeNames[nestedTypeIndex - 1],
                            constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
                            constructorCall.sourceStart);
                    break;
                }
            }
        }
        this.visitIfNeeded(methodDeclaration);
        if (isInRange) {
            requestor.exitConstructor(methodDeclaration.declarationSourceEnd);
        }
        return;
    }
    selectorSourceEnd = this.sourceEnds.get(methodDeclaration);

    // AspectJ Change Begin
    // recreate source locations for Pointcuts and Advice
    org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration ajmDec = new org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration(
            new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult(
                    methodDeclaration.compilationResult.fileName, methodDeclaration.compilationResult.unitIndex,
                    methodDeclaration.compilationResult.totalUnitsKnown, 500));
    if (ajmDec instanceof PointcutDeclaration) {
        selectorSourceEnd = methodDeclaration.sourceStart + methodDeclaration.selector.length - 1;
    }
    if (ajmDec instanceof AdviceDeclaration) {
        selectorSourceEnd = methodDeclaration.sourceStart + ((AdviceDeclaration) ajmDec).kind.getName().length()
                - 1;
    }
    // AspectJ Change End

    if (isInRange) {
        int currentModifiers = methodDeclaration.modifiers;
        if (isVarArgs)
            currentModifiers |= ClassFileConstants.AccVarargs;

        // remember deprecation so as to not lose it below
        boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0
                || hasDeprecatedAnnotation(methodDeclaration.annotations);

        TypeReference returnType = methodDeclaration instanceof MethodDeclaration
                ? ((MethodDeclaration) methodDeclaration).returnType
                : null;
        ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
        methodInfo.isAnnotation = methodDeclaration instanceof AnnotationMethodDeclaration;
        methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
        methodInfo.modifiers = deprecated
                ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated
                : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
        methodInfo.returnType = returnType == null ? null
                : CharOperation.concatWith(returnType.getParameterizedTypeName(), '.');
        methodInfo.name = methodDeclaration.selector;
        methodInfo.nameSourceStart = methodDeclaration.sourceStart;
        methodInfo.nameSourceEnd = selectorSourceEnd;
        methodInfo.parameterTypes = argumentTypes;
        methodInfo.parameterNames = argumentNames;
        methodInfo.exceptionTypes = thrownExceptionTypes;
        methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
        methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
        methodInfo.annotations = methodDeclaration.annotations;
        methodInfo.node = methodDeclaration;
        requestor.enterMethod(methodInfo);
    }

    this.visitIfNeeded(methodDeclaration);

    if (isInRange) {
        if (methodDeclaration instanceof AnnotationMethodDeclaration) {
            AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration;
            Expression expression = annotationMethodDeclaration.defaultValue;
            if (expression != null) {
                requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression);
                return;
            }
        }
        requestor.exitMethod(methodDeclaration.declarationSourceEnd,
                (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) null);
    }
}

From source file:org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.java

License:Open Source License

private AbstractMethodDeclaration convert(SourceMethod methodHandle, SourceMethodElementInfo methodInfo,
        CompilationResult compilationResult) throws JavaModelException {
    AbstractMethodDeclaration method;//from w  ww. jav a  2 s  . com

    /* only source positions available */
    int start = methodInfo.getNameSourceStart();
    int end = methodInfo.getNameSourceEnd();

    /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=324850, Even when this type is being constructed
       on behalf of a 1.4 project we must internalize type variables properly in order to be able to
       recognize usages of them in the method signature, to apply substitutions and thus to be able to
       detect overriding in the presence of generics. If we simply drop them, when the method signature
       refers to the type parameter, we won't know it should be bound to the type parameter and perform
       incorrect lookup and may mistakenly end up with missing types
     */
    TypeParameter[] typeParams = null;
    char[][] typeParameterNames = methodInfo.getTypeParameterNames();
    if (typeParameterNames != null) {
        int parameterCount = typeParameterNames.length;
        if (parameterCount > 0) { // method's type parameters must be null if no type parameter
            char[][][] typeParameterBounds = methodInfo.getTypeParameterBounds();
            typeParams = new TypeParameter[parameterCount];
            for (int i = 0; i < parameterCount; i++) {
                typeParams[i] = createTypeParameter(typeParameterNames[i], typeParameterBounds[i], start, end);
            }
        }
    }

    int modifiers = methodInfo.getModifiers();
    if (methodInfo.isConstructor()) {
        ConstructorDeclaration decl = new ConstructorDeclaration(compilationResult);
        decl.bits &= ~ASTNode.IsDefaultConstructor;
        method = decl;
        decl.typeParameters = typeParams;
    } else {
        MethodDeclaration decl;
        if (methodInfo.isAnnotationMethod()) {
            AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration(
                    compilationResult);

            /* conversion of default value */
            SourceAnnotationMethodInfo annotationMethodInfo = (SourceAnnotationMethodInfo) methodInfo;
            boolean hasDefaultValue = annotationMethodInfo.defaultValueStart != -1
                    || annotationMethodInfo.defaultValueEnd != -1;
            if ((this.flags & FIELD_INITIALIZATION) != 0) {
                if (hasDefaultValue) {
                    char[] defaultValueSource = CharOperation.subarray(getSource(),
                            annotationMethodInfo.defaultValueStart, annotationMethodInfo.defaultValueEnd + 1);
                    if (defaultValueSource != null) {
                        Expression expression = parseMemberValue(defaultValueSource);
                        if (expression != null) {
                            annotationMethodDeclaration.defaultValue = expression;
                        }
                    } else {
                        // could not retrieve the default value
                        hasDefaultValue = false;
                    }
                }
            }
            if (hasDefaultValue)
                modifiers |= ClassFileConstants.AccAnnotationDefault;
            decl = annotationMethodDeclaration;
        } else {
            decl = new MethodDeclaration(compilationResult);
        }

        // convert return type
        decl.returnType = createTypeReference(methodInfo.getReturnTypeName(), start, end);

        // type parameters
        decl.typeParameters = typeParams;

        method = decl;
    }
    method.selector = methodHandle.getElementName().toCharArray();
    boolean isVarargs = (modifiers & ClassFileConstants.AccVarargs) != 0;
    method.modifiers = modifiers & ~ClassFileConstants.AccVarargs;
    method.sourceStart = start;
    method.sourceEnd = end;
    method.declarationSourceStart = methodInfo.getDeclarationSourceStart();
    method.declarationSourceEnd = methodInfo.getDeclarationSourceEnd();

    // convert 1.5 specific constructs only if compliance is 1.5 or above
    if (this.has1_5Compliance) {
        /* convert annotations */
        method.annotations = convertAnnotations(methodHandle);
    }

    /* convert arguments */
    String[] argumentTypeSignatures = methodHandle.getParameterTypes();
    char[][] argumentNames = methodInfo.getArgumentNames();
    int argumentCount = argumentTypeSignatures == null ? 0 : argumentTypeSignatures.length;
    if (argumentCount > 0) {
        long position = ((long) start << 32) + end;
        method.arguments = new Argument[argumentCount];
        for (int i = 0; i < argumentCount; i++) {
            TypeReference typeReference = createTypeReference(argumentTypeSignatures[i], start, end);
            if (isVarargs && i == argumentCount - 1) {
                typeReference.bits |= ASTNode.IsVarArgs;
            }
            method.arguments[i] = new Argument(argumentNames[i], position, typeReference,
                    ClassFileConstants.AccDefault);
            // do not care whether was final or not
        }
    }

    /* convert thrown exceptions */
    char[][] exceptionTypeNames = methodInfo.getExceptionTypeNames();
    int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length;
    if (exceptionCount > 0) {
        method.thrownExceptions = new TypeReference[exceptionCount];
        for (int i = 0; i < exceptionCount; i++) {
            method.thrownExceptions[i] = createTypeReference(exceptionTypeNames[i], start, end);
        }
    }

    /* convert local and anonymous types */
    if ((this.flags & LOCAL_TYPE) != 0) {
        IJavaElement[] children = methodInfo.getChildren();
        int typesLength = children.length;
        if (typesLength != 0) {
            Statement[] statements = new Statement[typesLength];
            for (int i = 0; i < typesLength; i++) {
                SourceType type = (SourceType) children[i];
                TypeDeclaration localType = convert(type, compilationResult);
                if ((localType.bits & ASTNode.IsAnonymousType) != 0) {
                    QualifiedAllocationExpression expression = new QualifiedAllocationExpression(localType);
                    expression.type = localType.superclass;
                    localType.superclass = null;
                    localType.superInterfaces = null;
                    localType.allocation = expression;
                    statements[i] = expression;
                } else {
                    statements[i] = localType;
                }
            }
            method.statements = statements;
        }
    }

    return method;
}