Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.FieldGen


        parttwo.append(InstructionFactory.createStore(clazzType, slotForThis)); // ? should be the real type ? String or
        // something?
        parttwo.append(InstructionFactory.MONITORENTER);

        String fieldname = synchronizedMethod.getEnclosingClass().allocateField("class$");
        FieldGen f = new FieldGen(Modifier.STATIC | Modifier.PRIVATE, Type.getType(Class.class), fieldname,
            synchronizedMethod.getEnclosingClass().getConstantPool());
        synchronizedMethod.getEnclosingClass().addField(f, null);

        // 10: invokestatic #44; //Method
        // java/lang/Class.forName:(Ljava/lang/String;)Ljava/lang/Class;
View Full Code Here


      }

      // Do we need to calculate an SUID and add it?
      if (!getType().isInterface() && !hasSerialVersionUIDField && world.isAddSerialVerUID()) {
        calculatedSerialVersionUID = myGen.getSUID();
        FieldGen fg = new FieldGen(Constants.ACC_PRIVATE | Constants.ACC_FINAL | Constants.ACC_STATIC, BasicType.LONG,
            "serialVersionUID", getConstantPool());
        addField(fg);
        hasSerialVersionUIDField = true;
        serialVersionUIDRequiresInitialization = true;
        // warn about what we've done?
View Full Code Here

            // System.out.println("tjp counter starting at " + tjpFieldsCounter);
          }
        }
      }
    }
    FieldGen fGen = new FieldGen(modifiers, jpType, "ajc$tjp_" + tjpFieldsCounter++, getConstantPool());
    addField(fGen);
    tjpField = fGen.getField();
    tjpFields.put(shadow, tjpField);
    return tjpField;
  }
View Full Code Here

    if (field == null) {
      // private static Annotation ajc$anno$<nnn>
      StringBuilder sb = new StringBuilder();
      sb.append(NameMangler.ANNOTATION_CACHE_FIELD_NAME);
      sb.append(annoFieldsCounter++);
      FieldGen annotationCacheField = new FieldGen(Modifier.PRIVATE | Modifier.STATIC, typeForAnnotation, sb.toString(), cp);
      addField(annotationCacheField);
      field = annotationCacheField.getField();
      annotationCachingFieldCache.put(cacheKey, field);
    }
    return field;
  }
View Full Code Here

    if (!gen.getType().equals(cflowCounterField.getDeclaringType()))
      return false;

    // Create the field declaration.
    // Something like: "public static final CflowCounter ajc$cflowCounter$0;"
    FieldGen f = new FieldGen(cflowCounterField.getModifiers(), BcelWorld.makeBcelType(cflowCounterField.getReturnType()),
        cflowCounterField.getName(), gen.getConstantPool());

    gen.addField(f, getSourceLocation());

    // Modify the ajc$preClinit() method to initialize it.
View Full Code Here

      for (Definition.DeclareErrorOrWarning deow : concreteAspect.deows) {
        // Building this:
        // @DeclareWarning("call(* javax.sql..*(..)) && !within(org.xyz.daos..*)")
        // static final String aMessage = "Only DAOs should be calling JDBC.";

        FieldGen field = new FieldGen(Modifier.FINAL, ObjectType.STRING, "rule" + (counter++), cg.getConstantPool());
        SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), deow.pointcut);
        List<NameValuePair> elems = new ArrayList<NameValuePair>();
        elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
        AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Declare"
            + (deow.isError ? "Error" : "Warning")), elems, true, cg.getConstantPool());
        field.addAnnotation(mag);

        field.setValue(deow.message);
        cg.addField(field, null);
      }
    }

    if (concreteAspect.pointcutsAndAdvice.size() > 0) {
View Full Code Here

    // ret.makeSynthetic();
    return ret;
  }

  protected FieldGen makeFieldGen(LazyClassGen gen, ResolvedMember member) {
    return new FieldGen(member.getModifiers(), BcelWorld.makeBcelType(member.getReturnType()), member.getName(),
        gen.getConstantPool());
  }
View Full Code Here

    // System.err.println("Munging perobject ["+munger+"] onto "+weaver.
    // getLazyClassGen().getClassName());
    LazyClassGen gen = weaver.getLazyClassGen();

    if (couldMatch(gen.getBcelObjectType(), munger.getTestPointcut())) {
      FieldGen fg = makeFieldGen(gen, AjcMemberMaker.perObjectField(gen.getType(), aspectType));

      gen.addField(fg, getSourceLocation());

      Type fieldType = BcelWorld.makeBcelType(aspectType);
      LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, fieldType, NameMangler.perObjectInterfaceGet(aspectType),
          new Type[0], new String[0], gen);
      InstructionList il = new InstructionList();
      InstructionFactory fact = gen.getFactory();
      il.append(InstructionConstants.ALOAD_0);
      il.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.GETFIELD));
      il.append(InstructionFactory.createReturn(fieldType));
      mg.getBody().insert(il);

      gen.addMethodGen(mg);

      LazyMethodGen mg1 = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, NameMangler.perObjectInterfaceSet(aspectType),

      new Type[] { fieldType, }, new String[0], gen);
      InstructionList il1 = new InstructionList();
      il1.append(InstructionConstants.ALOAD_0);
      il1.append(InstructionFactory.createLoad(fieldType, 1));
      il1.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.PUTFIELD));
      il1.append(InstructionFactory.createReturn(Type.VOID));
      mg1.getBody().insert(il1);

      gen.addMethodGen(mg1);
View Full Code Here

    // if (couldMatch(gen.getBcelObjectType(), munger.getTestPointcut())) {

    // Add (to the target type) the field that will hold the aspect instance
    // e.g ajc$com_blah_SecurityAspect$ptwAspectInstance
    FieldGen fg = makeFieldGen(gen, AjcMemberMaker.perTypeWithinField(gen.getType(), aspectType));
    gen.addField(fg, getSourceLocation());

    // Add an accessor for this new field, the
    // ajc$<aspectname>$localAspectOf() method
    // e.g.
    // "public com_blah_SecurityAspect ajc$com_blah_SecurityAspect$localAspectOf()"
    Type fieldType = BcelWorld.makeBcelType(aspectType);
    LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC | Modifier.STATIC, fieldType,
        NameMangler.perTypeWithinLocalAspectOf(aspectType), new Type[0], new String[0], gen);
    InstructionList il = new InstructionList();
    // PTWIMPL ?? Should check if it is null and throw
    // NoAspectBoundException
    InstructionFactory fact = gen.getFactory();
    il.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.GETSTATIC));
    il.append(InstructionFactory.createReturn(fieldType));
    mg.getBody().insert(il);
    gen.addMethodGen(mg);
    return true;
    // } else {
View Full Code Here

    munger.matches(weaver.getLazyClassGen().getType(), aspectType); // why
    // do
    // this?
    ResolvedMember host = AjcMemberMaker.itdAtDeclareParentsField(weaver.getLazyClassGen().getType(), munger.getSignature()
        .getType(), aspectType);
    FieldGen field = makeFieldGen(weaver.getLazyClassGen(), host);
    field.setModifiers(field.getModifiers() | BcelField.AccSynthetic);
    weaver.getLazyClassGen().addField(field, null);
    return true;
  }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.FieldGen

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.