Package org.aspectj.apache.bcel.generic

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


    /**
     * Assures the generic preconditions of a LoadClass instance.
     * The referenced class is loaded and pass2-verified.
     */
    public void visitLoadClass(LoadClass o){
      ObjectType t = o.getLoadClassType(cpg);
      if (t != null){// null means "no class is loaded"
        Verifier v = VerifierFactory.getVerifier(t.getClassName());
        VerificationResult vr = v.doPass1();
        if (vr.getStatus() != VerificationResult.VERIFIED_OK){
          constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+"' is referenced, but cannot be loaded: '"+vr+"'.");
        }
      }
View Full Code Here


    LazyMethodGen clinit = gen.getAjcPreClinit(); //StaticInitializer();
    InstructionList setup = new InstructionList();
    InstructionFactory fact = gen.getFactory();

    setup.append(fact.createNew(new ObjectType(NameMangler.CFLOW_STACK_TYPE)));
    setup.append(InstructionFactory.createDup(1));
    setup.append(fact.createInvoke(
      NameMangler.CFLOW_STACK_TYPE,
      "<init>",
      Type.VOID,
View Full Code Here

      il.append(fact.createInvoke("java/lang/Class","getDeclaredMethod",jlrMethod,new Type[]{jlString,jlClassArray},Constants.INVOKEVIRTUAL));
      // FIXME asc perf Cache the result of getDeclaredMethod() and use it
          // again for other annotations on the same signature at this join point
          // Calls getAnnotation
          String ss = toType.getName();
          il.append(fact.createConstant(new ObjectType(toType.getName())));   
      il.append(fact.createInvoke("java/lang/reflect/Method","getAnnotation",jlaAnnotation,new Type[]{jlClass},Constants.INVOKEVIRTUAL));
      il.append(Utility.createConversion(fact,jlaAnnotation,BcelWorld.makeBcelType(toType)));
      } else { // init/preinit/ctor-call/ctor-exec
      Type[] paramTypes = BcelWorld.makeBcelTypes(member.getParameterTypes());
      buildArray(il,fact,jlClass,paramTypes,1);
      Type jlrCtor = BcelWorld.makeBcelType(UnresolvedType.forSignature("Ljava.lang.reflect.Constructor;"));
      il.append(fact.createInvoke("java/lang/Class","getDeclaredConstructor",jlrCtor,new Type[]{jlClassArray},Constants.INVOKEVIRTUAL));
   
      // !!! OPTIMIZATION: Cache the result of getDeclaredMethod() and use it
      // again for other annotations on the same signature at this join point
      // Calls getAnnotation
      String ss = toType.getName();
      il.append(fact.createConstant(new ObjectType(toType.getName())));   
      il.append(fact.createInvoke("java/lang/reflect/Constructor","getAnnotation",jlaAnnotation,new Type[]{jlClass},Constants.INVOKEVIRTUAL));
      il.append(Utility.createConversion(fact,jlaAnnotation,BcelWorld.makeBcelType(toType)));
      }
    } else if (kind == Shadow.FieldSet || kind == Shadow.FieldGet) {
      Type jlrField = BcelWorld.makeBcelType(UnresolvedType.forSignature("Ljava.lang.reflect.Field;"));
      il.append(fact.createConstant(BcelWorld.makeBcelType(containingType))); // Stick the target on the stack
      il.append(fact.createConstant(member.getName())); // Stick what we are after on the stack
      il.append(fact.createInvoke("java/lang/Class","getDeclaredField",jlrField,new Type[]{jlString},Constants.INVOKEVIRTUAL));
      String ss = toType.getName();
          il.append(fact.createConstant(new ObjectType(toType.getName())));   
      il.append(fact.createInvoke("java/lang/reflect/Field","getAnnotation",jlaAnnotation,new Type[]{jlClass},Constants.INVOKEVIRTUAL));
      il.append(Utility.createConversion(fact,jlaAnnotation,BcelWorld.makeBcelType(toType)));
    } else if (kind == Shadow.StaticInitialization || kind==Shadow.ExceptionHandler) {
      il.append(fact.createConstant(BcelWorld.makeBcelType(containingType)));
      String ss = toType.getName();
          il.append(fact.createConstant(new ObjectType(toType.getName())));   
      il.append(fact.createInvoke("java/lang/Class","getAnnotation",jlaAnnotation,new Type[]{jlClass},Constants.INVOKEVIRTUAL));
      il.append(Utility.createConversion(fact,jlaAnnotation,BcelWorld.makeBcelType(toType)));
    } else {
      throw new RuntimeException("Don't understand this kind "+kind);
    }
View Full Code Here

        for (int i = 0; i < arrayEntries.length; i++) {
      il.append(InstructionFactory.createDup(1));
      il.append(fact.createConstant(new Integer(i)));
          switch (arrayEntries[i].getType()) {
            case Constants.T_ARRAY:
              il.append(fact.createConstant(new ObjectType(arrayEntries[i].getSignature())));
              break;
            case Constants.T_BOOLEAN: il.append(fact.createGetStatic("java/lang/Boolean","TYPE",arrayElementType)); break;
            case Constants.T_BYTE:il.append(fact.createGetStatic("java/lang/Byte","TYPE",arrayElementType)); break;
            case Constants.T_CHAR:il.append(fact.createGetStatic("java/lang/Character","TYPE",arrayElementType)); break;
            case Constants.T_INT:il.append(fact.createGetStatic("java/lang/Integer","TYPE",arrayElementType)); break;
View Full Code Here

        // 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

        il.append(ifNotNull);
        il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
        il.append(InstructionConstants.DUP);
        il.append(new PUSH(classGen.getConstantPoolGen(), aspectType.getName()));
        il.append(Utility.createGet(factory, AjcMemberMaker.initFailureCauseField(aspectType)));
        il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, new Type[] { Type.STRING, new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL));
        il.append(InstructionConstants.ATHROW);
        InstructionHandle ifElse = il.append(Utility.createGet(factory, AjcMemberMaker.perSingletonField(aspectType)));
        il.append(InstructionFactory.createReturn(Type.OBJECT));
        ifNotNull.setTarget(ifElse);
    }
View Full Code Here

        }
        clinit.getBody().getEnd().setInstruction(new NOP());
        clinit.getBody().append(il);

        clinit.addExceptionHandler(
            tryStart, handler, handler, new ObjectType("java.lang.Throwable"), false
        );
    }
View Full Code Here

        il.append(ifNonNull);
        il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
        il.append(InstructionConstants.DUP);
        il.append(new PUSH(classGen.getConstantPoolGen(), aspectType.getName()));
        il.append(InstructionConstants.ACONST_NULL);
        il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, new Type[] { Type.STRING, new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL));
        il.append(InstructionConstants.ATHROW);
        InstructionHandle ifElse = il.append(InstructionConstants.ALOAD_1);
        ifNonNull.setTarget(ifElse);
        il.append(InstructionFactory.createReturn(Type.OBJECT));

        InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
        il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
        il.append(InstructionConstants.DUP);
        il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
        il.append(InstructionConstants.ATHROW);

        method.addExceptionHandler(
            tryStart, handler.getPrev(), handler, new ObjectType("java.lang.Exception"), false
        );
    }
View Full Code Here

        InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
        il.append(InstructionConstants.ICONST_0);
        il.append(InstructionConstants.IRETURN);

        method.addExceptionHandler(
            tryStart, handler.getPrev(), handler, new ObjectType("java.lang.Exception"), false
        );
    }
View Full Code Here

        InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
        il.append(InstructionConstants.ACONST_NULL);
        il.append(InstructionConstants.ARETURN);

        method.addExceptionHandler(
            tryStart, handler.getPrev(), handler, new ObjectType("java.lang.Exception"), false
        );
    }
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.