Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.Type$TypeHolder


      frameEnv.put(donorFramePos, targetSlot);
      donorFramePos += 1;
    }
    Type[] argTypes = donor.getArgumentTypes();
    for (int i = 0, len = argTypes.length; i < len; i++) {
      Type argType = argTypes[i];
      int argSlot = recipient.allocateLocal(argType);
      ret.insert(InstructionFactory.createStore(argType, argSlot));
      frameEnv.put(donorFramePos, argSlot);
      donorFramePos += argType.getSize();
    }
    return ret;
  }
View Full Code Here


    ResolvedMember accessMethod)
  {
    LazyMethodGen mg = makeMethodGen(gen, accessMethod);
    InstructionList il = new InstructionList();
    InstructionFactory fact = gen.getFactory();
    Type fieldType = BcelWorld.makeBcelType(field.getType());
   
    if (field.isStatic()) {
      il.append(InstructionFactory.createLoad(fieldType, 0));
      il.append(fact.createFieldAccess(
        gen.getClassName(),
View Full Code Here

    if (!method.isStatic()) {
      il.append(InstructionConstants.ALOAD_0);
      pos++;
    }
    for (int i = 0, len = paramTypes.length; i < len; i++) {
      Type paramType = paramTypes[i];
      il.append(InstructionFactory.createLoad(paramType, pos));
      pos+=paramType.getSize();
    }
    il.append(Utility.createInvoke(fact, (BcelWorld)aspectType.getWorld(),
        method));
    il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(method.getReturnType())));
View Full Code Here

        AjcMemberMaker.perObjectField(gen.getType(), aspectType));

        gen.addField(fg.getField(),getSourceLocation());
       
       
        Type fieldType = BcelWorld.makeBcelType(aspectType);
      LazyMethodGen mg = new LazyMethodGen(
        Modifier.PUBLIC,
        fieldType,
          NameMangler.perObjectInterfaceGet(aspectType),
        new Type[0], new String[0],
View Full Code Here

      FieldGen fg = makeFieldGen(gen, AjcMemberMaker.perTypeWithinField(gen.getType(), aspectType));
        gen.addField(fg.getField(),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();
View Full Code Here

          body.append(InstructionFactory.createThis());
          pos++;
        }
        Type[] paramTypes = BcelWorld.makeBcelTypes(mangledInterMethod.getParameterTypes());
        for (int i = 0, len = paramTypes.length; i < len; i++) {
          Type paramType = paramTypes[i];
          body.append(InstructionFactory.createLoad(paramType, pos));
          pos+=paramType.getSize();
        }
        body.append(Utility.createInvoke(fact, weaver.getWorld(), interMethodBody));
        body.append(
          InstructionFactory.createReturn(
            BcelWorld.makeBcelType(mangledInterMethod.getReturnType())));
       
        if (weaver.getWorld().isInJava5Mode()) { // Don't need bridge methods if not in 1.5 mode.
          createAnyBridgeMethodsForCovariance(weaver, munger, unMangledInterMethod, onType, gen, paramTypes);
        }
       
      } else {
        //??? this is okay
        //if (!(mg.getBody() == null)) throw new RuntimeException("bas");
      }
     

      // XXX make sure to check that we set exceptions properly on this guy.
      weaver.addLazyMethodGen(newMethod);
      weaver.getLazyClassGen().warnOnAddedMethod(newMethod.getMethod(),getSignature().getSourceLocation());
     
      addNeededSuperCallMethods(weaver, onType, munger.getSuperMethodsCalled());
     
        return true;
       
    } else if (onInterface && !Modifier.isAbstract(unMangledInterMethod.getModifiers())) {
     
      // This means the 'gen' should be the top most implementor
      // - if it is *not* then something went wrong after we worked
      // out that it was the top most implementor (see pr49657)
        if (!gen.getType().isTopmostImplementor(onType)) {
          ResolvedType rtx = gen.getType().getTopmostImplementor(onType);
          if (!rtx.isExposedToWeaver()) {
            ISourceLocation sLoc = munger.getSourceLocation();
              weaver.getWorld().getMessageHandler().handleMessage(MessageUtil.error(
                  WeaverMessages.format(WeaverMessages.ITD_NON_EXPOSED_IMPLEMENTOR,rtx,getAspectType().getName()),
              (sLoc==null?getAspectType().getSourceLocation():sLoc)));
          } else {
            // XXX what does this state mean?
            // We have incorrectly identified what is the top most implementor and its not because
            // a type wasn't exposed to the weaver
          }
        return false;
        } else {
   
        ResolvedMember mangledInterMethod =
          AjcMemberMaker.interMethod(unMangledInterMethod, aspectType, false);
   
        LazyMethodGen mg = makeMethodGen(gen, mangledInterMethod);
        if (mungingInterface) {
        // we want the modifiers of the ITD to be used for all *implementors* of the
        // interface, but the method itself we add to the interface must be public abstract
        mg.setAccessFlags(Modifier.PUBLIC | Modifier.ABSTRACT);
        }
           
        Type[] paramTypes = BcelWorld.makeBcelTypes(mangledInterMethod.getParameterTypes());
        Type returnType = BcelWorld.makeBcelType(mangledInterMethod.getReturnType());
     
        InstructionList body = mg.getBody();
        InstructionFactory fact = gen.getFactory();
        int pos = 0;

        if (!mangledInterMethod.isStatic()) {
        body.append(InstructionFactory.createThis());
        pos++;
        }
        for (int i = 0, len = paramTypes.length; i < len; i++) {
        Type paramType = paramTypes[i];
        body.append(InstructionFactory.createLoad(paramType, pos));
        pos+=paramType.getSize();
        }
      
        body.append(Utility.createInvoke(fact, weaver.getWorld(), interMethodBody));
        Type t= BcelWorld.makeBcelType(interMethodBody.getReturnType());
        if (!t.equals(returnType)) {
          body.append(fact.createCast(t,returnType));
        }
        body.append(InstructionFactory.createReturn(returnType));
        mg.definingType = onType;
     
        weaver.addOrReplaceLazyMethodGen(mg);
     
        addNeededSuperCallMethods(weaver, onType, munger.getSuperMethodsCalled());

        // Work out if we need a bridge method for the new method added to the topmostimplementor.
        if (munger.getDeclaredSignature()!=null) { // Check if the munger being processed is a parameterized form of some original munger.
        boolean needsbridging = false;
          ResolvedMember toBridgeTo = munger.getDeclaredSignature().parameterizedWith(null,munger.getSignature().getDeclaringType().resolve(getWorld()),false,munger.getTypeVariableAliases());
        if (!toBridgeTo.getReturnType().getErasureSignature().equals(munger.getSignature().getReturnType().getErasureSignature())) needsbridging = true;
        UnresolvedType[] originalParams = toBridgeTo.getParameterTypes();
        UnresolvedType[] newParams = munger.getSignature().getParameterTypes();
        for (int ii = 0;ii<originalParams.length;ii++) {
          if (!originalParams[ii].getErasureSignature().equals(newParams[ii].getErasureSignature())) needsbridging=true;
        }
        if (toBridgeTo!=null && needsbridging) {
          ResolvedMember bridgerMethod = AjcMemberMaker.bridgerToInterMethod(unMangledInterMethod,gen.getType());
          ResolvedMember bridgingSetter = AjcMemberMaker.interMethod(toBridgeTo, aspectType, false);
         
          // FIXME asc ----------------8<---------------- extract method
          LazyMethodGen bridgeMethod = makeMethodGen(gen,bridgingSetter)
          paramTypes = BcelWorld.makeBcelTypes(bridgingSetter.getParameterTypes());
          Type[] bridgingToParms = BcelWorld.makeBcelTypes(unMangledInterMethod.getParameterTypes());
          returnType   = BcelWorld.makeBcelType(bridgingSetter.getReturnType());
          body = bridgeMethod.getBody();
          fact = gen.getFactory();
          pos = 0;

            if (!bridgingSetter.isStatic()) {
            body.append(InstructionFactory.createThis());
            pos++;
            }
            for (int i = 0, len = paramTypes.length; i < len; i++) {
             Type paramType = paramTypes[i];
            body.append(InstructionFactory.createLoad(paramType, pos));
            if (!bridgingSetter.getParameterTypes()[i].getErasureSignature().equals(unMangledInterMethod.getParameterTypes()[i].getErasureSignature()) ) {
//            System.err.println("Putting in cast from "+paramType+" to "+bridgingToParms[i]);
            body.append(fact.createCast(paramType,bridgingToParms[i]));
            }
            pos+=paramType.getSize();
            }
        
            body.append(Utility.createInvoke(fact, weaver.getWorld(), bridgerMethod));
            body.append(InstructionFactory.createReturn(returnType));
            gen.addMethodGen(bridgeMethod);
View Full Code Here

    int pos = 0;
   
    LazyMethodGen bridgeMethod = makeMethodGen(clazz,theBridgeMethod); // The bridge method in this type will have the same signature as the one in the supertype
    bridgeMethod.setAccessFlags(bridgeMethod.getAccessFlags() | 0x00000040 /*BRIDGE    = 0x00000040*/ );
    UnresolvedType[] newParams = munger.getSignature().getParameterTypes();
    Type returnType   = BcelWorld.makeBcelType(theBridgeMethod.getReturnType());
    body = bridgeMethod.getBody();
    fact = clazz.getFactory();

    if (!unMangledInterMethod.isStatic()) {
       body.append(InstructionFactory.createThis());
       pos++;
    }
    for (int i = 0, len = paramTypes.length; i < len; i++) {
      Type paramType = paramTypes[i];
      body.append(InstructionFactory.createLoad(paramType, pos));
//          if (!bridgingSetter.getParameterTypes()[i].getErasureSignature().equals(unMangledInterMethod.getParameterTypes()[i].getErasureSignature())) {
//            System.err.println("Putting in cast from "+paramType+" to "+bridgingToParms[i]);
//            body.append(fact.createCast(paramType,bridgingToParms[i]));
//          }
      pos+=paramType.getSize();
    }

    body.append(Utility.createInvoke(fact, world,unMangledInterMethod));
    body.append(InstructionFactory.createReturn(returnType));
    clazz.addMethodGen(bridgeMethod);
View Full Code Here

          //body.append(InstructionFactory.createThis());
          pos++;
        }
            Type[] paramTypes = BcelWorld.makeBcelTypes(introduced.getParameterTypes());
            for (int i = 0, len = paramTypes.length; i < len; i++) {
                Type paramType = paramTypes[i];
                body.append(InstructionFactory.createLoad(paramType, pos));
                pos+=paramType.getSize();
            }
            body.append(Utility.createInvoke(fact, Constants.INVOKEINTERFACE, introduced));
            body.append(
                InstructionFactory.createReturn(
                    BcelWorld.makeBcelType(introduced.getReturnType())
View Full Code Here

    ResolvedMember superMethod,
    BcelWorld world,
    boolean isSuper)
  {
    Type[] paramTypes = BcelWorld.makeBcelTypes(superMethod.getParameterTypes());
    Type returnType = BcelWorld.makeBcelType(superMethod.getReturnType());
       
    int modifiers = Modifier.PUBLIC;
    if (onGen.isInterface()) modifiers |= Modifier.ABSTRACT;
       
    LazyMethodGen mg =
        new LazyMethodGen(
          modifiers,
          returnType,
          dispatchName,
          paramTypes,
          UnresolvedType.getNames(superMethod.getExceptions()),
          onGen);
    InstructionList body = mg.getBody();
   
    if (onGen.isInterface()) return mg;
   
    // assert (!superMethod.isStatic())
    InstructionFactory fact = onGen.getFactory();
    int pos = 0;
   
    body.append(InstructionFactory.createThis());
    pos++;
    for (int i = 0, len = paramTypes.length; i < len; i++) {
      Type paramType = paramTypes[i];
      body.append(InstructionFactory.createLoad(paramType, pos));
      pos+=paramType.getSize();
    }
    if (isSuper) {
      body.append(Utility.createSuperInvoke(fact, world, superMethod));
    } else {
      body.append(Utility.createInvoke(fact, world, superMethod));
View Full Code Here

      if (field.isStatic()) throw new RuntimeException("unimplemented");
      weaver.addInitializer(this);
      //System.err.println("impl body on " + gen.getType() + " for " + munger);
     
     
      Type fieldType =   BcelWorld.makeBcelType(field.getType());
       
      FieldGen fg = makeFieldGen(gen,AjcMemberMaker.interFieldInterfaceField(field, onType, aspectType));
         
        if (annotationsOnRealMember!=null) {
          for (int i = 0; i < annotationsOnRealMember.length; i++) {
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.Type$TypeHolder

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.