Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedMember


  public void methodMustOverride(AbstractMethodDeclaration method) {

    // ignore ajc$ methods
    if (new String(method.selector).startsWith("ajc$"))
      return;
    ResolvedMember possiblyErroneousRm = factory.makeResolvedMember(method.binding);

    ResolvedType onTypeX = factory.fromEclipse(method.binding.declaringClass);
    // Can't use 'getInterTypeMungersIncludingSupers()' since that will exclude abstract ITDs
    // on any super classes - so we have to trawl up ourselves.. I wonder if this problem
    // affects other code in the problem reporter that looks through ITDs...
    ResolvedType supertypeToLookAt = onTypeX.getSuperclass();
    while (supertypeToLookAt != null) {
      List itMungers = supertypeToLookAt.getInterTypeMungers();
      for (Iterator i = itMungers.iterator(); i.hasNext();) {
        ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
        ResolvedMember sig = m.getSignature();
        if (sig == null)
          continue; // we aren't interested in other kinds of munger
        UnresolvedType dType = sig.getDeclaringType();
        if (dType == null)
          continue;
        ResolvedType resolvedDeclaringType = dType.resolve(factory.getWorld());
        ResolvedMember rm = AjcMemberMaker.interMethod(sig, m.getAspectType(), resolvedDeclaringType.isInterface());
        if (ResolvedType.matches(rm, possiblyErroneousRm)) {
          // match, so dont need to report a problem!
          return;
        }
      }
View Full Code Here


              String fname = new String(fieldDecl.name);
              Collection/* ResolvedMember */privvies = ((ReferenceType) theAspect).getPrivilegedAccesses();
              // On an incremental compile the information is in the bcel delegate
              if (privvies != null) {
                for (Iterator iterator = privvies.iterator(); iterator.hasNext();) {
                  ResolvedMember priv = (ResolvedMember) iterator.next();
                  if (priv.getName().equals(fname)) {
                    return;
                  }
                }
              }
            }
View Full Code Here

      boolean isExactTargetType) {
    InterTypeMethodBinding binding = new InterTypeMethodBinding(world, munger, aspectType, sourceMethod);

    if (!isExactTargetType) {
      // we're munging an interface ITD onto a topmost implementor
      ResolvedMember existingMember = onType.lookupMemberIncludingITDsOnInterfaces(getSignature());
      if (existingMember != null) {
        // already have an implementation, so don't do anything
        if (onType == existingMember.getDeclaringType() && Modifier.isFinal(munger.getSignature().getModifiers())) {
          // final modifier on default implementation is taken to mean that
          // no-one else can provide an implementation
          MethodBinding offendingBinding = sourceType.getExactMethod(binding.selector, binding.parameters,
              sourceType.scope.compilationUnitScope());
          sourceType.scope.problemReporter().finalMethodCannotBeOverridden(offendingBinding, binding);
View Full Code Here

  public boolean definesPrivilegedAccessToField(FieldBinding field) {
    if (field instanceof ParameterizedFieldBinding) {
      field = ((ParameterizedFieldBinding) field).originalField;
    }
    ResolvedMember key = inAspect.factory.makeResolvedMember(field);
    return (accessors.containsKey(key));
  }
View Full Code Here

  public FieldBinding getPrivilegedAccessField(FieldBinding baseField, ASTNode location) {
    if (baseField instanceof ParameterizedFieldBinding) {
      baseField = ((ParameterizedFieldBinding) baseField).originalField;
    }
    ResolvedMember key = inAspect.factory.makeResolvedMember(baseField);
    if (accessors.containsKey(key))
      return (FieldBinding) accessors.get(key);
    FieldBinding ret = new PrivilegedFieldBinding(inAspect, baseField);
    checkWeaveAccess(key.getDeclaringType(), location);
    if (!baseField.alwaysNeedsAccessMethod(true))
      accessors.put(key, ret);
    // 307120
    ResolvedType rt = inAspect.factory.fromEclipse(baseField.declaringClass);
    if (rt != null) {
View Full Code Here

  public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod, ASTNode location) {
    if (baseMethod.alwaysNeedsAccessMethod())
      return baseMethod;

    ResolvedMember key = null;

    if (baseMethod instanceof ParameterizedMethodBinding) {
      key = inAspect.factory.makeResolvedMember(((ParameterizedMethodBinding) baseMethod).original());
    } else {
      key = inAspect.factory.makeResolvedMember(baseMethod);
    }
    if (accessors.containsKey(key))
      return (MethodBinding) accessors.get(key);

    MethodBinding ret;
    if (baseMethod.isConstructor()) {
      ret = new MethodBinding(baseMethod, baseMethod.declaringClass);
      ret.modifiers = AstUtil.makePublic(ret.modifiers);
      baseMethod.modifiers = ret.modifiers;
    } else {
      ret = inAspect.factory.makeMethodBinding(AjcMemberMaker.privilegedAccessMethodForMethod(inAspect.typeX, key));
    }
    checkWeaveAccess(key.getDeclaringType(), location);
    accessors.put(key, ret);
    // if (!baseMethod.isConstructor()) {
    // ResolvedType rt = inAspect.factory.fromEclipse(baseMethod.declaringClass);
    // if (rt!=null) {
    // ReferenceTypeDelegate rtd = ((ReferenceType)rt).getDelegate();
View Full Code Here

    // }
    return ret;
  }

  public void notePrivilegedTypeAccess(ReferenceBinding type, ASTNode location) {
    ResolvedMember key = new ResolvedMemberImpl(Member.STATIC_INITIALIZATION, inAspect.factory.fromEclipse(type), 0,
        ResolvedType.VOID, "", UnresolvedType.NONE);

    checkWeaveAccess(key.getDeclaringType(), location);
    accessors.put(key, key);
  }
View Full Code Here

    if (ignoreFurtherInvestigation) {
      return;
    }

    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(upperScope);
    ResolvedMember sig = munger.getSignature();
    UnresolvedType aspectType = world.fromBinding(upperScope.referenceContext.binding);

    if (sig.getReturnType() == ResolvedType.VOID
        || (sig.getReturnType().isArray() && (sig.getReturnType().getComponentType() == ResolvedType.VOID))) {
      upperScope.problemReporter().signalError(sourceStart, sourceEnd, "field type can not be void");
    }

    //
    // System.err.println("sig: " + sig);
    // System.err.println("field: " + world.makeFieldBinding(
    // AjcMemberMaker.interFieldClassField(sig, aspectType)));

    if (initialization != null && initialization instanceof ArrayInitializer) {
      // System.err.println("got initializer: " + initialization);
      ArrayAllocationExpression aae = new ArrayAllocationExpression();
      aae.initializer = (ArrayInitializer) initialization;
      ArrayBinding arrayType = (ArrayBinding) world.makeTypeBinding(sig.getReturnType());
      aae.type = AstUtil.makeTypeReference(arrayType.leafComponentType());
      aae.sourceStart = initialization.sourceStart;
      aae.sourceEnd = initialization.sourceEnd;
      aae.dimensions = new Expression[arrayType.dimensions];
      initialization = aae;
    } /*
     * else if (initialization!=null) { MethodScope initializationScope = this.scope; TypeBinding fieldType = realFieldType;
     * TypeBinding initializationType; this.initialization.setExpectedType(fieldType); // needed in case of generic method
     * invocation if (this.initialization instanceof ArrayInitializer) {
     *
     * if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) {
     * ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType;
     * this.initialization.computeConversion(initializationScope, fieldType, initializationType); } } //
     * System.err.println("i=>"+initialization); // System.err.println("sasuages=>"+initialization.resolvedType); //
     * //initializationType = initialization.resolveType(initializationScope); //
     * System.err.println("scope=>"+initializationScope);
     *
     * else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) {
     *
     * if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError()
     * initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); if
     * (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) || (fieldType.isBaseType() &&
     * BaseTypeBinding.isWidening(fieldType.id, initializationType.id)) || initializationType.isCompatibleWith(fieldType)) {
     * initialization.computeConversion(initializationScope, fieldType, initializationType); if
     * (initializationType.needsUncheckedConversion(fieldType)) {
     * initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType); } } else
     * if (initializationScope.isBoxingCompatibleWith(initializationType, fieldType) || (initializationType.isBaseType() //
     * narrowing then boxing ? && initializationScope.compilerOptions().sourceLevel >= JDK1_5 // autoboxing &&
     * !fieldType.isBaseType() && initialization.isConstantValueOfTypeAssignableToType(initializationType,
     * initializationScope.environment().computeBoxingType(fieldType)))) {
     * this.initialization.computeConversion(initializationScope, fieldType, initializationType); } else {
     * initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this); } // if
     * (this.binding.isFinal()){ // cast from constant actual type to variable type //
     * this.binding.setConstant(this.initialization.constant.castTo((this.binding.returnType.id << 4) +
     * this.initialization.constant.typeID())); // } // } else { // this.binding.setConstant(NotAConstant); } // }
     */

    // ////////////////////

    if (initialization == null) {
      this.statements = new Statement[] { new ReturnStatement(null, 0, 0), };
    } else if (!onTypeBinding.isInterface()) {
      MethodBinding writeMethod = world.makeMethodBinding(AjcMemberMaker.interFieldSetDispatcher(sig, aspectType), munger
          .getTypeVariableAliases());
      // For the body of an intertype field initalizer, generate a call to the inter field set dispatcher
      // method as that casts the shadow of a field set join point.
      if (Modifier.isStatic(declaredModifiers)) {
        this.statements = new Statement[] { new KnownMessageSend(writeMethod, AstUtil
            .makeNameReference(writeMethod.declaringClass), new Expression[] { initialization }), };
      } else {
        this.statements = new Statement[] { new KnownMessageSend(writeMethod, AstUtil
            .makeNameReference(writeMethod.declaringClass), new Expression[] {
            AstUtil.makeLocalVariableReference(arguments[0].binding), initialization }), };
      }
    } else {
      // XXX something is broken about this logic. Can we write to static interface fields?
      MethodBinding writeMethod = world.makeMethodBinding(AjcMemberMaker.interFieldInterfaceSetter(sig, sig
          .getDeclaringType().resolve(world.getWorld()), aspectType), munger.getTypeVariableAliases());
      if (Modifier.isStatic(declaredModifiers)) {
        this.statements = new Statement[] { new KnownMessageSend(writeMethod, AstUtil
            .makeNameReference(writeMethod.declaringClass), new Expression[] { initialization }), };
      } else {
View Full Code Here

    if (interTypeScope == null) {
      return null; // We encountered a problem building the scope, don't continue - error already reported
    }

    // Build a half correct resolvedmember (makeResolvedMember understands tvars) then build a fully correct sig from it
    ResolvedMember sigtemp = world.makeResolvedMemberForITD(binding, onTypeBinding, interTypeScope.getRecoveryAliases());
    UnresolvedType returnType = sigtemp.getReturnType();
    // if (returnType.isParameterizedType() || returnType.isGenericType()) returnType = returnType.getRawType();
    ResolvedMember sig = new ResolvedMemberImpl(Member.FIELD, declaringType, declaredModifiers, returnType, new String(
        declaredSelector), UnresolvedType.NONE);
    sig.setTypeVariables(sigtemp.getTypeVariables());

    NewFieldTypeMunger myMunger = new NewFieldTypeMunger(sig, null, typeVariableAliases);
    setMunger(myMunger);
    ResolvedType aspectType = world.fromEclipse(classScope.referenceContext.binding);
    ResolvedMember me = myMunger.getInitMethod(aspectType);
    this.selector = binding.selector = me.getName().toCharArray();
    this.realFieldType = this.binding.returnType;
    this.binding.returnType = TypeBinding.VOID;
    // ??? all other pieces should already match

    return new EclipseTypeMunger(world, myMunger, aspectType, this);
View Full Code Here

    // interBinding.writer.generateMethod(this, classScope, classFile);
  }

  private void generateDispatchMethods(ClassScope classScope, ClassFile classFile) {
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope);
    ResolvedMember sig = munger.getSignature();
    UnresolvedType aspectType = world.fromBinding(classScope.referenceContext.binding);
    generateDispatchMethod(world, sig, aspectType, classScope, classFile, true);
    generateDispatchMethod(world, sig, aspectType, classScope, classFile, false);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ResolvedMember

Copyright © 2018 www.massapicom. 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.