Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedMember


    if (binding.isPrivate() && binding.declaringClass != inAspect.binding) {
      binding.modifiers = AstUtil.makePackageVisible(binding.modifiers);
    }

    ResolvedMember m = world.makeResolvedMember(binding, receiverType);
    if (inAspect.accessForInline.containsKey(m))
      return (FieldBinding) inAspect.accessForInline.get(m);
    FieldBinding ret = new InlineAccessFieldBinding(inAspect, binding, m);

    // System.err.println("   made accessor: " + ret);
View Full Code Here


    if (binding instanceof ParameterizedMethodBinding) { // pr124999
      binding = binding.original();
    }

    ResolvedMember m = null;
    if (binding.isPrivate() && binding.declaringClass != inAspect.binding) {
      // does this always mean that the aspect is an inner aspect of the bindings
      // declaring class? After all, the field is private but we can see it from
      // where we are.
      binding.modifiers = AstUtil.makePackageVisible(binding.modifiers);
View Full Code Here

      this.accessMethod = accessMethod;
    }
  }

  private MethodBinding getSuperAccessMethod(MethodBinding binding) {
    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));
View Full Code Here

    UnresolvedType memberHostType = declaredSig.getDeclaringType();
    String methodName = declaredSig.getName();
    String[] pnames = null;
    if (rm.getKind() == Member.METHOD && !rm.isAbstract()) {
      if (methodName.startsWith("ajc$inlineAccessMethod") || methodName.startsWith("ajc$superDispatch")) {
        ResolvedMember resolvedDooberry = world.resolve(declaredSig);
        pnames = resolvedDooberry.getParameterNames();
      } else {
        ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm.resolve(world), memberHostType).resolve(world);
        ResolvedMember theRealMember = findResolvedMemberNamed(memberHostType.resolve(world), realthing.getName());
        if (theRealMember != null) {
          pnames = theRealMember.getParameterNames();
          // static ITDs don't need any parameter shifting
          if (pnames.length > 0 && pnames[0].equals("ajc$this_")) {
            String[] pnames2 = new String[pnames.length - 1];
            System.arraycopy(pnames, 1, pnames2, 0, pnames2.length);
            pnames = pnames2;
View Full Code Here

      String methodName = declaredSig.getName();
      // FIXME asc shouldnt really rely on string names !
      if (annotations == null) {
        if (rm.getKind() == Member.FIELD) {
          if (methodName.startsWith("ajc$inlineAccessField")) {
            ResolvedMember resolvedDooberry = world.resolve(rm);
            annotations = resolvedDooberry.getAnnotationTypes();
          } else {
            ResolvedMember realthing = AjcMemberMaker.interFieldInitializer(rm, memberHostType);
            ResolvedMember resolvedDooberry = world.resolve(realthing);
            annotations = resolvedDooberry.getAnnotationTypes();
          }
        } else if (rm.getKind() == Member.METHOD && !rm.isAbstract()) {
          if (methodName.startsWith("ajc$inlineAccessMethod") || methodName.startsWith("ajc$superDispatch")) {
            ResolvedMember resolvedDooberry = world.resolve(declaredSig);
            annotations = resolvedDooberry.getAnnotationTypes();
          } else {
            ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm.resolve(world), memberHostType).resolve(
                world);
            // ResolvedMember resolvedDooberry =
            // world.resolve(realthing);
            ResolvedMember theRealMember = findResolvedMemberNamed(memberHostType.resolve(world), realthing.getName());
            // AMC temp guard for M4
            if (theRealMember == null) {
              throw new UnsupportedOperationException(
                  "Known limitation in M4 - can't find ITD members when type variable is used as an argument and has upper bound specified");
            }
            annotations = theRealMember.getAnnotationTypes();
          }
        } else if (rm.getKind() == Member.CONSTRUCTOR) {
          ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world),
              rm.getDeclaringType(), rm.getParameterTypes());
          ResolvedMember resolvedDooberry = world.resolve(realThing);
          // AMC temp guard for M4
          if (resolvedDooberry == null) {
            throw new UnsupportedOperationException(
                "Known limitation in M4 - can't find ITD members when type variable is used as an argument and has upper bound specified");
          }
          annotations = resolvedDooberry.getAnnotationTypes();
        }
        if (annotations == null) {
          annotations = new ResolvedType[0];
        }
        mapToAnnotations.put(rm, annotations);
View Full Code Here

  private void matchInvokeInstruction(LazyMethodGen mg, InstructionHandle ih, InvokeInstruction invoke,
      BcelShadow enclosingShadow, List<BcelShadow> shadowAccumulator) {
    String methodName = invoke.getName(cpg);
    if (methodName.startsWith(NameMangler.PREFIX)) {
      Member jpSig = world.makeJoinPointSignatureForMethodInvocation(clazz, invoke);
      ResolvedMember declaredSig = jpSig.resolve(world);
      // System.err.println(method + ", declaredSig: " +declaredSig);
      if (declaredSig == null) {
        return;
      }

      if (declaredSig.getKind() == Member.FIELD) {
        Shadow.Kind kind;
        if (jpSig.getReturnType().equals(ResolvedType.VOID)) {
          kind = Shadow.FieldSet;
        } else {
          kind = Shadow.FieldGet;
        }

        if (canMatch(Shadow.FieldGet) || canMatch(Shadow.FieldSet)) {
          match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow, kind, declaredSig), shadowAccumulator);
        }
      } else {
        AjAttribute.EffectiveSignatureAttribute effectiveSig = declaredSig.getEffectiveSignature();
        if (effectiveSig == null) {
          return;
        }
        // System.err.println("call to inter-type member: " +
        // effectiveSig);
        if (effectiveSig.isWeaveBody()) {
          return;
        }

        ResolvedMember rm = effectiveSig.getEffectiveSignature();
        fixParameterNamesForResolvedMember(rm, declaredSig);
        fixAnnotationsForResolvedMember(rm, declaredSig); // abracadabra

        if (canMatch(effectiveSig.getShadowKind())) {
          match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow, effectiveSig.getShadowKind(), rm),
View Full Code Here

          }
        }
      } else if (munger.getKind().equals(ResolvedTypeMunger.FieldHost)) {
        // hidden
      } else {
        ResolvedMember declaredSig = munger.getSignature();
        String fromString = fName + ":'" + declaredSig + "'";
        // if (declaredSig==null) declaredSig= munger.getSignature();
        String kindString = munger.getKind().toString().toLowerCase();
        if (kindString.equals("innerclass")) {
          kindString = "member class";
View Full Code Here

    List<ResolvedMember> newParentMethods = newParent.getMethodsWithoutIterator(false, true, false);
    for (ResolvedMember newParentMethod : newParentMethods) {
      String newParentMethodName = newParentMethod.getName();
      // Ignore abstract ajc$interField prefixed methods
      if (newParentMethod.isAbstract() && !newParentMethodName.startsWith("ajc$interField")) {
        ResolvedMember discoveredImpl = null;
        List<ResolvedMember> targetMethods = newParentTarget.getType().getMethodsWithoutIterator(false, true, false);
        for (ResolvedMember targetMethod : targetMethods) {
          if (!targetMethod.isAbstract() && targetMethod.getName().equals(newParentMethodName)) {
            String newParentMethodSig = newParentMethod.getParameterSignature(); // ([TT;)
            String targetMethodSignature = targetMethod.getParameterSignature(); // ([Ljava/lang/Object;)
            // could be a match
            if (targetMethodSignature.equals(newParentMethodSig)) {
              discoveredImpl = targetMethod;
            } else {
              // Does the erasure match? In which case a bridge method will be created later to
              // satisfy the abstract method
              if (targetMethod.hasBackingGenericMember()
                  && targetMethod.getBackingGenericMember().getParameterSignature().equals(newParentMethodSig)) {
                discoveredImpl = targetMethod;
              } else if (newParentMethod.hasBackingGenericMember()) {
                if (newParentMethod.getBackingGenericMember().getParameterSignature().equals(targetMethodSignature)) {
                  discoveredImpl = targetMethod;
                }
              }
            }
            if (discoveredImpl != null) {
              break;
            }
          }
        }
        if (discoveredImpl == null) {
          // didnt find a valid implementation, lets check the
          // ITDs on this type to see if they satisfy it
          boolean satisfiedByITD = false;
          for (ConcreteTypeMunger m : newParentTarget.getType().getInterTypeMungersIncludingSupers()) {
            if (m.getMunger() != null && m.getMunger().getKind() == ResolvedTypeMunger.Method) {
              ResolvedMember sig = m.getSignature();
              if (!Modifier.isAbstract(sig.getModifiers())) {
                // If the ITD shares a type variable with some target type, we need to tailor it
                // for that type
                if (m.isTargetTypeParameterized()) {
                  ResolvedType genericOnType = getWorld().resolve(sig.getDeclaringType()).getGenericType();
                  m = m.parameterizedFor(newParent.discoverActualOccurrenceOfTypeInHierarchy(genericOnType));
                  // possible sig change when type parameters filled in
                  sig = m.getSignature();
                }
                if (ResolvedType.matches(
                    AjcMemberMaker.interMethod(sig, m.getAspectType(),
                        sig.getDeclaringType().resolve(weaver.getWorld()).isInterface()), newParentMethod)) {
                  satisfiedByITD = true;
                }
              }
            } else if (m.getMunger() != null && m.getMunger().getKind() == ResolvedTypeMunger.MethodDelegate2) {
              // AV - that should be enough, no need to check more
View Full Code Here

                && invokeSpecial.getMethodName(cpg).equals("<init>")) {
              // System.err.println("Transforming super call '<init>" + invokeSpecial.getSignature(cpg) + "'");

              // 1. Check there is a ctor in the new parent with
              // the same signature
              ResolvedMember newCtor = getConstructorWithSignature(newParent, invokeSpecial.getSignature(cpg));

              if (newCtor == null) {

                // 2. Check ITDCs to see if the necessary ctor is provided that way
                boolean satisfiedByITDC = false;
View Full Code Here

    return null;
  }

  private boolean mungePrivilegedAccess(BcelClassWeaver weaver, PrivilegedAccessMunger munger) {
    LazyClassGen gen = weaver.getLazyClassGen();
    ResolvedMember member = munger.getMember();

    ResolvedType onType = weaver.getWorld().resolve(member.getDeclaringType(), munger.getSourceLocation());
    if (onType.isRawType()) {
      onType = onType.getGenericType();
    }

    // System.out.println("munging: " + gen + " with " + member);
    if (onType.equals(gen.getType())) {
      if (member.getKind() == Member.FIELD) {
        // System.out.println("matched: " + gen);
        addFieldGetter(gen, member,
            AjcMemberMaker.privilegedAccessMethodForFieldGet(aspectType, member, munger.shortSyntax));
        addFieldSetter(gen, member,
            AjcMemberMaker.privilegedAccessMethodForFieldSet(aspectType, member, munger.shortSyntax));
        return true;
      } else if (member.getKind() == Member.METHOD) {
        addMethodDispatch(gen, member, AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, member));
        return true;
      } else if (member.getKind() == Member.CONSTRUCTOR) {
        for (Iterator<LazyMethodGen> i = gen.getMethodGens().iterator(); i.hasNext();) {
          LazyMethodGen m = i.next();
          if (m.getMemberView() != null && m.getMemberView().getKind() == Member.CONSTRUCTOR) {
            // m.getMemberView().equals(member)) {
            m.forcePublic();
            // return true;
          }
        }
        return true;
        // throw new BCException("no match for " + member + " in " +
        // gen);
      } else if (member.getKind() == Member.STATIC_INITIALIZATION) {
        gen.forcePublic();
        return true;
      } else {
        throw new RuntimeException("unimplemented");
      }
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.