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(ReferenceExpression ref, SourceTypeBinding declaringClass) 

Source Link

Usage

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

License:Open Source License

public SyntheticMethodBinding addSyntheticEnumMethod(char[] selector) {
    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(selector);//from   w  w  w .j ava 2s  .  co  m
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(this, selector);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(selector, accessors = new SyntheticMethodBinding[2]);
        accessors[0] = accessMethod;
    } else {
        if ((accessMethod = accessors[0]) == null) {
            accessMethod = new SyntheticMethodBinding(this, selector);
            accessors[0] = accessMethod;
        }
    }
    return accessMethod;
}

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

License:Open Source License

public SyntheticMethodBinding addSyntheticBridgeMethod(MethodBinding inheritedMethodToBridge) {
    if (this.scope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_5) {
        return null;
    }//from   ww  w  .java2 s  . c o  m
    if (isInterface())
        return null;
    if (inheritedMethodToBridge.isAbstract() || inheritedMethodToBridge.isFinal()
            || inheritedMethodToBridge.isStatic()) {
        return null;
    }
    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, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(inheritedMethodToBridge,
                accessors = new SyntheticMethodBinding[2]);
        accessors[0] = accessMethod;
    } else {
        if ((accessMethod = accessors[0]) == null) {
            accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, this);
            accessors[0] = accessMethod;
        }
    }
    return accessMethod;
}