Package org.aspectj.weaver

Examples of org.aspectj.weaver.ReferenceType


        }
      }
    } else {
      UnresolvedType declaringType = this.getDeclaringType();
      if (declaringType instanceof ReferenceType) {
        ReferenceType referenceDeclaringType = (ReferenceType) declaringType;
        if (referenceDeclaringType.getDelegate() instanceof BcelObjectType) {
          // worth a look!
          ResolvedMember field = ((ResolvedType) declaringType).lookupField(this);
          if (field != null) {
            return field.getAnnotationOfType(ofType);
          }
View Full Code Here


      } else {
        // annotations may be accessible through the declaringClass if there is a bcel object behind it...
        cachedAnnotationTypes = ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY;
        UnresolvedType declaringType = this.getDeclaringType();
        if (declaringType instanceof ReferenceType) {
          ReferenceType referenceDeclaringType = (ReferenceType) declaringType;
          if (referenceDeclaringType.getDelegate() instanceof BcelObjectType) {
            // worth a look!
            if (this.getKind() == Member.METHOD) {
              ResolvedMember method = ((ResolvedType) declaringType).lookupMethod(this);
              if (method != null) {
                cachedAnnotationTypes = method.getAnnotationTypes();
View Full Code Here

        }
      }

      if (annotated.hasAnnotation(annotationType)) {
        if (annotationType instanceof ReferenceType) {
          ReferenceType rt = (ReferenceType) annotationType;
          if (rt.getRetentionPolicy() != null && rt.getRetentionPolicy().equals("SOURCE")) {
            rt.getWorld().getMessageHandler().handleMessage(
                MessageUtil.warn(WeaverMessages.format(WeaverMessages.NO_MATCH_BECAUSE_SOURCE_RETENTION,
                    annotationType, annotated), getSourceLocation()));
            return FuzzyBoolean.NO;
          }
        }
View Full Code Here

            // System.out.println("? addJarFile() filename='" + filename
            // + "'");
            UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);

            if (filename.endsWith(".class")) {
              ReferenceType type = this.addClassFile(classFile, false);
              StringBuffer sb = new StringBuffer();
              sb.append(inFile.getAbsolutePath());
              sb.append("!");
              sb.append(entry.getName());
              type.setBinaryPath(sb.toString());
              addedClassFiles.add(classFile);
            }
            // else if (!entry.isDirectory()) {
            //
            // /* bug-44190 Copy meta-data */
 
View Full Code Here

  /**
   * Should be addOrReplace
   */
  public ReferenceType addClassFile(UnwovenClassFile classFile, boolean fromInpath) {
    addedClasses.add(classFile);
    ReferenceType type = world.addSourceObjectType(classFile.getJavaClass(), false).getResolvedTypeX();
    if (fromInpath) {
      type.setBinaryPath(classFile.getFilename());
    }
    return type;
  }
View Full Code Here

      // "BCELWeaver: processing class from input directory "+classFile);
      StringBuffer sb = new StringBuffer();
      sb.append(inPathDir.getAbsolutePath());
      sb.append("!");
      sb.append(filename);
      ReferenceType type = this.addClassFile(ucf, false);
      type.setBinaryPath(sb.toString());
    }
    fis.close();
    return ucf;
  }
View Full Code Here

        if (dump) {
          dumpUnchanged(classFile);
        }
        return null;
      }
      ReferenceType resolvedClassType = classType.getResolvedTypeX();

      if (world.isXmlConfigured() && world.getXmlConfiguration().excludesType(resolvedClassType)) {
        if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
          world.getMessageHandler().handleMessage(
              MessageUtil.info("Type '" + resolvedClassType.getName()
                  + "' not woven due to exclusion via XML weaver exclude section"));

        }
        if (dump) {
          dumpUnchanged(classFile);
        }
        return null;
      }

      List<ShadowMunger> shadowMungers = fastMatch(shadowMungerList, resolvedClassType);
      List<ConcreteTypeMunger> typeMungers = classType.getResolvedTypeX().getInterTypeMungers();

      resolvedClassType.checkInterTypeMungers();

      // Decide if we need to do actual weaving for this class
      boolean mightNeedToWeave = shadowMungers.size() > 0 || typeMungers.size() > 0 || classType.isAspect()
          || world.getDeclareAnnotationOnMethods().size() > 0 || world.getDeclareAnnotationOnFields().size() > 0;

      // May need bridge methods if on 1.5 and something in our hierarchy is
      // affected by ITDs
      boolean mightNeedBridgeMethods = world.isInJava5Mode() && !classType.isInterface()
          && resolvedClassType.getInterTypeMungersIncludingSupers().size() > 0;

      LazyClassGen clazz = null;
      if (mightNeedToWeave || mightNeedBridgeMethods) {
        clazz = classType.getLazyClassGen();
        // System.err.println("got lazy gen: " + clazz + ", " +
View Full Code Here

    // }
    // }
    //
    if (annotated.hasAnnotation(annotationType)) {
      if (annotationType instanceof ReferenceType) {
        ReferenceType rt = (ReferenceType) annotationType;
        if (rt.getRetentionPolicy() != null && rt.getRetentionPolicy().equals("SOURCE")) {
          rt.getWorld().getMessageHandler().handleMessage(
              MessageUtil.warn(WeaverMessages.format(WeaverMessages.NO_MATCH_BECAUSE_SOURCE_RETENTION,
                  annotationType, annotated), getSourceLocation()));
          return FuzzyBoolean.NO;
        }
        ResolvedMember[] methods = rt.getDeclaredMethods();
        boolean found = false;
        for (int i = 0; i < methods.length && !found; i++) {
          if (methods[i].getReturnType().equals(formalType)) {
            found = true;
          }
View Full Code Here

              + "' is not (compiler limitation)");
    }
    bindingPattern = true;

    // Check that the formal is bound to a type that is represented by one field in the annotation type
    ReferenceType theAnnotationType = (ReferenceType) annotationType;
    ResolvedMember[] annotationFields = theAnnotationType.getDeclaredMethods();
    field = null;
    boolean looksAmbiguous = false;
    for (int i = 0; i < annotationFields.length; i++) {
      ResolvedMember resolvedMember = annotationFields[i];
      if (resolvedMember.getReturnType().equals(formalBinding.getType())) {
        if (field != null) {
          boolean haveProblem = true;
          // use the name to differentiate
          if (field.getName().equals(formalName)) {
            // don't use this new field
            haveProblem = false;
          } else if (resolvedMember.getName().equals(formalName)) {
            // ok, let's use this one
            field = resolvedMember;
            haveProblem = false;
          }
          if (haveProblem) {
            looksAmbiguous = true;
          }
        } else {
          field = resolvedMember;
        }
      }
    }
    if (looksAmbiguous) {
      // did we find something that does match by name?
      if (field == null || !field.getName().equals(formalName)) {
        scope.message(IMessage.ERROR, this, "The field type '" + formalBinding.getType()
            + "' is ambiguous for annotation type '" + theAnnotationType.getName() + "'");
      }
    }
    if (field == null) {
      scope.message(IMessage.ERROR, this, "No field of type '" + formalBinding.getType() + "' exists on annotation type '"
          + theAnnotationType.getName() + "'");
    }

    BindingAnnotationFieldTypePattern binding = new BindingAnnotationFieldTypePattern(formalBinding.getType(),
        formalBinding.getIndex(), theAnnotationType);
    binding.copyLocationFrom(this);
View Full Code Here

        adviceCounter++;
      }
    }

    // handle the perClause
    ReferenceType rt = new ReferenceType(ResolvedType.forName(concreteAspect.name).getSignature(), world);
    GeneratedReferenceTypeDelegate grtd = new GeneratedReferenceTypeDelegate(rt);
    grtd.setSuperclass(parent);
    rt.setDelegate(grtd);

    BcelPerClauseAspectAdder perClauseMunger = new BcelPerClauseAspectAdder(rt, perclauseKind);
    perClauseMunger.forceMunge(cg, false);

    // TODO AV - unsafe cast
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ReferenceType

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.