Example usage for org.eclipse.jdt.internal.compiler.lookup SyntheticMethodBinding SyntheticMethodBinding

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

Introduction

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

Prototype

public SyntheticMethodBinding(LambdaExpression lambda, char[] lambdaName, SourceTypeBinding declaringClass) 

Source Link

Usage

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

License:Open Source License

public SyntheticMethodBinding addSyntheticMethodForEnumInitialization(int begin, int end) {
    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 = new SyntheticMethodBinding(this, begin, end);
    SyntheticMethodBinding[] accessors = new SyntheticMethodBinding[2];
    this.synthetics[SourceTypeBinding.METHOD_EMUL].put(accessMethod.selector, accessors);
    accessors[0] = accessMethod;/*from  w  w w  .j av a 2  s.c om*/
    return accessMethod;
}

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);//ww  w .  j a v  a 2  s  .  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 SyntheticMethodBinding addSyntheticBridgeMethod(MethodBinding inheritedMethodToBridge,
        MethodBinding targetMethod) {//from w  w w  .  ja  va 2s. co  m
    if (isInterface())
        return null; // only classes & enums get bridge methods
    // targetMethod may be inherited
    if (inheritedMethodToBridge.returnType.erasure() == targetMethod.returnType.erasure()
            && inheritedMethodToBridge.areParameterErasuresEqual(targetMethod)) {
        return null; // do not need bridge method
    }
    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);
    } else {
        // check to see if there is another equivalent inheritedMethod already added
        Iterator synthMethods = this.synthetics[SourceTypeBinding.METHOD_EMUL].keySet().iterator();
        while (synthMethods.hasNext()) {
            Object synthetic = synthMethods.next();
            if (synthetic instanceof MethodBinding) {
                MethodBinding method = (MethodBinding) synthetic;
                if (CharOperation.equals(inheritedMethodToBridge.selector, method.selector)
                        && inheritedMethodToBridge.returnType.erasure() == method.returnType.erasure()
                        && inheritedMethodToBridge.areParameterErasuresEqual(method)) {
                    return null;
                }
            }
        }
    }

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(inheritedMethodToBridge);
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, targetMethod, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(inheritedMethodToBridge,
                accessors = new SyntheticMethodBinding[2]);
        accessors[1] = accessMethod;
    } else {
        if ((accessMethod = accessors[1]) == null) {
            accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, targetMethod, this);
            accessors[1] = accessMethod;
        }
    }
    return accessMethod;
}