Package org.aspectj.apache.bcel.generic

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


      } else {
        if (canMatch(Shadow.FieldGet))
          matchGetInstruction(mg, ih, enclosingShadow, shadowAccumulator);
      }
    } else if (i instanceof InvokeInstruction) {
      InvokeInstruction ii = (InvokeInstruction) i;
      if (ii.getMethodName(clazz.getConstantPoolGen()).equals("<init>")) {
        if (canMatch(Shadow.ConstructorCall))
          match(
              BcelShadow.makeConstructorCall(world, mg, ih, enclosingShadow),
              shadowAccumulator);
      } else if (ii instanceof INVOKESPECIAL) {
        String onTypeName = ii.getClassName(cpg);
        if (onTypeName.equals(mg.getEnclosingClass().getName())) {
          // we are private
          matchInvokeInstruction(mg, ih, ii, enclosingShadow, shadowAccumulator);
        } else {
          // we are a super call, and this is not a join point in AspectJ-1.{0,1}
View Full Code Here


    {
        InstructionList body = enclosingMethod.getBody();
        // move the start past ajc$preClinit
        InstructionHandle clinitStart = body.getStart();
        if (clinitStart.getInstruction() instanceof InvokeInstruction) {
          InvokeInstruction ii = (InvokeInstruction)clinitStart.getInstruction();
      if (ii
        .getName(enclosingMethod.getEnclosingClass().getConstantPoolGen())
        .equals(NameMangler.AJC_PRE_CLINIT_NAME)) {
        clinitStart = clinitStart.getNext();
      }
        }
View Full Code Here

  }

  private Type[] getSuperConstructorParameterTypes() {
    // assert getKind() == PreInitialization 
    InstructionHandle superCallHandle = getRange().getEnd().getNext();
    InvokeInstruction superCallInstruction =
      (InvokeInstruction) superCallHandle.getInstruction();
    return superCallInstruction.getArgumentTypes(
      getEnclosingClass().getConstantPoolGen());
  }
View Full Code Here

            InstructionHandle next = curr.getNext();
            Instruction inst = curr.getInstruction();

            // open-up method call
            if ((inst instanceof InvokeInstruction)) {
                InvokeInstruction invoke = (InvokeInstruction) inst;
                ResolvedType callee = m_aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));

                // look in the whole method list and not just declared for super calls and alike
                List methods = callee.getMethodsWithoutIterator(false,true);
                for (Iterator iter = methods.iterator(); iter.hasNext();) {
                    ResolvedMember resolvedMember = (ResolvedMember) iter.next();
                    if (invoke.getName(cpg).equals(resolvedMember.getName())
                            && invoke.getSignature(cpg).equals(resolvedMember.getSignature())
                            && !resolvedMember.isPublic()) {
                        if ("<init>".equals(invoke.getName(cpg))) {
                            // skipping open up for private constructor
                            // can occur when aspect new a private inner type
                            // too complex to handle new + dup + .. + invokespecial here.
                            aroundAdvice.setCanInline(false);
                            realizedCannotInline = true;
                        } else {
                            // specific handling for super.foo() calls, where foo is non public
                            if (aspectType.getSuperclass() != null
                                    && aspectType.getSuperclass().getName().equals(callee.getName())) {
                                ResolvedMember accessor = createOrGetInlineAccessorForSuperDispatch(resolvedMember);
                                InvokeInstruction newInst = factory.createInvoke(
                                        aspectType.getName(),
                                        accessor.getName(),
                                        BcelWorld.makeBcelType(accessor.getReturnType()),
                                        BcelWorld.makeBcelTypes(accessor.getParameterTypes()),
                                        Constants.INVOKEVIRTUAL
                                );
                                curr.setInstruction(newInst);
                            } else {
                                ResolvedMember accessor = createOrGetInlineAccessorForMethod(resolvedMember);
                                InvokeInstruction newInst = factory.createInvoke(
                                        aspectType.getName(),
                                        accessor.getName(),
                                        BcelWorld.makeBcelType(accessor.getReturnType()),
                                        BcelWorld.makeBcelTypes(accessor.getParameterTypes()),
                                        Constants.INVOKESTATIC
                                );
                                curr.setInstruction(newInst);
                            }
                        }

                        break;//ok we found a matching callee member and swapped the instruction with the accessor
                    }
                }
            } else if (inst instanceof FieldInstruction) {
                FieldInstruction invoke = (FieldInstruction) inst;
                ResolvedType callee = m_aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));
                for (int i = 0; i < callee.getDeclaredJavaFields().length; i++) {
                    ResolvedMember resolvedMember = callee.getDeclaredJavaFields()[i];
                    if (invoke.getName(cpg).equals(resolvedMember.getName())
                            && invoke.getSignature(cpg).equals(resolvedMember.getSignature())
                            && !resolvedMember.isPublic()) {
                        final ResolvedMember accessor;
                        if ((inst instanceof GETFIELD) || (inst instanceof GETSTATIC)) {
                            accessor = createOrGetInlineAccessorForFieldGet(resolvedMember);
                        } else {
                            accessor = createOrGetInlineAccessorForFieldSet(resolvedMember);
                        }
                        InvokeInstruction newInst = factory.createInvoke(
                                aspectType.getName(),
                                accessor.getName(),
                                BcelWorld.makeBcelType(accessor.getReturnType()),
                                BcelWorld.makeBcelTypes(accessor.getParameterTypes()),
                                Constants.INVOKESTATIC
View Full Code Here

TOP

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

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.