Examples of InvokeInstruction


Examples of org.apache.bcel.generic.InvokeInstruction

            Instruction exceptionThrower = instructionHandle.getInstruction();
            if (!(exceptionThrower instanceof InvokeInstruction)) {
                continue;
            }

            InvokeInstruction inv = (InvokeInstruction) exceptionThrower;
            boolean foundThrower = false;
            boolean foundNonThrower = false;
            boolean isExact = true;
            XMethod primaryXMethod = XFactory.createXMethod(inv, cpg);
            final String methodName = primaryXMethod.getName();
            final boolean matches = unconditionalThrowerPattern.matcher(methodName).matches();
            if (DEBUG) {
                System.out.println("Checking '" + methodName + "' is " + matches);
            }

            if (matches) {
                if (DEBUG) {
                    System.out.println("\tmatched for " + instructionHandle + " : " + primaryXMethod);
                }

                foundThrower = true;
            } else if (inv instanceof INVOKEINTERFACE) {
                continue;
            } else if (inv instanceof INVOKESTATIC) {
                foundThrower = isUnconditionalThrower(primaryXMethod);
            } else {
                String className = inv.getClassName(cpg);
                if (DEBUG) {
                    System.out.println("\tlooking up method for " + instructionHandle + " : " + primaryXMethod);
                }

                Location loc = new Location(instructionHandle, basicBlock);
                TypeFrame typeFrame = typeDataflow.getFactAtLocation(loc);
                // if (primaryXMethod.isAbstract()) continue;
                Set<XMethod> targetSet = null;
                try {

                    if (className.startsWith("[")) {
                        continue;
                    }
                    String methodSig = inv.getSignature(cpg);
                    if (!methodSig.endsWith("V") && !methodSig.endsWith("Exception;")
                            && !methodSig.endsWith("Error;") && !methodSig.endsWith(")Ljava/lang/Object;")) {
                        continue;
                    }
View Full Code Here

Examples of org.apache.bcel.generic.InvokeInstruction

            while (j.hasNext()) {
                InstructionHandle handle = j.next();

                Instruction ins = handle.getInstruction();
                if (ins instanceof InvokeInstruction) {
                    InvokeInstruction inv = (InvokeInstruction) ins;
                    Method called = isSelfCall(inv);
                    if (called != null) {
                        // Add edge to call graph
                        CallSite callSite = new CallSite(method, block, handle);
                        callGraph.createEdge(node, callGraph.getNodeForMethod(called), callSite);
View Full Code Here

Examples of org.apache.bcel.generic.InvokeInstruction

        short opcode = ins.getOpcode();
        if (opcode == Constants.IF_ACMPEQ || opcode == Constants.IF_ACMPNE) {
            checkRefComparison(location, jclass, method, methodGen, visitor, typeDataflow, stringComparisonList,
                    refComparisonList);
        } else if (ins instanceof InvokeInstruction) {
            InvokeInstruction inv = (InvokeInstruction) ins;
            boolean isStatic = inv instanceof INVOKESTATIC;
            @DottedClassName String className = inv.getClassName(cpg);
            String methodName = inv.getMethodName(cpg);
            String methodSig = inv.getSignature(cpg);
            if ( methodName.equals("assertSame") && methodSig.equals("(Ljava/lang/Object;Ljava/lang/Object;)V")) {
                checkRefComparison(location, jclass, method, methodGen, visitor, typeDataflow, stringComparisonList,
                        refComparisonList);
            } else if ( methodName.equals("assertFalse") && methodSig.equals("(Z)V")) {
                SourceLineAnnotation lastLocation = bugAccumulator.getLastBugLocation();
View Full Code Here

Examples of org.apache.bcel.generic.InvokeInstruction

        // Ignore top and bottom values
        if (lhsType_.getType() == T_TOP || lhsType_.getType() == T_BOTTOM || rhsType_.getType() == T_TOP
                || rhsType_.getType() == T_BOTTOM) {
            return;
        }
        InvokeInstruction inv = (InvokeInstruction) handle.getInstruction();
        MethodAnnotation calledMethodAnnotation = getMethodCalledAnnotation(cpg, inv);
        boolean looksLikeTestCase = TestCaseDetector.likelyTestCase(XFactory.createXMethod(methodGen));
        int priorityModifier = 0;
        if (looksLikeTestCase) {
            priorityModifier = 1;
View Full Code Here

Examples of org.apache.bcel.generic.InvokeInstruction

            if (frame != null) {
                if (rewriteable(method, ins)) {
                    // Add frame saver and restorer for the current breakpoint

                    // determine type of object for the method invocation
                    InvokeInstruction invoke = (InvokeInstruction)ins.getInstruction();
                    Type[] arguments = invoke.getArgumentTypes(method.getConstantPool())
                    ObjectType objecttype = null;
                    if (!(invoke instanceof INVOKESTATIC)) {
                        objecttype = (ObjectType)context.getInFrame().getStack().peek(arguments.length);
                    }
                    InstructionList rList = restoreFrame(method, ins, insFactory, frame, objecttype);
                    insList.append(ins, saveFrame(method, ins, count++, insFactory, frame));
                    invokeIns.addElement(rList.getStart());
                    restorer.append(rList);
                }    
                // remove all new's               
                if (ins.getInstruction().getOpcode() == Constants.NEW) {
                    try {
                        // remove additional dup's
                        while (next != null && next.getInstruction().getOpcode() == Constants.DUP) {
                            context = cfg.contextOf(next);
                            frame = context.getOutFrame(new ArrayList());
                            InstructionHandle newnext = next.getNext();
                            insList.delete(next);
                            next = newnext;
                        }
                        InstructionTargeter[] targeter = ins.getTargeters();
                        if (targeter != null) {
                            InstructionHandle newnext = ins.getNext();
                            for (int i = 0; i < targeter.length; i++) {
                                targeter[i].updateTarget(ins, newnext);
                            }
                        }
                        insList.delete(ins);
                    } catch (TargetLostException tle) {
                        throw new ClassNotFoundException(tle.getMessage(), tle);
                    }
                } else if (ins.getInstruction().getOpcode() == Constants.INVOKESPECIAL) {
                    // duplicate stack before invokespecial to insert uninitialized object
                    frame = context.getInFrame();
                    InvokeInstruction invoke = (InvokeInstruction)ins.getInstruction();
                    Type[] arguments = invoke.getArgumentTypes(method.getConstantPool());
   
                    OperandStack os = frame.getStack();
                    Type type = os.peek(arguments.length);
                    if (type instanceof UninitializedObjectType) {
                        ObjectType objecttype = ((UninitializedObjectType) type).getInitialized();
View Full Code Here

Examples of org.apache.bcel.generic.InvokeInstruction

            throws ClassNotFoundException {
        // check in the invocation can be a breakpoint.
        int opcode = handle.getInstruction().getOpcode();
        boolean invokeSpecialSuper = false;
        if (opcode == Constants.INVOKESPECIAL) {
            InvokeInstruction ivs = (InvokeInstruction) handle.getInstruction();
            String mName = ivs.getMethodName(method.getConstantPool());
            invokeSpecialSuper = !mName.equals(Constants.CONSTRUCTOR_NAME);
        }

        if (opcode == Constants.INVOKEVIRTUAL ||
            opcode == Constants.INVOKESTATIC ||
View Full Code Here

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

  public static BcelShadow makeStaticInitialization(BcelWorld world, LazyMethodGen enclosingMethod) {
    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().getConstantPool()).equals(NameMangler.AJC_PRE_CLINIT_NAME)) {
        clinitStart = clinitStart.getNext();
      }
    }

    InstructionHandle clinitEnd = body.getEnd();
View Full Code Here

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

  }

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

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

      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<ResolvedMember> methods = callee.getMethodsWithoutIterator(false, true, false);
        for (ResolvedMember resolvedMember : methods) {
          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
              ResolvedType memberType = m_aspectGen.getWorld().resolve(resolvedMember.getDeclaringType());
              if (!aspectType.equals(memberType) && memberType.isAssignableFrom(aspectType)) {
                // old test was...
                // if (aspectType.getSuperclass() != null
                // && aspectType.getSuperclass().getName().equals(resolvedMember.getDeclaringType().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.opcode == Constants.GETFIELD) || (inst.opcode == Constants.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);
            curr.setInstruction(newInst);

            break;// ok we found a matching callee member and swapped the instruction with the accessor
View Full Code Here

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

        InstructionList insList = aMethod.getBody();
        InstructionHandle handle = insList.getStart();
        while (handle != null) {
          if (handle.getInstruction().opcode == Constants.INVOKESPECIAL) {
            ConstantPool cpg = newParentTarget.getConstantPool();
            InvokeInstruction invokeSpecial = (InvokeInstruction) handle.getInstruction();
            if (invokeSpecial.getClassName(cpg).equals(currentParent)
                && invokeSpecial.getMethodName(cpg).equals("<init>")) {
              // System.err.println("Transforming super call '<init>" + invokeSpecial.getSignature(cpg) + "'");

              // 1. Check there is a ctor in the new parent with
              // the same signature
              ResolvedMember newCtor = getConstructorWithSignature(newParent, invokeSpecial.getSignature(cpg));

              if (newCtor == null) {

                // 2. Check ITDCs to see if the necessary ctor is provided that way
                boolean satisfiedByITDC = false;
                for (Iterator<ConcreteTypeMunger> ii = newParentTarget.getType()
                    .getInterTypeMungersIncludingSupers().iterator(); ii.hasNext() && !satisfiedByITDC;) {
                  ConcreteTypeMunger m = ii.next();
                  if (m.getMunger() instanceof NewConstructorTypeMunger) {
                    if (m.getSignature().getSignature().equals(invokeSpecial.getSignature(cpg))) {
                      satisfiedByITDC = true;
                    }
                  }
                }

                if (!satisfiedByITDC) {
                  String csig = createReadableCtorSig(newParent, cpg, invokeSpecial);
                  weaver.getWorld()
                      .getMessageHandler()
                      .handleMessage(
                          MessageUtil.error(
                              "Unable to modify hierarchy for " + newParentTarget.getClassName()
                                  + " - the constructor " + csig + " is missing",
                              this.getSourceLocation()));
                  return false;
                }
              }

              int idx = cpg.addMethodref(newParent.getName(), invokeSpecial.getMethodName(cpg),
                  invokeSpecial.getSignature(cpg));
              invokeSpecial.setIndex(idx);
            }
          }
          handle = handle.getNext();
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.