Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedType$MethodGetterIncludingItds


        return methodThatMightBeGettingOverridden.getBackingGenericMember();
      } else if (!methodThatMightBeGettingOverridden.getReturnType().getErasureSignature().equals(mrettype)) {
        // addressing the wierd situation from bug 147801
        // just check whether these things are in the right relationship
        // for covariance...
        ResolvedType superReturn = typeToCheck.getWorld().resolve(
            UnresolvedType.forSignature(methodThatMightBeGettingOverridden.getReturnType().getErasureSignature()));
        ResolvedType subReturn = typeToCheck.getWorld().resolve(UnresolvedType.forSignature(mrettype));
        if (superReturn.isAssignableFrom(subReturn)) {
          return methodThatMightBeGettingOverridden;
        }
        // } else if (typeToCheck.isParameterizedType()) {
        // return methodThatMightBeGettingOverridden.getBackingGenericMember();
View Full Code Here


    if (typeToCheck.equals(UnresolvedType.OBJECT)) {
      return null;
    }

    ResolvedType superclass = typeToCheck.getSuperclass();
    ResolvedMember overriddenMethod = checkForOverride(superclass, mname, mparams, mrettype, mmods, mpkg, methodParamsArray);
    if (overriddenMethod != null) {
      return overriddenMethod;
    }

    ResolvedType[] interfaces = typeToCheck.getDeclaredInterfaces();
    for (int i = 0; i < interfaces.length; i++) {
      ResolvedType anInterface = interfaces[i];
      overriddenMethod = checkForOverride(anInterface, mname, mparams, mrettype, mmods, mpkg, methodParamsArray);
      if (overriddenMethod != null) {
        return overriddenMethod;
      }
    }
View Full Code Here

        System.err.println("Bridging: Determining if we have to bridge to " + clazz.getName() + "." + name + ""
            + bridgeToCandidate.getSignature());
      }

      // Let's take a look at the superclass
      ResolvedType theSuperclass = clazz.getSuperClass();
      if (world.forDEBUG_bridgingCode) {
        System.err.println("Bridging: Checking supertype " + theSuperclass);
      }
      String pkgName = clazz.getPackageName();
      UnresolvedType[] bm = BcelWorld.fromBcel(bridgeToCandidate.getArgumentTypes());
      ResolvedMember overriddenMethod = checkForOverride(theSuperclass, name, psig, rsig, bridgeToCandidate.getAccessFlags(),
          pkgName, bm);
      if (overriddenMethod != null) {
        String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignatureErased())
            .toString(); // pr237419
        boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
        if (!alreadyHaveABridgeMethod) {
          if (world.forDEBUG_bridgingCode) {
            System.err.println("Bridging:bridging to '" + overriddenMethod + "'");
          }
          createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
          methodsSet.add(key);
          didSomething = true;
          continue; // look at the next method
        }
      }

      // Check superinterfaces
      String[] interfaces = clazz.getInterfaceNames();
      for (int j = 0; j < interfaces.length; j++) {
        if (world.forDEBUG_bridgingCode) {
          System.err.println("Bridging:checking superinterface " + interfaces[j]);
        }
        ResolvedType interfaceType = world.resolve(interfaces[j]);
        overriddenMethod = checkForOverride(interfaceType, name, psig, rsig, bridgeToCandidate.getAccessFlags(),
            clazz.getPackageName(), bm);
        if (overriddenMethod != null) {
          String key = new StringBuffer().append(overriddenMethod.getName())
              .append(overriddenMethod.getSignatureErased()).toString(); // pr
View Full Code Here

          NameValuePair object = iterator.next();
          Object o = object.getValue();
          if (o instanceof EnumElementValue) {
            EnumElementValue v = (EnumElementValue) object.getValue();
            String s = v.getEnumTypeString();
            ResolvedType rt = toType.getWorld().resolve(UnresolvedType.forSignature(s));
            if (rt.equals(toType)) {
              il.append(fact.createGetStatic(rt.getName(), v.getEnumValueString(), Type.getType(rt.getSignature())));
              doneAndDusted = true;
            }
          } else if (o instanceof SimpleElementValue) {
            // FIXASC types other than String will go bang bang at runtime
            SimpleElementValue v = (SimpleElementValue) object.getValue();
            il.append(fact.createConstant(v.getValueString()));
            doneAndDusted = true;
            // String s = v.getEnumTypeString();
            // ResolvedType rt = toType.getWorld().resolve(UnresolvedType.forSignature(s));
            // if (rt.equals(toType)) {
            // il.append(fact.createGetStatic(rt.getName(), v.getEnumValueString(), Type.getType(rt.getSignature())));
            // doneAndDusted = true;
            // }
          }
        }
        if (!doneAndDusted) {
          ResolvedMember[] annotationFields = toType.getWorld()
              .resolve(UnresolvedType.forSignature(annotation.getTypeSignature())).getDeclaredMethods();

          // ResolvedMember[] fs = rt.getDeclaredFields();
          for (int ii = 0; ii < annotationFields.length; ii++) {
            if (annotationFields[ii].getType().equals(annoFieldOfInterest)) {
              String dvalue = annotationFields[ii].getAnnotationDefaultValue();
              // form will be LBLAHBLAHBLAH;X where X is the field
              // within X
              String typename = dvalue.substring(0, dvalue.lastIndexOf(';') + 1);
              String field = dvalue.substring(dvalue.lastIndexOf(';') + 1);
              ResolvedType rt = toType.getWorld().resolve(UnresolvedType.forSignature(typename));
              il.append(fact.createGetStatic(rt.getName(), field, Type.getType(rt.getSignature())));
            }
          }
        }
      }
    }
View Full Code Here

      WeaverStateInfo info = weaver.getLazyClassGen().getOrCreateWeaverStateInfo(weaver.getReweavableMode());
      info.addConcreteMunger(this);
    }

    if (changed && worthReporting) {
      ResolvedType declaringAspect = null;
      AsmManager model = ((BcelWorld) getWorld()).getModelAsAsmManager();
      if (model != null) {
        if (munger instanceof NewParentTypeMunger) {
          NewParentTypeMunger nptMunger = (NewParentTypeMunger) munger;
          declaringAspect = nptMunger.getDeclaringType();
          if (declaringAspect.isParameterizedOrGenericType()) {
            declaringAspect = declaringAspect.getRawType();
          }
          ResolvedType thisAspect = getAspectType();
          AsmRelationshipProvider.addRelationship(model, weaver.getLazyClassGen().getType(), munger, thisAspect);

          // Add a relationship on the actual declaring aspect too
          if (!thisAspect.equals(declaringAspect)) {
            // Might be the case the declaring aspect is generic and thisAspect is parameterizing it. In that case
            // record the actual parameterizations

            ResolvedType target = weaver.getLazyClassGen().getType();
            ResolvedType newParent = nptMunger.getNewParent();
            IProgramElement thisAspectNode = model.getHierarchy().findElementForType(thisAspect.getPackageName(),
                thisAspect.getClassName());
            Map<String, List<String>> declareParentsMap = thisAspectNode.getDeclareParentsMap();
            if (declareParentsMap == null) {
              declareParentsMap = new HashMap<String, List<String>>();
              thisAspectNode.setDeclareParentsMap(declareParentsMap);
            }
            String tname = target.getName();
            String pname = newParent.getName();
            List<String> newparents = declareParentsMap.get(tname);
            if (newparents == null) {
              newparents = new ArrayList<String>();
              declareParentsMap.put(tname, newparents);
            }
View Full Code Here

   * For a long time, AspectJ did not allow binary weaving of declare parents. This restriction is now lifted but could do with
   * more testing!
   */
  private boolean mungeNewParent(BcelClassWeaver weaver, NewParentTypeMunger typeTransformer) {
    LazyClassGen newParentTarget = weaver.getLazyClassGen();
    ResolvedType newParent = typeTransformer.getNewParent();

    boolean performChange = true;
    performChange = enforceDecpRule1_abstractMethodsImplemented(weaver, typeTransformer.getSourceLocation(), newParentTarget,
        newParent);
    performChange = enforceDecpRule2_cantExtendFinalClass(weaver, typeTransformer.getSourceLocation(), newParentTarget,
        newParent) && performChange;

    List<ResolvedMember> methods = newParent.getMethodsWithoutIterator(false, true, false);
    for (ResolvedMember method : methods) {
      if (!method.getName().equals("<init>")) {
        LazyMethodGen subMethod = findMatchingMethod(newParentTarget, method);
        // FIXME asc is this safe for all bridge methods?
        if (subMethod != null && !subMethod.isBridgeMethod()) {
          if (!(subMethod.isSynthetic() && method.isSynthetic())) {
            if (!(subMethod.isStatic() && subMethod.getName().startsWith("access$"))) {
              // ignore generated accessors
              performChange = enforceDecpRule3_visibilityChanges(weaver, newParent, method, subMethod)
                  && performChange;
              performChange = enforceDecpRule4_compatibleReturnTypes(weaver, method, subMethod) && performChange;
              performChange = enforceDecpRule5_cantChangeFromStaticToNonstatic(weaver,
                  typeTransformer.getSourceLocation(), method, subMethod)
                  && performChange;
            }
          }
        }
      }
    }
    if (!performChange) {
      // A rule was violated and an error message already reported
      return false;
    }

    if (newParent.isClass()) {
      // Changing the supertype
      if (!attemptToModifySuperCalls(weaver, newParentTarget, newParent)) {
        return false;
      }
      newParentTarget.setSuperClass(newParent);
View Full Code Here

              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(
View Full Code Here

    String subReturnTypeSig = subMethod.getGenericReturnTypeSignature();
    superReturnTypeSig = superReturnTypeSig.replace('.', '/');
    subReturnTypeSig = subReturnTypeSig.replace('.', '/');
    if (!superReturnTypeSig.equals(subReturnTypeSig)) {
      // Check for covariance
      ResolvedType subType = weaver.getWorld().resolve(subMethod.getReturnType());
      ResolvedType superType = weaver.getWorld().resolve(superMethod.getReturnType());
      if (!superType.isAssignableFrom(subType)) {
        weaver.getWorld()
            .getMessageHandler()
            .handleMessage(
                MessageUtil.error("The return type is incompatible with " + superMethod.getDeclaringType() + "."
                    + superMethod.getName() + superMethod.getParameterSignature(),
View Full Code Here

  /**
   * The main part of implementing declare parents extends. Modify super ctor calls to target the new type.
   */
  public boolean attemptToModifySuperCalls(BcelClassWeaver weaver, LazyClassGen newParentTarget, ResolvedType newParent) {
    ResolvedType currentParentType = newParentTarget.getSuperClass();
    if (currentParentType.getGenericType() != null) {
      currentParentType = currentParentType.getGenericType();
    }
    String currentParent = currentParentType.getName();
    if (newParent.getGenericType() != null) {
      newParent = newParent.getGenericType(); // target new super calls at
    }
    // the generic type if its raw or parameterized
    List<LazyMethodGen> mgs = newParentTarget.getMethodGens();
View Full Code Here

  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,
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ResolvedType$MethodGetterIncludingItds

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.