Examples of MethodBinding


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

    ResolvedMember m = world.makeResolvedMember(binding);
    ResolvedMember superAccessMember = AjcMemberMaker.superAccessMethod(inAspect.typeX, m);
    if (inAspect.superAccessForInline.containsKey(superAccessMember)) {
      return ((SuperAccessMethodPair) inAspect.superAccessForInline.get(superAccessMember)).accessMethod;
    }
    MethodBinding ret = world.makeMethodBinding(superAccessMember);
    inAspect.superAccessForInline.put(superAccessMember, new SuperAccessMethodPair(m, ret));
    return ret;
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

    // System.out.println("endVisit: " + call);
    // an error has already occurred
    if (call.codegenBinding == null)
      return;

    MethodBinding superBinding = call.codegenBinding;
    if (superBinding instanceof ProblemMethodBinding) {
      return;
    }
    // InterTypeMethodBindings are always statically bound, so there's no
    // need to treat super calls specially here
    if (superBinding instanceof InterTypeMethodBinding) {
      return;
      // InterTypeMethodBinding m = (InterTypeMethodBinding)superBinding;
      // if (m.postDispatchMethod != null) {
      // call.binding = m.postDispatchMethod;
      // }
      // return;
    }
    if (superBinding instanceof ParameterizedMethodBinding) {
      superBinding = ((ParameterizedMethodBinding) superBinding).original();
    }
    EclipseFactory factory = ((AjLookupEnvironment) method.scope.environment()).factory;
    if (depthCounter != 0 && targetClass.isInterface()) {// pr198196 - when calling MarkerInterface.super.XXX()
      if (call.isSuperAccess() && !call.binding.isStatic()) {
        MethodScope currentMethodScope = scope.methodScope();
        SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType();
        FieldBinding field = sourceType.addSyntheticFieldForInnerclass(targetClass);
        call.receiver = new KnownFieldReference(field, call.receiver.sourceStart, call.receiver.sourceEnd);
      } else {
        return;
      }
    } else if (depthCounter == 0) { // Allow case testSuperItds_pr198196_2/3

      char[] accessName;
      if (call.isSuperAccess() && !call.binding.isStatic()) {
        call.receiver = new ThisReference(call.receiver.sourceStart, call.receiver.sourceEnd);
        accessName = NameMangler.superDispatchMethod(factory.fromBinding(targetClass), new String(superBinding.selector))
            .toCharArray();
      } else if (call.receiver.isThis() && call.binding.isProtected() && !call.binding.isStatic()) {
        // XXX this is a hack that violates some binary compatibility rules
        ReferenceBinding superBindingDeclaringClass = superBinding.declaringClass;
        if (superBindingDeclaringClass.isParameterizedType()) {
          superBindingDeclaringClass = ((ParameterizedTypeBinding) superBindingDeclaringClass).type;
        }
        if (superBindingDeclaringClass.equals(targetClass)) {
          accessName = NameMangler.protectedDispatchMethod(factory.fromBinding(targetClass),
              new String(superBinding.selector)).toCharArray();
        } else {
          accessName = NameMangler.superDispatchMethod(factory.fromBinding(targetClass),
              new String(superBinding.selector)).toCharArray();
        }
      } else {
        return;
      }

      // ??? do we want these to be unique
      MethodBinding superAccessBinding = new MethodBinding(ClassFileConstants.AccPublic, accessName, superBinding.returnType,
          superBinding.parameters, superBinding.thrownExceptions, targetClass);

      AstUtil.replaceMethodBinding(call, superAccessBinding);
    } else {
      return;
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

      MemberValuePair[] memberValuePairs = normalAnnotation.memberValuePairs;
      if (memberValuePairs != null) {
        int memberValuePairsLength = memberValuePairs.length;
        for (int i = 0; i < memberValuePairsLength; i++) {
          MemberValuePair memberValuePair = memberValuePairs[i];
          MethodBinding methodBinding = memberValuePair.binding;
          if (methodBinding == null) {
            // is this just a marker annotation?
            throw new MissingImplementationException(
                "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation [" + annotation
                    + "]");
          } else {
            AnnotationValue av = generateElementValue(memberValuePair.value, methodBinding.returnType);
            AnnotationNameValuePair anvp = new AnnotationNameValuePair(new String(memberValuePair.name), av);
            annotationAJ.addNameValuePair(anvp);
          }
        }
      } else {
        throw new MissingImplementationException(
            "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation [" + annotation + "]");
      }
    } else if (annotation instanceof SingleMemberAnnotation) {
      // this is a single member annotation (one member value)
      SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation;
      MethodBinding methodBinding = singleMemberAnnotation.memberValuePairs()[0].binding;
      if (methodBinding == null) {
        throw new MissingImplementationException(
            "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation [" + annotation + "]");
      } else {
        AnnotationValue av = generateElementValue(singleMemberAnnotation.memberValue, methodBinding.returnType);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

      }
    }
  }
}
public void acceptLocalMethodTypeParameter(TypeVariableBinding typeVariableBinding) {
  MethodBinding methodBinding = (MethodBinding)typeVariableBinding.declaringElement;
  IJavaElement res = findLocalElement(methodBinding.sourceStart());
  if(res != null && res.getElementType() == IJavaElement.METHOD) {
    IMethod method = (IMethod) res;

    ITypeParameter typeParameter = method.getTypeParameter(new String(typeVariableBinding.sourceName));
    if (typeParameter.exists()) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

        for (int i = length; --i >= 0;) {
          pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type
        }
        this.binding = scope.findMethod((ReferenceBinding) receiverType, TypeConstants.INIT, pseudoArgs, this);
        if (this.binding != null && !this.binding.isValidBinding()) {
          MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
          // record the closest match, for clients who may still need hint about possible method match
          if (closestMatch != null) {
            if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method
              // shouldn't return generic method outside its context, rather convert it to raw method (175409)
              closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null);
            }
            this.binding = closestMatch;
            MethodBinding closestMatchOriginal = closestMatch.original();
            if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) {
              // ignore cases where method is used from within inside itself (e.g. direct recursions)
              closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
            }
          }
        }
       
      }
      return this.resolvedType = receiverType;
    }
    if (this.anonymousType == null) {
      // qualified allocation with no anonymous type
      if (!receiverType.canBeInstantiated()) {
        scope.problemReporter().cannotInstantiate(this.type, receiverType);
        return this.resolvedType = receiverType;
      }
      ReferenceBinding allocationType = (ReferenceBinding) receiverType;
      if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
        if (isMethodUseDeprecated(this.binding, scope, true)) {
          scope.problemReporter().deprecatedMethod(this.binding, this);
        }
        checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
      } else {
        if (this.binding.declaringClass == null) {
          this.binding.declaringClass = allocationType;
        }
        scope.problemReporter().invalidConstructor(this, this.binding);
        return this.resolvedType = receiverType;
      }

      // The enclosing instance must be compatible with the innermost enclosing type
      ReferenceBinding expectedType = this.binding.declaringClass.enclosingType();
      if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError()
        scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType);
      if (enclosingInstanceType.isCompatibleWith(expectedType) || scope.isBoxingCompatibleWith(enclosingInstanceType, expectedType)) {
        this.enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType);
        return this.resolvedType = receiverType;
      }
      scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance);
      return this.resolvedType = receiverType;
    }

    if (receiverType.isTypeVariable()) {
      receiverType = new ProblemReferenceBinding(receiverType.sourceName(), (ReferenceBinding)receiverType, ProblemReasons.IllegalSuperTypeVariable);
      scope.problemReporter().invalidType(this, receiverType);
      return null;
    } else if (this.type != null && receiverType.isEnum()) { // tolerate enum constant body
      scope.problemReporter().cannotInstantiate(this.type, receiverType);
      return this.resolvedType = receiverType;
    }
    // anonymous type scenario
    // an anonymous class inherits from java.lang.Object when declared "after" an interface
    this.superTypeBinding = receiverType.isInterface() ? scope.getJavaLangObject() : (ReferenceBinding) receiverType;
    // insert anonymous type in scope
    scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType);
    this.anonymousType.resolve(scope);   
    if (this.superTypeBinding.erasure().id == TypeIds.T_JavaLangEnum) {
      scope.problemReporter().cannotExtendEnum(this.anonymousType.binding, this.type, this.superTypeBinding);
    }
   
    if ((receiverType.tagBits & TagBits.HasDirectWildcard) != 0) {
      scope.problemReporter().superTypeCannotUseWildcard(this.anonymousType.binding, this.type, receiverType);
    }   
    // find anonymous super constructor
    MethodBinding inheritedBinding = scope.getConstructor(this.superTypeBinding, argumentTypes, this);
    if (!inheritedBinding.isValidBinding()) {
      if (inheritedBinding.declaringClass == null) {
        inheritedBinding.declaringClass = this.superTypeBinding;
      }
      scope.problemReporter().invalidConstructor(this, inheritedBinding);
      return this.resolvedType = this.anonymousType.binding;
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

        typeVariableToTypeBinding.put(element, aliasTarget.typeVariables()[i++]);
      }
    }

    currentType = declaringType;
    MethodBinding mb = new MethodBinding(member.getModifiers(), member.getName().toCharArray(),
        makeTypeBinding(member.getReturnType()), makeTypeBindings(member.getParameterTypes()),
        makeReferenceBindings(member.getExceptions()), declaringType);

    if (tvbs != null) {
      mb.typeVariables = tvbs;
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

    }
    return tvBinding;
  }

  public MethodBinding makeMethodBindingForCall(Member member) {
    return new MethodBinding(member.getModifiers() & ~Modifier.INTERFACE, member.getName().toCharArray(),
        makeTypeBinding(member.getReturnType()), makeTypeBindings(member.getParameterTypes()), new ReferenceBinding[0],
        (ReferenceBinding) makeTypeBinding(member.getDeclaringType()));
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

          if (needValue) {
            codeStream.generateConstant(fieldConstant, 0);
          }
        } else {
          if (needValue || (i > 0 && complyTo14) || lastGenericCast != null) {
            MethodBinding accessor = this.syntheticReadAccessors == null ? null : this.syntheticReadAccessors[i];
            if (accessor == null) {
              if (lastFieldBinding.isStatic()) {
                codeStream.getstatic(lastFieldBinding);
              } else {
                codeStream.getfield(lastFieldBinding);
              }
            } else {
              codeStream.invokestatic(accessor);
            }
            if (lastGenericCast != null) codeStream.checkcast(lastGenericCast);
            if (!needValue) codeStream.pop();
          } else {
            if (this.codegenBinding == lastFieldBinding) {
              if (lastFieldBinding.isStatic()){
                // if no valueRequired, still need possible side-effects of <clinit> invocation, if field belongs to different class
                if (((FieldBinding)this.binding).original().declaringClass != this.actualReceiverType.erasure()) {
                  MethodBinding accessor = this.syntheticReadAccessors == null ? null : this.syntheticReadAccessors[i];
                  if (accessor == null) {
                    codeStream.getstatic(lastFieldBinding);
                  } else {
                    codeStream.invokestatic(accessor);
                  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

        this.constant = Constant.NotAConstant;
        scope.problemReporter().invalidMethod(this, this.binding);
        return null;
      }
      CodeSnippetScope localScope = new CodeSnippetScope(scope);     
      MethodBinding privateBinding =
        this.receiver instanceof CodeSnippetThisReference && ((CodeSnippetThisReference) this.receiver).isImplicit
          ? localScope.getImplicitMethod((ReferenceBinding)this.delegateThis.type, this.selector, argumentTypes, this)
          : localScope.getMethod(this.delegateThis.type, this.selector, argumentTypes, this);
      if (!privateBinding.isValidBinding()) {
        if (this.binding.declaringClass == null) {
          if (this.actualReceiverType instanceof ReferenceBinding) {
            this.binding.declaringClass = (ReferenceBinding) this.actualReceiverType;
          } else { // really bad error ....
            scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, argumentTypes);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

  public UnresolvedType getTypeX() {
    return typeX;
  }
 
  public void addMethod(EclipseFactory world , ResolvedMember member) {
    MethodBinding binding = world.makeMethodBinding(member);
    this.methods.add(binding);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.