Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.Field


      addAttribute(new ConstantValue(cp.addUtf8("ConstantValue"), 2, index, cp));
    }

    addAnnotationsAsAttribute(cp);

    return new Field(modifiers, nameIndex, signatureIndex, getAttributesImmutable(), cp);
  }
View Full Code Here


   * @param isEnclosingJp true to have the enclosingJpStaticPart
   * @return
   */
  public BcelVar getThisJoinPointStaticPartBcelVar(final boolean isEnclosingJp) {
    if (thisJoinPointStaticPartVar == null) {
      Field field = getEnclosingClass().getTjpField(this, isEnclosingJp);
      ResolvedType sjpType = null;
      if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We didn't have different jpsp types in 1.2
        sjpType = world.getCoreType(UnresolvedType.JOINPOINT_STATICPART);
      } else {
        sjpType = isEnclosingJp ? world.getCoreType(UnresolvedType.JOINPOINT_ENCLOSINGSTATICPART) : world
            .getCoreType(UnresolvedType.JOINPOINT_STATICPART);
      }
      thisJoinPointStaticPartVar = new BcelFieldRef(sjpType, getEnclosingClass().getClassName(), field.getName());
      // getEnclosingClass().warnOnAddedStaticInitializer(this,munger.getSourceLocation());
    }
    return thisJoinPointStaticPartVar;
  }
View Full Code Here

          // annotations for fieldset/fieldget when an ITD is involved are stored against a METHOD
          ((kind == Shadow.FieldGet || kind == Shadow.FieldSet) && member.getKind() == Member.METHOD)
          || ((kind == Shadow.ConstructorCall || kind == Shadow.ConstructorExecution) && member.getKind() == Member.METHOD)) {

        // Need to look at the cached annotation before going to fetch it again
        Field annotationCachingField = shadow.getEnclosingClass().getAnnotationCachingField(shadow, toType);

        // Basic idea here is to check if the cached field is null, if it is then initialize it, otherwise use it
        il.append(fact
            .createGetStatic(shadow.getEnclosingClass().getName(), annotationCachingField.getName(), jlAnnotation));
        il.append(InstructionConstants.DUP);
        InstructionBranch ifNonNull = InstructionFactory.createBranchInstruction(Constants.IFNONNULL, null);
        il.append(ifNonNull);
        il.append(InstructionConstants.POP);
        il.append(fact.createConstant(BcelWorld.makeBcelType(containingType)));

        il.append(fact.createConstant(member.getName()));
        buildArray(il, fact, jlClass, paramTypes, 1);
        // OPTIMIZE cache result of getDeclaredMethod?
        il.append(fact.createInvoke("java/lang/Class", "getDeclaredMethod", jlrMethod,
            new Type[] { jlString, jlClassArray }, Constants.INVOKEVIRTUAL));
        il.append(pushConstant);// fact.createConstant(new ObjectType(toType.getName())));
        il.append(fact.createInvoke("java/lang/reflect/Method", "getAnnotation", jlaAnnotation, new Type[] { jlClass },
            Constants.INVOKEVIRTUAL));
        il.append(InstructionConstants.DUP);
        il.append(fact
            .createPutStatic(shadow.getEnclosingClass().getName(), annotationCachingField.getName(), jlAnnotation));
        InstructionHandle ifNullElse = il.append(InstructionConstants.NOP);
        ifNonNull.setTarget(ifNullElse);

      } else { // init/preinit/ctor-call/ctor-exec
        il.append(fact.createConstant(BcelWorld.makeBcelType(containingType)));
View Full Code Here

    // code style declare error / warning / implements / parents are field
    // attributes
    Field[] fs = javaClass.getFields();
    for (int i = 0; i < fs.length; i++) {
      Field field = fs[i];
      if (field.getName().startsWith(NameMangler.PREFIX)) {
        continue; // already dealt with by ajc...
      }
      // FIXME alex optimize, this method struct will gets recreated for
      // advice extraction
      AjAttributeFieldStruct fstruct = new AjAttributeFieldStruct(field, null, type, context, msgHandler);
      Attribute[] fattributes = field.getAttributes();

      for (int j = 0; j < fattributes.length; j++) {
        Attribute fattribute = fattributes[j];
        if (acceptAttribute(fattribute)) {
          RuntimeAnnos frvs = (RuntimeAnnos) fattribute;
View Full Code Here

  // new ObjectType("org.aspectj.lang.reflect.SourceLocation");
  private static final ObjectType factoryType = new ObjectType("org.aspectj.runtime.reflect.Factory");
  private static final ObjectType classType = new ObjectType("java.lang.Class");

  public Field getTjpField(BcelShadow shadow, final boolean isEnclosingJp) {
    Field tjpField = tjpFields.get(shadow);
    if (tjpField != null) {
      return tjpField;
    }

    int modifiers = Modifier.STATIC | Modifier.FINAL;
View Full Code Here

   * @return a field
   */
  public Field getAnnotationCachingField(BcelShadow shadow, ResolvedType toType) {
    // Multiple annotation types at a shadow. A different field would be required for each
    CacheKey cacheKey = new CacheKey(shadow, toType);
    Field field = annotationCachingFieldCache.get(cacheKey);
    if (field == null) {
      // private static Annotation ajc$anno$<nnn>
      StringBuilder sb = new StringBuilder();
      sb.append(NameMangler.ANNOTATION_CACHE_FIELD_NAME);
      sb.append(annoFieldsCounter++);
View Full Code Here

  // new ObjectType("org.aspectj.lang.reflect.SourceLocation");
  private static final ObjectType factoryType = new ObjectType("org.aspectj.runtime.reflect.Factory");
  private static final ObjectType classType = new ObjectType("java.lang.Class");

  public Field getTjpField(BcelShadow shadow, final boolean isEnclosingJp) {
    Field tjpField = tjpFields.get(shadow);
    if (tjpField != null) {
      return tjpField;
    }

    int modifiers = Modifier.STATIC | Modifier.FINAL;
View Full Code Here

   * @return a field
   */
  public Field getAnnotationCachingField(BcelShadow shadow, ResolvedType toType, boolean isWithin) {
    // Multiple annotation types at a shadow. A different field would be required for each
    CacheKey cacheKey = new CacheKey(shadow, toType, isWithin);
    Field field = annotationCachingFieldCache.get(cacheKey);
    // System.out.println(field + " for shadow " + shadow);
    if (field == null) {
      // private static Annotation ajc$anno$<nnn>
      StringBuilder sb = new StringBuilder();
      sb.append(NameMangler.ANNOTATION_CACHE_FIELD_NAME);
View Full Code Here

      addAttribute(new ConstantValue(cp.addUtf8("ConstantValue"), 2, index, cp));
    }

    addAnnotationsAsAttribute(cp);

    return new Field(modifiers, nameIndex, signatureIndex, getAttributesImmutable(), cp);
  }
View Full Code Here

   * @param isEnclosingJp true to have the enclosingJpStaticPart
   * @return
   */
  public BcelVar getThisJoinPointStaticPartBcelVar(final boolean isEnclosingJp) {
    if (thisJoinPointStaticPartVar == null) {
      Field field = getEnclosingClass().getTjpField(this, isEnclosingJp);
      ResolvedType sjpType = null;
      if (world.isTargettingAspectJRuntime12()) { // TAG:SUPPORTING12: We didn't have different jpsp types in 1.2
        sjpType = world.getCoreType(UnresolvedType.JOINPOINT_STATICPART);
      } else {
        sjpType = isEnclosingJp ? world.getCoreType(UnresolvedType.JOINPOINT_ENCLOSINGSTATICPART) : world
            .getCoreType(UnresolvedType.JOINPOINT_STATICPART);
      }
      thisJoinPointStaticPartVar = new BcelFieldRef(sjpType, getEnclosingClass().getClassName(), field.getName());
      // getEnclosingClass().warnOnAddedStaticInitializer(this,munger.getSourceLocation());
    }
    return thisJoinPointStaticPartVar;
  }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.Field

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.