Package bytecodeparser.analysis.decoders

Examples of bytecodeparser.analysis.decoders.DecodedMethodInvocationOp


                    if(!frame.isAccessible) {
                        Logger.debug("WARNING : frame " + frame.index + " is NOT accessible");
                        continue;
                    }
                    if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
                        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
                        if(!dmio.getDeclaringClassName().equals("org.apache.commons.javaflow.bytecode.StackRecorder") &&
                                !dmio.getDeclaringClassName().startsWith("java.")) { // no need to track non-user method calls
                            MethodParams methodParams = DecodedMethodInvocationOp.resolveParameters(frame);
                           
                            String[] paramsNames = new String[methodParams.params.length + (methodParams.varargs != null ? methodParams.varargs.length : 0)];
                            for(int i = 0; i < methodParams.params.length; i++)
                                if(methodParams.params[i] != null && methodParams.params[i].name != null)
                                    paramsNames[i] = methodParams.params[i].name;
                            if(methodParams.varargs != null)
                                for(int i = 0, j = methodParams.params.length; i < methodParams.varargs.length; i++, j++)
                                    if(methodParams.varargs[i] != null && methodParams.varargs[i].name != null)
                                        paramsNames[j] = methodParams.varargs[i].name;

                            Bytecode b = makeInitMethodCall(behavior, dmio.getName(), dmio.getNbParameters(), methodParams.subject != null ? methodParams.subject.name : null, paramsNames);
                            insert(b, ctClass, behavior, codeAttribute, iterator, frame, false);
                        }
                    }
                    if(frame.decodedOp.op instanceof ExitOpcode) {
                        Bytecode b = makeExitMethod(behavior, ctClass.getName(), behavior.getName(), behavior.getSignature());
View Full Code Here


    }
    return null;
  }
 
  public static String getMethodNamedSignature(Context context, Frame frame) {
    DecodedMethodInvocationOp decoded = (DecodedMethodInvocationOp) frame.decodedOp;
    String name = decoded.getName();
    String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, true);
    StringBuffer sb = new StringBuffer();
    if(names.length > 0) {
      sb.append(names[0]);
      for(int i = 1; i < names.length; i++) {
View Full Code Here

    sb.insert(0, "(").insert(0, name).append(")");
    return sb.toString();
  }
 
  public static String[] methodInvocationNames(Frame frame) {
    DecodedMethodInvocationOp decoded = (DecodedMethodInvocationOp) frame.decodedOp;
    int nbParams = decoded.getNbParameters();
    String[] result = new String[nbParams];
    if(nbParams > 0) {
      int stackIndex = 0;
      if(frame.stackBefore.stack.get(stackIndex) instanceof TrackableArray) {
        StackElement[] varargs = ((TrackableArray) frame.stackBefore.stack.get(0)).elements;
View Full Code Here

    CtMethod method = getMethod(clazz, "simple");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
          switch(frame.index) {
            case 15:
              assertDeepEquals(names, new String[] {"subject", "myInt", "date"});
              break;
            case 21:
              assertDeepEquals(names, new String[] {null, null, "date"});
              break;
            case 30:
              assertDeepEquals(names, new String[] {null, null, null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

    CtMethod method = getMethod(clazz, "simpleWithParams");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
          switch(frame.index) {
            case 17:
              assertDeepEquals(names, new String[] {"subject", "myInt", "date"});
              break;
            case 24:
              assertDeepEquals(names, new String[] {null, null, "date"});
              break;
            case 33:
              assertDeepEquals(names, new String[] {null, null, null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

    CtMethod method = getMethod(clazz, "simpleWithConditionals");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
          switch(frame.index) {
            case 30:
              assertDeepEquals(names, new String[] {"subject", "myInt2", "date"});
              break;
            case 37:
              assertDeepEquals(names, new String[] {null, null, "date"});
              break;
            case 46:
              assertDeepEquals(names, new String[] {null, null, null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

    CtMethod method = getMethod(clazz, "varargs");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("varargs")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, true);
          switch(frame.index) {
            case 17:
              assertDeepEquals(names, new String[] {});
              break;
            case 35:
              assertDeepEquals(names, new String[] {"myInt", null, "myInt2"});
              break;
            case 45:
              assertDeepEquals(names, new String[] {null});
              break;
            case 54:
              assertDeepEquals(names, new String[] {"subject", "date"});
              break;
            case 67:
              assertDeepEquals(names, new String[] {"subject", "date", "myInt"});
              break;
            case 84:
              assertDeepEquals(names, new String[] {"subject", "date", "myInt", null});
              break;
            case 97:
              assertDeepEquals(names, new String[] {"subject", "date", null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

    CtMethod method = getMethod(clazz, "exceptions");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
          switch(frame.index) {
            case 15:
              assertDeepEquals(names, new String[] {"subject", "myInt", "date"});
              break;
            case 35:
              assertDeepEquals(names, new String[] {null, null, "date"});
              break;
            case 24:
            case 44:
            case 58:
              assertDeepEquals(names, new String[] {null, null, null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

    CtMethod method = getMethod(clazz, "tableswitchBlock");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
          switch(frame.index) {
            case 44:
              assertDeepEquals(names, new String[] {"subject", "myInt", "date"});
              break;
            case 53:
              assertDeepEquals(names, new String[] {null, null, "date"});
              break;
            case 65:
              assertDeepEquals(names, new String[] {null, null, null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

    CtMethod method = getMethod(clazz, "lookupswitchBlock");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
          switch(frame.index) {
            case 52:
              assertDeepEquals(names, new String[] {"subject", "myInt", "date"});
              break;
            case 61:
              assertDeepEquals(names, new String[] {null, null, "date"});
              break;
            case 73:
              assertDeepEquals(names, new String[] {null, null, null});
              break;
            default:
              throw new RuntimeException("could not handle index " + frame.index);
          }
          System.out.println(dmio.getName() + " -> " + Arrays.toString(names));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of bytecodeparser.analysis.decoders.DecodedMethodInvocationOp

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.