Package org.aspectj.apache.bcel.generic

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


                // Build the initial frame situation for this method.
                Frame f = new Frame(mg.getMaxLocals(), mg.getMaxStack());
                if (!mg.isStatic()) {
                    if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)) {
                        Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
                        f.getLocals().set(0, Frame._this);
                    } else {
                        Frame._this = null;
                        f.getLocals().set(0, new ObjectType(jc.getClassName()));
                    }
                }
                Type[] argtypes = mg.getArgumentTypes();
                int twoslotoffset = 0;
                for (int j = 0; j < argtypes.length; j++) {
View Full Code Here


    Type jlClass = BcelWorld.makeBcelType(UnresolvedType.JL_CLASS);
    Type jlString = BcelWorld.makeBcelType(UnresolvedType.JL_STRING);
    Type jlClassArray = BcelWorld.makeBcelType(UnresolvedType.JAVA_LANG_CLASS_ARRAY);
    Type jlaAnnotation = BcelWorld.makeBcelType(UnresolvedType.JAVA_LANG_ANNOTATION);

    Instruction pushConstant = fact.createConstant(new ObjectType(toType.getName()));

    if (kind == Shadow.MethodCall || kind == Shadow.MethodExecution || kind == Shadow.PreInitialization
        || kind == Shadow.Initialization || kind == Shadow.ConstructorCall || kind == Shadow.ConstructorExecution
        || kind == Shadow.AdviceExecution ||
        // annotations for fieldset/fieldget when an ITD is involved are stored against a METHOD
View Full Code Here

    for (int i = 0; i < arrayEntries.length; i++) {
      il.append(InstructionFactory.createDup(1));
      il.append(fact.createConstant(Integer.valueOf(i)));
      switch (arrayEntries[i].getType()) {
      case Constants.T_ARRAY:
        il.append(fact.createConstant(new ObjectType(arrayEntries[i].getSignature()))); // FIXME should be getName() and not
        // getSignature()?
        break;
      case Constants.T_BOOLEAN:
        il.append(fact.createGetStatic("java/lang/Boolean", "TYPE", arrayElementType));
        break;
View Full Code Here

        + Constants.ACC_SUPER, EMPTY_STRINGS, world);
    if (parent != null && parent.isParameterizedType()) {
      cg.setSuperClass(parent);
    }
    if (perclauseString == null) {
      AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"), Collections.EMPTY_LIST,
          true, cg.getConstantPool());
      cg.addAnnotation(ag);
    } else {
      // List elems = new ArrayList();
      List elems = new ArrayList();
      elems.add(new NameValuePair("value",
          new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), perclauseString), cg.getConstantPool()));
      AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"), elems, true, cg
          .getConstantPool());
      cg.addAnnotation(ag);
    }
    if (concreteAspect.precedence != null) {
      SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), concreteAspect.precedence);
      List elems = new ArrayList();
      elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
      AnnotationGen agprec = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/DeclarePrecedence"), elems, true,
          cg.getConstantPool());
      cg.addAnnotation(agprec);
    }

    // default constructor
    LazyMethodGen init = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, "<init>", EMPTY_TYPES, EMPTY_STRINGS, cg);
    InstructionList cbody = init.getBody();
    cbody.append(InstructionConstants.ALOAD_0);

    cbody.append(cg.getFactory().createInvoke(parentName, "<init>", Type.VOID, EMPTY_TYPES, Constants.INVOKESPECIAL));
    cbody.append(InstructionConstants.RETURN);
    cg.addMethodGen(init);

    for (Iterator it = concreteAspect.pointcuts.iterator(); it.hasNext();) {
      Definition.Pointcut abstractPc = (Definition.Pointcut) it.next();
      // TODO AV - respect visibility instead of opening up as public?
      LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, EMPTY_TYPES, EMPTY_STRINGS, cg);
      SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression);
      List elems = new ArrayList();
      elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
      AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Pointcut"), elems, true, cg
          .getConstantPool());
      AnnotationAJ max = new BcelAnnotation(mag, world);
      mg.addAnnotation(max);

      InstructionList body = mg.getBody();
      body.append(InstructionConstants.RETURN);
      cg.addMethodGen(mg);
    }

    if (concreteAspect.deows.size() > 0) {

      int counter = 1;
      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 elems = new ArrayList();
        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);
View Full Code Here

    // I will now jump through some firey BCEL hoops to generate a trivial bit of code:
    // if (exc instanceof ExceptionInInitializerError)
    // throw (ExceptionInInitializerError)exc;
    if (this.getEnclosingMethod().getName().equals("<clinit>")) {
      ResolvedType eiieType = world.resolve("java.lang.ExceptionInInitializerError");
      ObjectType eiieBcelType = (ObjectType) BcelWorld.makeBcelType(eiieType);
      InstructionList ih = new InstructionList(InstructionConstants.NOP);
      handler.append(exceptionVar.createLoad(fact));
      handler.append(fact.createInstanceOf(eiieBcelType));
      InstructionBranch bi = InstructionFactory.createBranchInstruction(Constants.IFEQ, ih.getStart());
      handler.append(bi);
View Full Code Here

    // ENH 42737
    exceptionVar.appendStore(rtExHandler, fact);
    // aload_1
    rtExHandler.append(exceptionVar.createLoad(fact));
    // instanceof class java/lang/RuntimeException
    rtExHandler.append(fact.createInstanceOf(new ObjectType("java.lang.RuntimeException")));
    // ifeq go to new SOFT_EXCEPTION_TYPE instruction
    rtExHandler.append(InstructionFactory.createBranchInstruction(Constants.IFEQ, handler.getStart()));
    // aload_1
    rtExHandler.append(exceptionVar.createLoad(fact));
    // athrow
View Full Code Here

    String aspectname = munger.getConcreteAspect().getName();

    String ptwField = NameMangler.perTypeWithinFieldForTarget(munger.getConcreteAspect());
    entrySuccessInstructions.append(InstructionFactory.PUSH(fact.getConstantPool(), t.getName()));

    entrySuccessInstructions.append(fact.createInvoke(aspectname, "ajc$createAspectInstance", new ObjectType(aspectname),
        new Type[] { new ObjectType("java.lang.String") }, Constants.INVOKESTATIC));
    entrySuccessInstructions.append(fact.createPutStatic(t.getName(), ptwField, new ObjectType(aspectname)));

    entryInstructions.append(entrySuccessInstructions);

    range.insert(entryInstructions, Range.InsideBefore);
  }
View Full Code Here

    if (thisJoinPointVar != null) {
      arrayVar.appendConvertableArrayStore(il, fact, stateIndex, thisJoinPointVar);
      thisJoinPointVar.setPositionInAroundState(stateIndex);
      stateIndex++;
    }
    il.append(fact.createNew(new ObjectType(constructor.getDeclaringType().getName())));
    il.append(InstructionConstants.DUP);
    arrayVar.appendLoad(il, fact);
    il.append(Utility.createInvoke(fact, world, constructor));
    if (getKind() == PreInitialization) {
      il.append(InstructionConstants.DUP);
View Full Code Here

      retval = MemberImpl.method(ut, Modifier.PUBLIC, ResolvedType.VOID, "<init>", new ResolvedType[] { ResolvedType.INT });
    } else if (i instanceof MULTIANEWARRAY) {
      MULTIANEWARRAY arrayInstruction = (MULTIANEWARRAY) i;
      UnresolvedType ut = null;
      short dimensions = arrayInstruction.getDimensions();
      ObjectType ot = arrayInstruction.getLoadClassType(cpg);
      if (ot != null) {
        ut = fromBcel(ot);
        ut = UnresolvedType.makeArray(ut, dimensions);
      } else {
        Type t = arrayInstruction.getType(cpg);
View Full Code Here

    Member getClass = MemberImpl.method(UnresolvedType.OBJECT, 0, UnresolvedType.JL_CLASS, "getClass",
        UnresolvedType.NONE);
    il.append(Utility.createInvoke(fact, world, getClass));
    // aload annotationClass
    il.append(fact.createConstant(new ObjectType(hasAnnotation.getAnnotationType().getName())));
    // int annClassIndex = fact.getConstantPool().addClass(hasAnnotation.getAnnotationType().getSignature());
    // il.append(new LDC_W(annClassIndex));
    Member isAnnotationPresent = MemberImpl.method(UnresolvedType.JL_CLASS, 0, ResolvedType.BOOLEAN,
        "isAnnotationPresent", new UnresolvedType[] { UnresolvedType.JL_CLASS });
    il.append(Utility.createInvoke(fact, world, isAnnotationPresent));
View Full Code Here

TOP

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

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.